Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1d1e8ae19 | ||
|
|
a24acd2901 | ||
|
|
150ef2d30c |
@ -1,5 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## 0.4.14 - 2026-08-17
|
||||
|
||||
- Resolved the configured CinemachineBrain from camera tracks on descendant
|
||||
PlayableDirectors, including Cinemachine 3 `OutputCamera` setups, so
|
||||
orchestration Timelines can import AI results without duplicating camera
|
||||
tracks on the parent Timeline.
|
||||
- Made AI preview cloning inactive from construction and disconnected cloned
|
||||
authored Cinemachine tracks and virtual cameras before playback. This
|
||||
prevents the authored Motion Timeline from competing with the generated
|
||||
Shot tracks while preserving the original scene hierarchy. This is an
|
||||
Editor-only hotfix; the bundled Windows worker remains 0.1.9.
|
||||
|
||||
## 0.4.13 - 2026-08-16
|
||||
|
||||
- Enforced radial distance bounds on the actual float32 camera coordinates,
|
||||
|
||||
@ -17,7 +17,7 @@ must remain together.
|
||||
In Unity Package Manager, choose **Add package from git URL** and enter:
|
||||
|
||||
```text
|
||||
https://kindnick-git.duckdns.org/mingle/streamingle-unity-utilities.git?path=/CameraAI~#v0.1.19
|
||||
https://kindnick-git.duckdns.org/mingle/streamingle-unity-utilities.git?path=/CameraAI~#v0.1.20
|
||||
```
|
||||
|
||||
The initial package download is large because the frozen Windows worker is
|
||||
@ -26,7 +26,7 @@ it, remove the package lock entry, and add the package again.
|
||||
|
||||
## Reference data
|
||||
|
||||
Version 0.1.19 includes a compact, read-only `RuntimeData~` bundle with the
|
||||
Version 0.1.20 includes a compact, read-only `RuntimeData~` bundle with the
|
||||
263 prepared reference songs, cut policy, and ranker model. An artist
|
||||
workstation does not need a separate `CW-AI` checkout or Python installation.
|
||||
If a newer access-controlled library is available, it remains an optional
|
||||
|
||||
@ -440,7 +440,7 @@ namespace Streamingle.Editor
|
||||
originalDirector.gameObject.activeSelf;
|
||||
try
|
||||
{
|
||||
previewDirectorObject = UnityEngine.Object.Instantiate(
|
||||
previewDirectorObject = InstantiateInactivePreviewCloneForEditor(
|
||||
originalDirector.gameObject,
|
||||
originalDirector.transform.parent);
|
||||
Undo.RegisterCreatedObjectUndo(
|
||||
@ -456,6 +456,7 @@ namespace Streamingle.Editor
|
||||
originalTimeline,
|
||||
previewDirector,
|
||||
copiedTimeline);
|
||||
SuppressAuthoredCinemachineOutputsForEditor(previewDirector);
|
||||
MuteCopiedCameraTracks(previewDirector, copiedTimeline);
|
||||
MuteCopiedRecorderTracks(copiedTimeline);
|
||||
|
||||
@ -595,6 +596,7 @@ namespace Streamingle.Editor
|
||||
$"Position Dense C2 Fallbacks: {positionDenseFallbackCount:N0}",
|
||||
$"Preview Director: {GetHierarchyPath(previewDirector.transform)}",
|
||||
$"Preview Camera Root: {GetHierarchyPath(previewCameraObject.transform)}",
|
||||
GetPreviewOutputStatusForEditor(brain),
|
||||
$"Timeline Asset: {copiedTimelinePath}",
|
||||
$"Animation Assets: {generatedClipPaths.Count:N0} " +
|
||||
$"under {shotAnimationFolder}",
|
||||
@ -1449,6 +1451,8 @@ namespace Streamingle.Editor
|
||||
TimelineAsset finalTimeline = null;
|
||||
GameObject cameraPrefab = null;
|
||||
GameObject finalCameraRoot = null;
|
||||
AuthoredCinemachineStateSnapshot destinationCinemachineStateBefore =
|
||||
null;
|
||||
try
|
||||
{
|
||||
var sourceTimelinePath = AssetDatabase.GetAssetPath(sourceTimeline);
|
||||
@ -1511,6 +1515,11 @@ namespace Streamingle.Editor
|
||||
destinationTimelineBefore,
|
||||
finalTimeline,
|
||||
finalCameraRoot);
|
||||
destinationCinemachineStateBefore =
|
||||
CaptureAuthoredCinemachineState(destinationDirector);
|
||||
SuppressAuthoredCinemachineOutputsForEditor(
|
||||
destinationDirector,
|
||||
false);
|
||||
destinationDirector.time = destinationTimeBefore;
|
||||
destinationDirector.RebuildGraph();
|
||||
destinationDirector.time = destinationTimeBefore;
|
||||
@ -1545,6 +1554,8 @@ namespace Streamingle.Editor
|
||||
}
|
||||
catch
|
||||
{
|
||||
RestoreAuthoredCinemachineState(
|
||||
destinationCinemachineStateBefore);
|
||||
RestoreDestinationDirectorAfterFinalizationFailure(
|
||||
destinationStateBefore,
|
||||
finalTimeline);
|
||||
@ -1943,6 +1954,7 @@ namespace Streamingle.Editor
|
||||
destinationDirector.SetReferenceValue(exposedName, camera);
|
||||
EditorUtility.SetDirty(shot);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal static void ClearTimelineBindingsForFinalization(
|
||||
@ -5575,6 +5587,46 @@ namespace Streamingle.Editor
|
||||
return clonedComponents[index];
|
||||
}
|
||||
|
||||
internal static GameObject InstantiateInactivePreviewCloneForEditor(
|
||||
GameObject sourceObject,
|
||||
Transform destinationParent)
|
||||
{
|
||||
if (sourceObject == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(sourceObject));
|
||||
}
|
||||
|
||||
var sourceScene = sourceObject.scene;
|
||||
if (!sourceScene.IsValid() || !sourceScene.isLoaded)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The source Timeline object must belong to a loaded scene.");
|
||||
}
|
||||
|
||||
var stagingObject = new GameObject(
|
||||
"__CWAI_InactivePreviewCloneStaging");
|
||||
stagingObject.SetActive(false);
|
||||
try
|
||||
{
|
||||
if (stagingObject.scene != sourceScene)
|
||||
{
|
||||
SceneManager.MoveGameObjectToScene(stagingObject, sourceScene);
|
||||
}
|
||||
|
||||
var clone = UnityEngine.Object.Instantiate(
|
||||
sourceObject,
|
||||
stagingObject.transform,
|
||||
true);
|
||||
clone.SetActive(false);
|
||||
clone.transform.SetParent(destinationParent, true);
|
||||
return clone;
|
||||
}
|
||||
finally
|
||||
{
|
||||
UnityEngine.Object.DestroyImmediate(stagingObject);
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureNoExistingPreview(
|
||||
Scene scene,
|
||||
string previewDirectorName,
|
||||
@ -5645,30 +5697,49 @@ namespace Streamingle.Editor
|
||||
}
|
||||
|
||||
var scene = director.gameObject.scene;
|
||||
var boundBrains = timeline.GetOutputTracks()
|
||||
.OfType<CinemachineTrack>()
|
||||
.Select(track => director.GetGenericBinding(track) as CinemachineBrain)
|
||||
.Where(brain => brain != null)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
if (boundBrains.Length > 1)
|
||||
var directlyBoundBrains = GetBoundCinemachineBrains(
|
||||
director,
|
||||
timeline);
|
||||
if (directlyBoundBrains.Length > 1)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The Timeline has Cinemachine Tracks bound to multiple " +
|
||||
"CinemachineBrain components. Bind every camera track to one Brain.");
|
||||
}
|
||||
|
||||
if (boundBrains.Length == 1)
|
||||
if (directlyBoundBrains.Length == 1)
|
||||
{
|
||||
var boundBrain = boundBrains[0];
|
||||
if (!IsUsableCinemachineBrain(boundBrain, scene))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The CinemachineBrain bound to the Timeline must be enabled, " +
|
||||
"attached to an enabled Camera, and belong to the Timeline scene.");
|
||||
}
|
||||
return ValidateExplicitCinemachineBrain(
|
||||
directlyBoundBrains[0],
|
||||
scene);
|
||||
}
|
||||
|
||||
return boundBrain;
|
||||
var descendantBoundBrains = director.gameObject
|
||||
.GetComponentsInChildren<PlayableDirector>(true)
|
||||
.Where(descendant =>
|
||||
descendant != null &&
|
||||
descendant != director &&
|
||||
descendant.gameObject.scene == scene &&
|
||||
descendant.playableAsset is TimelineAsset)
|
||||
.SelectMany(descendant => GetBoundCinemachineBrains(
|
||||
descendant,
|
||||
(TimelineAsset)descendant.playableAsset))
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
if (descendantBoundBrains.Length > 1)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Descendant PlayableDirectors under the selected Timeline object " +
|
||||
"have Cinemachine Tracks bound to multiple CinemachineBrain " +
|
||||
"components. Bind them to one Brain or bind the selected Timeline " +
|
||||
"directly.");
|
||||
}
|
||||
|
||||
if (descendantBoundBrains.Length == 1)
|
||||
{
|
||||
return ValidateExplicitCinemachineBrain(
|
||||
descendantBoundBrains[0],
|
||||
scene);
|
||||
}
|
||||
|
||||
var usableBrains = sceneBrains
|
||||
@ -5678,7 +5749,7 @@ namespace Streamingle.Editor
|
||||
var mainCameraBrains = usableBrains
|
||||
.Where(brain =>
|
||||
{
|
||||
var camera = brain.GetComponent<Camera>();
|
||||
var camera = brain.OutputCamera;
|
||||
return camera != null && camera.CompareTag("MainCamera");
|
||||
})
|
||||
.ToArray();
|
||||
@ -5714,6 +5785,81 @@ namespace Streamingle.Editor
|
||||
"one Camera as MainCamera or bind a Cinemachine Track explicitly.");
|
||||
}
|
||||
|
||||
private static CinemachineBrain[] GetBoundCinemachineBrains(
|
||||
PlayableDirector director,
|
||||
TimelineAsset timeline)
|
||||
{
|
||||
return timeline.GetOutputTracks()
|
||||
.OfType<CinemachineTrack>()
|
||||
.Select(track =>
|
||||
director.GetGenericBinding(track) as CinemachineBrain)
|
||||
.Where(brain => brain != null)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static CinemachineBrain ValidateExplicitCinemachineBrain(
|
||||
CinemachineBrain brain,
|
||||
Scene scene)
|
||||
{
|
||||
if (brain.gameObject.scene != scene)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The CinemachineBrain explicitly bound to a Timeline must belong " +
|
||||
"to the same scene as the selected Timeline director.");
|
||||
}
|
||||
|
||||
var camera = brain.OutputCamera;
|
||||
if (camera == null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The CinemachineBrain explicitly bound to a Timeline must have an " +
|
||||
"output Camera component on its controlled GameObject.");
|
||||
}
|
||||
|
||||
if (camera.gameObject.scene != scene)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The CinemachineBrain output Camera explicitly bound to a Timeline " +
|
||||
"must belong to the same scene as the selected Timeline director.");
|
||||
}
|
||||
|
||||
if (!brain.isActiveAndEnabled || !camera.isActiveAndEnabled)
|
||||
{
|
||||
Debug.LogWarning(
|
||||
"The CinemachineBrain explicitly bound to a Timeline or its " +
|
||||
"Camera is disabled. Camera AI will use the configured Brain " +
|
||||
"without enabling either component automatically.",
|
||||
brain);
|
||||
}
|
||||
|
||||
return brain;
|
||||
}
|
||||
|
||||
internal static string GetPreviewOutputStatusForEditor(
|
||||
CinemachineBrain brain)
|
||||
{
|
||||
if (brain == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(brain));
|
||||
}
|
||||
|
||||
var camera = brain.OutputCamera;
|
||||
var cameraName = camera != null
|
||||
? camera.gameObject.name
|
||||
: brain.gameObject.name;
|
||||
if (camera != null &&
|
||||
brain.isActiveAndEnabled &&
|
||||
camera.isActiveAndEnabled)
|
||||
{
|
||||
return $"Preview Output: configured '{cameraName}' CinemachineBrain " +
|
||||
"and Camera are active.";
|
||||
}
|
||||
|
||||
return $"Preview Output: configured '{cameraName}' CinemachineBrain or " +
|
||||
"Camera is disabled; enable it to see AI camera playback.";
|
||||
}
|
||||
|
||||
private static bool IsUsableCinemachineBrain(
|
||||
CinemachineBrain brain,
|
||||
Scene scene)
|
||||
@ -5725,8 +5871,193 @@ namespace Streamingle.Editor
|
||||
return false;
|
||||
}
|
||||
|
||||
var camera = brain.GetComponent<Camera>();
|
||||
return camera != null && camera.isActiveAndEnabled;
|
||||
var camera = brain.OutputCamera;
|
||||
return camera != null &&
|
||||
camera.gameObject.scene == scene &&
|
||||
camera.isActiveAndEnabled;
|
||||
}
|
||||
|
||||
internal static void SuppressAuthoredCinemachineOutputsForEditor(
|
||||
PlayableDirector selectedDirector,
|
||||
bool recordUndo = true)
|
||||
{
|
||||
if (selectedDirector == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(selectedDirector));
|
||||
}
|
||||
|
||||
var directorObject = selectedDirector.gameObject;
|
||||
var descendantDirectors = directorObject
|
||||
.GetComponentsInChildren<PlayableDirector>(true)
|
||||
.Where(descendant =>
|
||||
descendant != null &&
|
||||
descendant != selectedDirector &&
|
||||
descendant.playableAsset is TimelineAsset)
|
||||
.ToArray();
|
||||
foreach (var descendantDirector in descendantDirectors)
|
||||
{
|
||||
var descendantTimeline =
|
||||
(TimelineAsset)descendantDirector.playableAsset;
|
||||
var cinemachineTracks = descendantTimeline.GetOutputTracks()
|
||||
.OfType<CinemachineTrack>()
|
||||
.ToArray();
|
||||
if (cinemachineTracks.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (recordUndo)
|
||||
{
|
||||
Undo.RecordObject(
|
||||
descendantDirector,
|
||||
"Disconnect Authored Cameras From AI Preview");
|
||||
}
|
||||
|
||||
foreach (var cinemachineTrack in cinemachineTracks)
|
||||
{
|
||||
descendantDirector.ClearGenericBinding(cinemachineTrack);
|
||||
}
|
||||
|
||||
RebuildDirectorGraphPreservingPlayback(descendantDirector);
|
||||
|
||||
EditorUtility.SetDirty(descendantDirector);
|
||||
}
|
||||
|
||||
foreach (var authoredCamera in directorObject
|
||||
.GetComponentsInChildren<CinemachineVirtualCameraBase>(true))
|
||||
{
|
||||
if (authoredCamera == null || !authoredCamera.enabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (recordUndo)
|
||||
{
|
||||
Undo.RecordObject(
|
||||
authoredCamera,
|
||||
"Disable Authored Cameras In AI Output");
|
||||
}
|
||||
|
||||
authoredCamera.enabled = false;
|
||||
EditorUtility.SetDirty(authoredCamera);
|
||||
}
|
||||
}
|
||||
|
||||
internal static AuthoredCinemachineStateSnapshot
|
||||
CaptureAuthoredCinemachineState(PlayableDirector selectedDirector)
|
||||
{
|
||||
if (selectedDirector == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(selectedDirector));
|
||||
}
|
||||
|
||||
var directorObject = selectedDirector.gameObject;
|
||||
var directorStates = directorObject
|
||||
.GetComponentsInChildren<PlayableDirector>(true)
|
||||
.Where(descendant =>
|
||||
descendant != null &&
|
||||
descendant != selectedDirector &&
|
||||
descendant.playableAsset is TimelineAsset)
|
||||
.Select(descendant =>
|
||||
{
|
||||
var timeline = (TimelineAsset)descendant.playableAsset;
|
||||
var tracks = timeline.GetOutputTracks()
|
||||
.OfType<CinemachineTrack>()
|
||||
.ToArray();
|
||||
return new AuthoredCinemachineDirectorState(
|
||||
descendant,
|
||||
tracks,
|
||||
tracks.Select(descendant.GetGenericBinding).ToArray());
|
||||
})
|
||||
.Where(state => state.Tracks.Length > 0)
|
||||
.ToArray();
|
||||
var cameraStates = directorObject
|
||||
.GetComponentsInChildren<CinemachineVirtualCameraBase>(true)
|
||||
.Where(camera => camera != null)
|
||||
.Select(camera => new AuthoredVirtualCameraState(
|
||||
camera,
|
||||
camera.enabled))
|
||||
.ToArray();
|
||||
return new AuthoredCinemachineStateSnapshot(
|
||||
directorStates,
|
||||
cameraStates);
|
||||
}
|
||||
|
||||
internal static void RestoreAuthoredCinemachineState(
|
||||
AuthoredCinemachineStateSnapshot snapshot)
|
||||
{
|
||||
if (snapshot == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var cameraState in snapshot.CameraStates)
|
||||
{
|
||||
if (cameraState.Camera == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
cameraState.Camera.enabled = cameraState.Enabled;
|
||||
EditorUtility.SetDirty(cameraState.Camera);
|
||||
}
|
||||
|
||||
foreach (var directorState in snapshot.DirectorStates)
|
||||
{
|
||||
var director = directorState.Director;
|
||||
if (director == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var index = 0; index < directorState.Tracks.Length; index++)
|
||||
{
|
||||
var track = directorState.Tracks[index];
|
||||
if (track == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var binding = directorState.Bindings[index];
|
||||
if (binding != null)
|
||||
{
|
||||
director.SetGenericBinding(track, binding);
|
||||
}
|
||||
else
|
||||
{
|
||||
director.ClearGenericBinding(track);
|
||||
}
|
||||
}
|
||||
|
||||
RebuildDirectorGraphPreservingPlayback(director);
|
||||
|
||||
EditorUtility.SetDirty(director);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RebuildDirectorGraphPreservingPlayback(
|
||||
PlayableDirector director)
|
||||
{
|
||||
if (!director.playableGraph.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var time = director.time;
|
||||
var wasPlaying = director.state == PlayState.Playing;
|
||||
director.Stop();
|
||||
director.RebuildGraph();
|
||||
director.time = time;
|
||||
if (wasPlaying)
|
||||
{
|
||||
director.Play();
|
||||
director.time = time;
|
||||
}
|
||||
else
|
||||
{
|
||||
director.Evaluate();
|
||||
director.time = time;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CopyTrackBindings(
|
||||
@ -6944,6 +7275,51 @@ namespace Streamingle.Editor
|
||||
public GameObject CameraRoot { get; }
|
||||
}
|
||||
|
||||
internal sealed class AuthoredCinemachineStateSnapshot
|
||||
{
|
||||
public AuthoredCinemachineStateSnapshot(
|
||||
AuthoredCinemachineDirectorState[] directorStates,
|
||||
AuthoredVirtualCameraState[] cameraStates)
|
||||
{
|
||||
DirectorStates = directorStates;
|
||||
CameraStates = cameraStates;
|
||||
}
|
||||
|
||||
public AuthoredCinemachineDirectorState[] DirectorStates { get; }
|
||||
public AuthoredVirtualCameraState[] CameraStates { get; }
|
||||
}
|
||||
|
||||
internal sealed class AuthoredCinemachineDirectorState
|
||||
{
|
||||
public AuthoredCinemachineDirectorState(
|
||||
PlayableDirector director,
|
||||
CinemachineTrack[] tracks,
|
||||
UnityEngine.Object[] bindings)
|
||||
{
|
||||
Director = director;
|
||||
Tracks = tracks;
|
||||
Bindings = bindings;
|
||||
}
|
||||
|
||||
public PlayableDirector Director { get; }
|
||||
public CinemachineTrack[] Tracks { get; }
|
||||
public UnityEngine.Object[] Bindings { get; }
|
||||
}
|
||||
|
||||
internal sealed class AuthoredVirtualCameraState
|
||||
{
|
||||
public AuthoredVirtualCameraState(
|
||||
CinemachineVirtualCameraBase camera,
|
||||
bool enabled)
|
||||
{
|
||||
Camera = camera;
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public CinemachineVirtualCameraBase Camera { get; }
|
||||
public bool Enabled { get; }
|
||||
}
|
||||
|
||||
private sealed class DirectorStateSnapshot
|
||||
{
|
||||
public DirectorStateSnapshot(
|
||||
|
||||
@ -16,7 +16,7 @@ Cinemachine Track이나 기존 카메라 애니메이션은 필요하지 않으
|
||||
Unity Package Manager의 `Add package from git URL`에는 다음 주소를 사용할 수
|
||||
있습니다.
|
||||
|
||||
`https://kindnick-git.duckdns.org/mingle/streamingle-unity-utilities.git?path=/CameraAI~#v0.1.19`
|
||||
`https://kindnick-git.duckdns.org/mingle/streamingle-unity-utilities.git?path=/CameraAI~#v0.1.20`
|
||||
|
||||
배포 패키지에는 Windows x64용 `CWCameraWorker` 폴더 전체가 포함됩니다.
|
||||
Python은 따로 설치하지 않아도 되지만, Git 패키지의 대용량 바이너리를 받으려면
|
||||
|
||||
@ -6,13 +6,26 @@ using System.Text;
|
||||
using NUnit.Framework;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.Timeline;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Streamingle.Editor.Tests
|
||||
{
|
||||
public sealed class PreviewCloneActivationProbe : MonoBehaviour
|
||||
{
|
||||
internal static int EnableCount { get; set; }
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
EnableCount++;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AICameraTimelinePreviewImporterTests
|
||||
{
|
||||
[Test]
|
||||
@ -34,6 +47,10 @@ namespace Streamingle.Editor.Tests
|
||||
timeline,
|
||||
new[] { brain }),
|
||||
Is.SameAs(brain));
|
||||
Assert.That(
|
||||
AICameraTimelinePreviewImporter
|
||||
.GetPreviewOutputStatusForEditor(brain),
|
||||
Does.Contain("are active"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -111,6 +128,843 @@ namespace Streamingle.Editor.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BrainResolutionUsesDisabledUniqueDescendantBinding()
|
||||
{
|
||||
var directorObject = new GameObject("Director");
|
||||
var childDirectorObject = new GameObject("Camera Director");
|
||||
var cameraObject = new GameObject("Configured Camera");
|
||||
childDirectorObject.transform.SetParent(directorObject.transform, false);
|
||||
var timeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
TimelineAsset childTimeline = null;
|
||||
try
|
||||
{
|
||||
var director = directorObject.AddComponent<PlayableDirector>();
|
||||
director.playableAsset = timeline;
|
||||
var childDirector =
|
||||
childDirectorObject.AddComponent<PlayableDirector>();
|
||||
cameraObject.AddComponent<Camera>();
|
||||
var brain = cameraObject.AddComponent<CinemachineBrain>();
|
||||
childTimeline = CreateTimelineBoundToBrain(
|
||||
childDirector,
|
||||
brain,
|
||||
"Child Camera Track");
|
||||
childDirectorObject.SetActive(false);
|
||||
brain.enabled = false;
|
||||
|
||||
LogAssert.Expect(
|
||||
LogType.Warning,
|
||||
"The CinemachineBrain explicitly bound to a Timeline or its " +
|
||||
"Camera is disabled. Camera AI will use the configured Brain " +
|
||||
"without enabling either component automatically.");
|
||||
Assert.That(
|
||||
AICameraTimelinePreviewImporter.ResolveCinemachineBrainForEditor(
|
||||
director,
|
||||
timeline,
|
||||
new[] { brain }),
|
||||
Is.SameAs(brain));
|
||||
Assert.That(brain.enabled, Is.False);
|
||||
Assert.That(
|
||||
AICameraTimelinePreviewImporter
|
||||
.GetPreviewOutputStatusForEditor(brain),
|
||||
Does.Contain("enable it to see AI camera playback"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(directorObject);
|
||||
Object.DestroyImmediate(cameraObject);
|
||||
Object.DestroyImmediate(childTimeline);
|
||||
Object.DestroyImmediate(timeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BrainResolutionDeduplicatesSameBrainAcrossDescendants()
|
||||
{
|
||||
var directorObject = new GameObject("Director");
|
||||
var firstChildObject = new GameObject("First Camera Director");
|
||||
var secondChildObject = new GameObject("Second Camera Director");
|
||||
var cameraObject = new GameObject("Configured Camera");
|
||||
firstChildObject.transform.SetParent(directorObject.transform, false);
|
||||
secondChildObject.transform.SetParent(directorObject.transform, false);
|
||||
var timeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
TimelineAsset firstChildTimeline = null;
|
||||
TimelineAsset secondChildTimeline = null;
|
||||
try
|
||||
{
|
||||
var director = directorObject.AddComponent<PlayableDirector>();
|
||||
director.playableAsset = timeline;
|
||||
var firstChildDirector =
|
||||
firstChildObject.AddComponent<PlayableDirector>();
|
||||
var secondChildDirector =
|
||||
secondChildObject.AddComponent<PlayableDirector>();
|
||||
cameraObject.AddComponent<Camera>();
|
||||
var brain = cameraObject.AddComponent<CinemachineBrain>();
|
||||
firstChildTimeline = CreateTimelineBoundToBrain(
|
||||
firstChildDirector,
|
||||
brain,
|
||||
"First Child Camera Track");
|
||||
secondChildTimeline = CreateTimelineBoundToBrain(
|
||||
secondChildDirector,
|
||||
brain,
|
||||
"Second Child Camera Track");
|
||||
|
||||
Assert.That(
|
||||
AICameraTimelinePreviewImporter.ResolveCinemachineBrainForEditor(
|
||||
director,
|
||||
timeline,
|
||||
Array.Empty<CinemachineBrain>()),
|
||||
Is.SameAs(brain));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(directorObject);
|
||||
Object.DestroyImmediate(cameraObject);
|
||||
Object.DestroyImmediate(firstChildTimeline);
|
||||
Object.DestroyImmediate(secondChildTimeline);
|
||||
Object.DestroyImmediate(timeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BrainResolutionRejectsAmbiguousDescendantBindings()
|
||||
{
|
||||
var directorObject = new GameObject("Director");
|
||||
var firstChildObject = new GameObject("First Camera Director");
|
||||
var secondChildObject = new GameObject("Second Camera Director");
|
||||
var firstCameraObject = new GameObject("First Configured Camera");
|
||||
var secondCameraObject = new GameObject("Second Configured Camera");
|
||||
firstChildObject.transform.SetParent(directorObject.transform, false);
|
||||
secondChildObject.transform.SetParent(directorObject.transform, false);
|
||||
var timeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
TimelineAsset firstChildTimeline = null;
|
||||
TimelineAsset secondChildTimeline = null;
|
||||
try
|
||||
{
|
||||
var director = directorObject.AddComponent<PlayableDirector>();
|
||||
director.playableAsset = timeline;
|
||||
var firstChildDirector =
|
||||
firstChildObject.AddComponent<PlayableDirector>();
|
||||
var secondChildDirector =
|
||||
secondChildObject.AddComponent<PlayableDirector>();
|
||||
firstCameraObject.AddComponent<Camera>();
|
||||
var firstBrain =
|
||||
firstCameraObject.AddComponent<CinemachineBrain>();
|
||||
secondCameraObject.AddComponent<Camera>();
|
||||
var secondBrain =
|
||||
secondCameraObject.AddComponent<CinemachineBrain>();
|
||||
firstChildTimeline = CreateTimelineBoundToBrain(
|
||||
firstChildDirector,
|
||||
firstBrain,
|
||||
"First Child Camera Track");
|
||||
secondChildTimeline = CreateTimelineBoundToBrain(
|
||||
secondChildDirector,
|
||||
secondBrain,
|
||||
"Second Child Camera Track");
|
||||
|
||||
Assert.That(
|
||||
() => AICameraTimelinePreviewImporter
|
||||
.ResolveCinemachineBrainForEditor(
|
||||
director,
|
||||
timeline,
|
||||
new[] { firstBrain, secondBrain }),
|
||||
Throws.TypeOf<InvalidOperationException>()
|
||||
.With.Message.Contains("Descendant PlayableDirectors"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(directorObject);
|
||||
Object.DestroyImmediate(firstCameraObject);
|
||||
Object.DestroyImmediate(secondCameraObject);
|
||||
Object.DestroyImmediate(firstChildTimeline);
|
||||
Object.DestroyImmediate(secondChildTimeline);
|
||||
Object.DestroyImmediate(timeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BrainResolutionPrefersDirectBindingOverDescendants()
|
||||
{
|
||||
var directorObject = new GameObject("Director");
|
||||
var childDirectorObject = new GameObject("Camera Director");
|
||||
var directCameraObject = new GameObject("Direct Camera");
|
||||
var childCameraObject = new GameObject("Child Camera");
|
||||
childDirectorObject.transform.SetParent(directorObject.transform, false);
|
||||
TimelineAsset timeline = null;
|
||||
TimelineAsset childTimeline = null;
|
||||
try
|
||||
{
|
||||
var director = directorObject.AddComponent<PlayableDirector>();
|
||||
var childDirector =
|
||||
childDirectorObject.AddComponent<PlayableDirector>();
|
||||
directCameraObject.AddComponent<Camera>();
|
||||
var directBrain =
|
||||
directCameraObject.AddComponent<CinemachineBrain>();
|
||||
childCameraObject.AddComponent<Camera>();
|
||||
var childBrain =
|
||||
childCameraObject.AddComponent<CinemachineBrain>();
|
||||
timeline = CreateTimelineBoundToBrain(
|
||||
director,
|
||||
directBrain,
|
||||
"Direct Camera Track");
|
||||
childTimeline = CreateTimelineBoundToBrain(
|
||||
childDirector,
|
||||
childBrain,
|
||||
"Child Camera Track");
|
||||
|
||||
Assert.That(
|
||||
AICameraTimelinePreviewImporter.ResolveCinemachineBrainForEditor(
|
||||
director,
|
||||
timeline,
|
||||
new[] { childBrain, directBrain }),
|
||||
Is.SameAs(directBrain));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(directorObject);
|
||||
Object.DestroyImmediate(directCameraObject);
|
||||
Object.DestroyImmediate(childCameraObject);
|
||||
Object.DestroyImmediate(childTimeline);
|
||||
Object.DestroyImmediate(timeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BrainResolutionRejectsExplicitBrainFromAnotherScene()
|
||||
{
|
||||
var directorObject = new GameObject("Director");
|
||||
var cameraObject = new GameObject("Foreign Camera");
|
||||
var foreignScene = EditorSceneManager.NewPreviewScene();
|
||||
SceneManager.MoveGameObjectToScene(cameraObject, foreignScene);
|
||||
TimelineAsset timeline = null;
|
||||
try
|
||||
{
|
||||
var director = directorObject.AddComponent<PlayableDirector>();
|
||||
cameraObject.AddComponent<Camera>();
|
||||
var brain = cameraObject.AddComponent<CinemachineBrain>();
|
||||
timeline = CreateTimelineBoundToBrain(
|
||||
director,
|
||||
brain,
|
||||
"Foreign Camera Track");
|
||||
|
||||
Assert.That(
|
||||
() => AICameraTimelinePreviewImporter
|
||||
.ResolveCinemachineBrainForEditor(
|
||||
director,
|
||||
timeline,
|
||||
new[] { brain }),
|
||||
Throws.TypeOf<InvalidOperationException>()
|
||||
.With.Message.Contains("same scene"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(directorObject);
|
||||
Object.DestroyImmediate(cameraObject);
|
||||
Object.DestroyImmediate(timeline);
|
||||
EditorSceneManager.ClosePreviewScene(foreignScene);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BrainResolutionRejectsExplicitBrainWithoutCamera()
|
||||
{
|
||||
var directorObject = new GameObject("Director");
|
||||
var cameraObject = new GameObject("Camera-less Brain");
|
||||
TimelineAsset timeline = null;
|
||||
try
|
||||
{
|
||||
var director = directorObject.AddComponent<PlayableDirector>();
|
||||
var camera = cameraObject.AddComponent<Camera>();
|
||||
var brain = cameraObject.AddComponent<CinemachineBrain>();
|
||||
Object.DestroyImmediate(camera);
|
||||
timeline = CreateTimelineBoundToBrain(
|
||||
director,
|
||||
brain,
|
||||
"Invalid Camera Track");
|
||||
|
||||
Assert.That(
|
||||
() => AICameraTimelinePreviewImporter
|
||||
.ResolveCinemachineBrainForEditor(
|
||||
director,
|
||||
timeline,
|
||||
new[] { brain }),
|
||||
Throws.TypeOf<InvalidOperationException>()
|
||||
.With.Message.Contains("Camera component"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(directorObject);
|
||||
Object.DestroyImmediate(cameraObject);
|
||||
Object.DestroyImmediate(timeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BrainResolutionAcceptsSeparateControlledOutputCamera()
|
||||
{
|
||||
var directorObject = new GameObject("Director");
|
||||
var brainObject = new GameObject("Configured Brain");
|
||||
var outputCameraObject = new GameObject("Controlled Output Camera");
|
||||
TimelineAsset timeline = null;
|
||||
try
|
||||
{
|
||||
var director = directorObject.AddComponent<PlayableDirector>();
|
||||
var brain = brainObject.AddComponent<CinemachineBrain>();
|
||||
var outputCamera = outputCameraObject.AddComponent<Camera>();
|
||||
brain.ControlledObject = outputCameraObject;
|
||||
timeline = CreateTimelineBoundToBrain(
|
||||
director,
|
||||
brain,
|
||||
"Controlled Output Camera Track");
|
||||
|
||||
Assert.That(brain.OutputCamera, Is.SameAs(outputCamera));
|
||||
Assert.That(
|
||||
AICameraTimelinePreviewImporter.ResolveCinemachineBrainForEditor(
|
||||
director,
|
||||
timeline,
|
||||
new[] { brain }),
|
||||
Is.SameAs(brain));
|
||||
Assert.That(
|
||||
AICameraTimelinePreviewImporter
|
||||
.GetPreviewOutputStatusForEditor(brain),
|
||||
Does.Contain(outputCameraObject.name));
|
||||
Assert.That(
|
||||
AICameraTimelinePreviewImporter
|
||||
.GetPreviewOutputStatusForEditor(brain),
|
||||
Does.Contain("are active"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(directorObject);
|
||||
Object.DestroyImmediate(brainObject);
|
||||
Object.DestroyImmediate(outputCameraObject);
|
||||
Object.DestroyImmediate(timeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BrainResolutionUsesControlledOutputMainCameraForFallback()
|
||||
{
|
||||
var directorObject = new GameObject("Director");
|
||||
var mainBrainObject = new GameObject("Main Output Brain");
|
||||
var mainCameraObject = new GameObject("Main Output Camera");
|
||||
var secondaryCameraObject = new GameObject("Secondary Camera");
|
||||
var timeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
try
|
||||
{
|
||||
var director = directorObject.AddComponent<PlayableDirector>();
|
||||
director.playableAsset = timeline;
|
||||
var mainBrain = mainBrainObject.AddComponent<CinemachineBrain>();
|
||||
mainCameraObject.tag = "MainCamera";
|
||||
mainCameraObject.AddComponent<Camera>();
|
||||
mainBrain.ControlledObject = mainCameraObject;
|
||||
secondaryCameraObject.AddComponent<Camera>();
|
||||
var secondaryBrain =
|
||||
secondaryCameraObject.AddComponent<CinemachineBrain>();
|
||||
|
||||
Assert.That(
|
||||
AICameraTimelinePreviewImporter.ResolveCinemachineBrainForEditor(
|
||||
director,
|
||||
timeline,
|
||||
new[] { secondaryBrain, mainBrain }),
|
||||
Is.SameAs(mainBrain));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(directorObject);
|
||||
Object.DestroyImmediate(mainBrainObject);
|
||||
Object.DestroyImmediate(mainCameraObject);
|
||||
Object.DestroyImmediate(secondaryCameraObject);
|
||||
Object.DestroyImmediate(timeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BrainResolutionRejectsControlledOutputCameraFromAnotherScene()
|
||||
{
|
||||
var directorObject = new GameObject("Director");
|
||||
var brainObject = new GameObject("Configured Brain");
|
||||
var outputCameraObject = new GameObject("Foreign Output Camera");
|
||||
var foreignScene = EditorSceneManager.NewPreviewScene();
|
||||
SceneManager.MoveGameObjectToScene(outputCameraObject, foreignScene);
|
||||
TimelineAsset timeline = null;
|
||||
try
|
||||
{
|
||||
var director = directorObject.AddComponent<PlayableDirector>();
|
||||
var brain = brainObject.AddComponent<CinemachineBrain>();
|
||||
outputCameraObject.AddComponent<Camera>();
|
||||
brain.ControlledObject = outputCameraObject;
|
||||
timeline = CreateTimelineBoundToBrain(
|
||||
director,
|
||||
brain,
|
||||
"Foreign Controlled Output Track");
|
||||
|
||||
Assert.That(
|
||||
() => AICameraTimelinePreviewImporter
|
||||
.ResolveCinemachineBrainForEditor(
|
||||
director,
|
||||
timeline,
|
||||
new[] { brain }),
|
||||
Throws.TypeOf<InvalidOperationException>()
|
||||
.With.Message.Contains("output Camera")
|
||||
.And.Message.Contains("same scene"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(directorObject);
|
||||
Object.DestroyImmediate(brainObject);
|
||||
Object.DestroyImmediate(outputCameraObject);
|
||||
Object.DestroyImmediate(timeline);
|
||||
EditorSceneManager.ClosePreviewScene(foreignScene);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InactiveStagingCloneNeverActivatesAndPreservesSourcePlayback()
|
||||
{
|
||||
var parentObject = new GameObject("Preview Parent");
|
||||
var sourceObject = new GameObject("Source Director");
|
||||
var motionObject = new GameObject("Motion Director");
|
||||
var authoredCameraObject = new GameObject("Authored Virtual Camera");
|
||||
sourceObject.transform.SetParent(parentObject.transform, false);
|
||||
motionObject.transform.SetParent(sourceObject.transform, false);
|
||||
authoredCameraObject.transform.SetParent(
|
||||
motionObject.transform,
|
||||
false);
|
||||
parentObject.transform.position = new Vector3(4f, -2f, 7f);
|
||||
sourceObject.transform.localPosition = new Vector3(1f, 2f, 3f);
|
||||
var sourceTimeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
var motionTimeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
GameObject cloneObject = null;
|
||||
PlayableDirector motionDirector = null;
|
||||
try
|
||||
{
|
||||
var sourceDirector =
|
||||
sourceObject.AddComponent<PlayableDirector>();
|
||||
sourceDirector.playOnAwake = false;
|
||||
sourceDirector.playableAsset = sourceTimeline;
|
||||
motionDirector = motionObject.AddComponent<PlayableDirector>();
|
||||
motionDirector.playOnAwake = true;
|
||||
motionDirector.timeUpdateMode = DirectorUpdateMode.Manual;
|
||||
motionDirector.playableAsset = motionTimeline;
|
||||
var authoredCamera = authoredCameraObject
|
||||
.AddComponent<CinemachineCamera>();
|
||||
sourceObject.AddComponent<PreviewCloneActivationProbe>();
|
||||
|
||||
motionDirector.Play();
|
||||
motionDirector.time = 0.4d;
|
||||
motionDirector.Evaluate();
|
||||
var sourceWorldPosition = sourceObject.transform.position;
|
||||
var sourcePlaybackState = motionDirector.state;
|
||||
PreviewCloneActivationProbe.EnableCount = 0;
|
||||
|
||||
cloneObject = AICameraTimelinePreviewImporter
|
||||
.InstantiateInactivePreviewCloneForEditor(
|
||||
sourceObject,
|
||||
parentObject.transform);
|
||||
var cloneMotionDirector = cloneObject.transform
|
||||
.Find(motionObject.name)
|
||||
.GetComponent<PlayableDirector>();
|
||||
var cloneAuthoredCamera = cloneObject.transform
|
||||
.Find($"{motionObject.name}/{authoredCameraObject.name}")
|
||||
.GetComponent<CinemachineCamera>();
|
||||
|
||||
Assert.That(cloneObject.transform.parent, Is.SameAs(parentObject.transform));
|
||||
Assert.That(cloneObject.transform.position, Is.EqualTo(sourceWorldPosition));
|
||||
Assert.That(cloneObject.activeSelf, Is.False);
|
||||
Assert.That(cloneObject.activeInHierarchy, Is.False);
|
||||
Assert.That(PreviewCloneActivationProbe.EnableCount, Is.Zero);
|
||||
Assert.That(cloneMotionDirector.playOnAwake, Is.True);
|
||||
Assert.That(cloneMotionDirector.playableGraph.IsValid(), Is.False);
|
||||
Assert.That(cloneAuthoredCamera.enabled, Is.True);
|
||||
Assert.That(cloneAuthoredCamera.isActiveAndEnabled, Is.False);
|
||||
Assert.That(sourceObject.activeSelf, Is.True);
|
||||
Assert.That(sourceObject.activeInHierarchy, Is.True);
|
||||
Assert.That(motionDirector.state, Is.EqualTo(sourcePlaybackState));
|
||||
Assert.That(motionDirector.time, Is.EqualTo(0.4d).Within(0.000001d));
|
||||
Assert.That(authoredCamera.enabled, Is.True);
|
||||
Assert.That(authoredCamera.isActiveAndEnabled, Is.True);
|
||||
}
|
||||
finally
|
||||
{
|
||||
PreviewCloneActivationProbe.EnableCount = 0;
|
||||
if (motionDirector != null)
|
||||
{
|
||||
motionDirector.Stop();
|
||||
}
|
||||
|
||||
Object.DestroyImmediate(cloneObject);
|
||||
Object.DestroyImmediate(parentObject);
|
||||
Object.DestroyImmediate(motionTimeline);
|
||||
Object.DestroyImmediate(sourceTimeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PreviewCloneSuppressesOnlyAuthoredCinemachineOutputs()
|
||||
{
|
||||
var sourceObject = new GameObject("Source Director");
|
||||
var motionObject = new GameObject("Motion Director");
|
||||
var authoredVirtualCameraObject =
|
||||
new GameObject("Authored Virtual Camera");
|
||||
var cameraObject = new GameObject("Authored Camera");
|
||||
motionObject.transform.SetParent(sourceObject.transform, false);
|
||||
authoredVirtualCameraObject.transform.SetParent(
|
||||
motionObject.transform,
|
||||
false);
|
||||
var sourceTimeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
TimelineAsset motionTimeline = null;
|
||||
GameObject previewObject = null;
|
||||
try
|
||||
{
|
||||
var sourceDirector =
|
||||
sourceObject.AddComponent<PlayableDirector>();
|
||||
sourceDirector.playOnAwake = false;
|
||||
sourceDirector.playableAsset = sourceTimeline;
|
||||
var motionDirector =
|
||||
motionObject.AddComponent<PlayableDirector>();
|
||||
motionDirector.playOnAwake = false;
|
||||
var motionAnimator = motionObject.AddComponent<Animator>();
|
||||
var authoredVirtualCamera = authoredVirtualCameraObject
|
||||
.AddComponent<CinemachineCamera>();
|
||||
cameraObject.AddComponent<Camera>();
|
||||
var authoredBrain =
|
||||
cameraObject.AddComponent<CinemachineBrain>();
|
||||
motionTimeline = CreateTimelineBoundToBrain(
|
||||
motionDirector,
|
||||
authoredBrain,
|
||||
"Authored Camera Track");
|
||||
var motionTrack = motionTimeline.CreateTrack<AnimationTrack>(
|
||||
null,
|
||||
"Motion Track");
|
||||
motionDirector.SetGenericBinding(motionTrack, motionAnimator);
|
||||
|
||||
previewObject = Object.Instantiate(sourceObject);
|
||||
var previewMotionObject =
|
||||
previewObject.transform.Find(motionObject.name).gameObject;
|
||||
var previewMotionDirector =
|
||||
previewMotionObject.GetComponent<PlayableDirector>();
|
||||
var previewMotionAnimator =
|
||||
previewMotionObject.GetComponent<Animator>();
|
||||
var previewAuthoredVirtualCamera = previewMotionObject.transform
|
||||
.Find(authoredVirtualCameraObject.name)
|
||||
.GetComponent<CinemachineCamera>();
|
||||
var authoredCameraTrack = motionTimeline.GetOutputTracks()
|
||||
.OfType<CinemachineTrack>()
|
||||
.Single();
|
||||
var motionTimelineWasDirty = EditorUtility.IsDirty(motionTimeline);
|
||||
var suppressionState = AICameraTimelinePreviewImporter
|
||||
.CaptureAuthoredCinemachineState(
|
||||
previewObject.GetComponent<PlayableDirector>());
|
||||
|
||||
Assert.That(previewObject.activeSelf, Is.True);
|
||||
Assert.That(
|
||||
previewMotionDirector.GetGenericBinding(authoredCameraTrack),
|
||||
Is.SameAs(authoredBrain));
|
||||
Assert.That(
|
||||
previewMotionDirector.GetGenericBinding(motionTrack),
|
||||
Is.SameAs(previewMotionAnimator));
|
||||
Assert.That(previewAuthoredVirtualCamera.enabled, Is.True);
|
||||
Assert.That(authoredVirtualCamera.enabled, Is.True);
|
||||
|
||||
AICameraTimelinePreviewImporter
|
||||
.SuppressAuthoredCinemachineOutputsForEditor(
|
||||
previewObject.GetComponent<PlayableDirector>());
|
||||
|
||||
Assert.That(
|
||||
previewMotionDirector.GetGenericBinding(authoredCameraTrack),
|
||||
Is.Null);
|
||||
Assert.That(
|
||||
previewMotionDirector.GetGenericBinding(motionTrack),
|
||||
Is.SameAs(previewMotionAnimator));
|
||||
Assert.That(previewAuthoredVirtualCamera.enabled, Is.False);
|
||||
Assert.That(authoredVirtualCamera.enabled, Is.True);
|
||||
Assert.That(
|
||||
previewMotionDirector.playableAsset,
|
||||
Is.SameAs(motionTimeline));
|
||||
Assert.That(
|
||||
motionTimeline.GetOutputTracks(),
|
||||
Does.Contain(authoredCameraTrack));
|
||||
Assert.That(
|
||||
motionTimeline.GetOutputTracks(),
|
||||
Does.Contain(motionTrack));
|
||||
Assert.That(
|
||||
motionDirector.GetGenericBinding(authoredCameraTrack),
|
||||
Is.SameAs(authoredBrain));
|
||||
Assert.That(
|
||||
motionDirector.GetGenericBinding(motionTrack),
|
||||
Is.SameAs(motionAnimator));
|
||||
Assert.That(
|
||||
motionDirector.playableAsset,
|
||||
Is.SameAs(motionTimeline));
|
||||
Assert.That(
|
||||
EditorUtility.IsDirty(motionTimeline),
|
||||
Is.EqualTo(motionTimelineWasDirty));
|
||||
|
||||
AICameraTimelinePreviewImporter.RestoreAuthoredCinemachineState(
|
||||
suppressionState);
|
||||
|
||||
Assert.That(
|
||||
previewMotionDirector.GetGenericBinding(authoredCameraTrack),
|
||||
Is.SameAs(authoredBrain));
|
||||
Assert.That(
|
||||
previewMotionDirector.GetGenericBinding(motionTrack),
|
||||
Is.SameAs(previewMotionAnimator));
|
||||
Assert.That(previewAuthoredVirtualCamera.enabled, Is.True);
|
||||
Assert.That(authoredVirtualCamera.enabled, Is.True);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(previewObject);
|
||||
Object.DestroyImmediate(sourceObject);
|
||||
Object.DestroyImmediate(cameraObject);
|
||||
Object.DestroyImmediate(motionTimeline);
|
||||
Object.DestroyImmediate(sourceTimeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PreviewCloneKeepsParentGeneratedCinemachineBinding()
|
||||
{
|
||||
var sourceObject = new GameObject("Source Director");
|
||||
var motionObject = new GameObject("Motion Director");
|
||||
var generatedCameraObject = new GameObject("Generated Camera");
|
||||
var authoredCameraObject = new GameObject("Authored Camera");
|
||||
motionObject.transform.SetParent(sourceObject.transform, false);
|
||||
TimelineAsset sourceTimeline = null;
|
||||
TimelineAsset motionTimeline = null;
|
||||
GameObject previewObject = null;
|
||||
try
|
||||
{
|
||||
var sourceDirector =
|
||||
sourceObject.AddComponent<PlayableDirector>();
|
||||
sourceDirector.playOnAwake = false;
|
||||
var motionDirector =
|
||||
motionObject.AddComponent<PlayableDirector>();
|
||||
motionDirector.playOnAwake = false;
|
||||
generatedCameraObject.AddComponent<Camera>();
|
||||
var generatedBrain =
|
||||
generatedCameraObject.AddComponent<CinemachineBrain>();
|
||||
authoredCameraObject.AddComponent<Camera>();
|
||||
var authoredBrain =
|
||||
authoredCameraObject.AddComponent<CinemachineBrain>();
|
||||
sourceTimeline = CreateTimelineBoundToBrain(
|
||||
sourceDirector,
|
||||
generatedBrain,
|
||||
AICameraTimelinePreviewImporter.GeneratedCinemachineTrackName);
|
||||
motionTimeline = CreateTimelineBoundToBrain(
|
||||
motionDirector,
|
||||
authoredBrain,
|
||||
"Authored Camera Track");
|
||||
var generatedTrack = sourceTimeline.GetOutputTracks()
|
||||
.OfType<CinemachineTrack>()
|
||||
.Single();
|
||||
var authoredTrack = motionTimeline.GetOutputTracks()
|
||||
.OfType<CinemachineTrack>()
|
||||
.Single();
|
||||
|
||||
previewObject = Object.Instantiate(sourceObject);
|
||||
var previewDirector =
|
||||
previewObject.GetComponent<PlayableDirector>();
|
||||
var previewMotionDirector = previewObject.transform
|
||||
.Find(motionObject.name)
|
||||
.GetComponent<PlayableDirector>();
|
||||
|
||||
AICameraTimelinePreviewImporter
|
||||
.SuppressAuthoredCinemachineOutputsForEditor(
|
||||
previewDirector);
|
||||
|
||||
Assert.That(
|
||||
previewDirector.GetGenericBinding(generatedTrack),
|
||||
Is.SameAs(generatedBrain));
|
||||
Assert.That(
|
||||
previewMotionDirector.GetGenericBinding(authoredTrack),
|
||||
Is.Null);
|
||||
Assert.That(
|
||||
sourceDirector.GetGenericBinding(generatedTrack),
|
||||
Is.SameAs(generatedBrain));
|
||||
Assert.That(
|
||||
motionDirector.GetGenericBinding(authoredTrack),
|
||||
Is.SameAs(authoredBrain));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(previewObject);
|
||||
Object.DestroyImmediate(sourceObject);
|
||||
Object.DestroyImmediate(generatedCameraObject);
|
||||
Object.DestroyImmediate(authoredCameraObject);
|
||||
Object.DestroyImmediate(motionTimeline);
|
||||
Object.DestroyImmediate(sourceTimeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FinalSuppressionDoesNotCreatePartialUndoEntry()
|
||||
{
|
||||
var destinationObject = new GameObject("Destination Director");
|
||||
var motionObject = new GameObject("Motion Director");
|
||||
var authoredVirtualCameraObject =
|
||||
new GameObject("Authored Virtual Camera");
|
||||
var outputCameraObject = new GameObject("Output Camera");
|
||||
var undoSentinelObject = new GameObject("Undo Sentinel");
|
||||
motionObject.transform.SetParent(destinationObject.transform, false);
|
||||
authoredVirtualCameraObject.transform.SetParent(
|
||||
motionObject.transform,
|
||||
false);
|
||||
var destinationTimeline =
|
||||
ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
TimelineAsset motionTimeline = null;
|
||||
try
|
||||
{
|
||||
var destinationDirector =
|
||||
destinationObject.AddComponent<PlayableDirector>();
|
||||
destinationDirector.playableAsset = destinationTimeline;
|
||||
var motionDirector =
|
||||
motionObject.AddComponent<PlayableDirector>();
|
||||
var authoredVirtualCamera = authoredVirtualCameraObject
|
||||
.AddComponent<CinemachineCamera>();
|
||||
outputCameraObject.AddComponent<Camera>();
|
||||
var brain = outputCameraObject.AddComponent<CinemachineBrain>();
|
||||
motionTimeline = CreateTimelineBoundToBrain(
|
||||
motionDirector,
|
||||
brain,
|
||||
"Authored Camera Track");
|
||||
var cameraTrack = motionTimeline.GetOutputTracks()
|
||||
.OfType<CinemachineTrack>()
|
||||
.Single();
|
||||
|
||||
Undo.ClearAll();
|
||||
Undo.IncrementCurrentGroup();
|
||||
var sentinelGroup = Undo.GetCurrentGroup();
|
||||
Undo.RegisterCompleteObjectUndo(
|
||||
undoSentinelObject.transform,
|
||||
"Final Suppression Undo Sentinel");
|
||||
undoSentinelObject.transform.position = Vector3.one;
|
||||
Undo.CollapseUndoOperations(sentinelGroup);
|
||||
Undo.FlushUndoRecordObjects();
|
||||
Undo.IncrementCurrentGroup();
|
||||
|
||||
AICameraTimelinePreviewImporter
|
||||
.SuppressAuthoredCinemachineOutputsForEditor(
|
||||
destinationDirector,
|
||||
false);
|
||||
Undo.FlushUndoRecordObjects();
|
||||
|
||||
Assert.That(
|
||||
motionDirector.GetGenericBinding(cameraTrack),
|
||||
Is.Null);
|
||||
Assert.That(authoredVirtualCamera.enabled, Is.False);
|
||||
|
||||
Undo.PerformUndo();
|
||||
|
||||
Assert.That(undoSentinelObject.transform.position, Is.EqualTo(Vector3.zero));
|
||||
Assert.That(
|
||||
motionDirector.GetGenericBinding(cameraTrack),
|
||||
Is.Null);
|
||||
Assert.That(authoredVirtualCamera.enabled, Is.False);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Undo.ClearAll();
|
||||
Object.DestroyImmediate(destinationObject);
|
||||
Object.DestroyImmediate(outputCameraObject);
|
||||
Object.DestroyImmediate(undoSentinelObject);
|
||||
Object.DestroyImmediate(motionTimeline);
|
||||
Object.DestroyImmediate(destinationTimeline);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SuppressionRebuildsPlayingDirectorAndReleasesBrainOverride()
|
||||
{
|
||||
var sourceObject = new GameObject("Source Director");
|
||||
var motionObject = new GameObject("Motion Director");
|
||||
var authoredCameraObject = new GameObject("Authored Virtual Camera");
|
||||
var outputCameraObject = new GameObject("Output Camera");
|
||||
motionObject.transform.SetParent(sourceObject.transform, false);
|
||||
authoredCameraObject.transform.SetParent(
|
||||
motionObject.transform,
|
||||
false);
|
||||
var sourceTimeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
var motionTimeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
PlayableDirector motionDirector = null;
|
||||
try
|
||||
{
|
||||
var sourceDirector =
|
||||
sourceObject.AddComponent<PlayableDirector>();
|
||||
sourceDirector.playOnAwake = false;
|
||||
sourceDirector.playableAsset = sourceTimeline;
|
||||
motionDirector = motionObject.AddComponent<PlayableDirector>();
|
||||
motionDirector.playOnAwake = false;
|
||||
motionDirector.timeUpdateMode = DirectorUpdateMode.Manual;
|
||||
motionDirector.playableAsset = motionTimeline;
|
||||
var authoredCamera =
|
||||
authoredCameraObject.AddComponent<CinemachineCamera>();
|
||||
outputCameraObject.AddComponent<Camera>();
|
||||
var brain = outputCameraObject.AddComponent<CinemachineBrain>();
|
||||
brain.UpdateMethod = CinemachineBrain.UpdateMethods.ManualUpdate;
|
||||
|
||||
var track = motionTimeline.CreateTrack<CinemachineTrack>(
|
||||
null,
|
||||
"Authored Camera Track");
|
||||
var clip = track.CreateDefaultClip();
|
||||
clip.start = 0d;
|
||||
clip.duration = 1d;
|
||||
var shot = clip.asset as CinemachineShot;
|
||||
Assert.That(shot, Is.Not.Null);
|
||||
var exposedName = new PropertyName("AuthoredCameraForSuppressionTest");
|
||||
shot.VirtualCamera.exposedName = exposedName;
|
||||
shot.VirtualCamera.defaultValue = authoredCamera;
|
||||
motionDirector.SetReferenceValue(exposedName, authoredCamera);
|
||||
motionDirector.SetGenericBinding(track, brain);
|
||||
|
||||
motionDirector.Play();
|
||||
motionDirector.time = 0.25d;
|
||||
motionDirector.Evaluate();
|
||||
brain.ManualUpdate(100, 1f / 60f);
|
||||
|
||||
Assert.That(motionDirector.playableGraph.IsValid(), Is.True);
|
||||
Assert.That(motionDirector.state, Is.EqualTo(PlayState.Playing));
|
||||
Assert.That(brain.ActiveVirtualCamera, Is.SameAs(authoredCamera));
|
||||
var suppressionState = AICameraTimelinePreviewImporter
|
||||
.CaptureAuthoredCinemachineState(sourceDirector);
|
||||
|
||||
AICameraTimelinePreviewImporter
|
||||
.SuppressAuthoredCinemachineOutputsForEditor(sourceDirector);
|
||||
brain.ManualUpdate(101, 1f / 60f);
|
||||
|
||||
Assert.That(motionDirector.state, Is.EqualTo(PlayState.Playing));
|
||||
Assert.That(motionDirector.time, Is.EqualTo(0.25d).Within(0.000001d));
|
||||
Assert.That(motionDirector.GetGenericBinding(track), Is.Null);
|
||||
Assert.That(authoredCamera.enabled, Is.False);
|
||||
Assert.That(brain.ActiveVirtualCamera, Is.Not.SameAs(authoredCamera));
|
||||
|
||||
AICameraTimelinePreviewImporter.RestoreAuthoredCinemachineState(
|
||||
suppressionState);
|
||||
brain.ManualUpdate(102, 1f / 60f);
|
||||
|
||||
Assert.That(motionDirector.state, Is.EqualTo(PlayState.Playing));
|
||||
Assert.That(motionDirector.time, Is.EqualTo(0.25d).Within(0.000001d));
|
||||
Assert.That(
|
||||
motionDirector.GetGenericBinding(track),
|
||||
Is.SameAs(brain));
|
||||
Assert.That(authoredCamera.enabled, Is.True);
|
||||
Assert.That(brain.ActiveVirtualCamera, Is.SameAs(authoredCamera));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (motionDirector != null)
|
||||
{
|
||||
motionDirector.Stop();
|
||||
}
|
||||
|
||||
Object.DestroyImmediate(sourceObject);
|
||||
Object.DestroyImmediate(outputCameraObject);
|
||||
Object.DestroyImmediate(motionTimeline);
|
||||
Object.DestroyImmediate(sourceTimeline);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void GeneratedDirectorySupportsLegacyAndDeclaredHashes(
|
||||
@ -778,6 +1632,18 @@ namespace Streamingle.Editor.Tests
|
||||
}
|
||||
}
|
||||
|
||||
private static TimelineAsset CreateTimelineBoundToBrain(
|
||||
PlayableDirector director,
|
||||
CinemachineBrain brain,
|
||||
string trackName)
|
||||
{
|
||||
var timeline = ScriptableObject.CreateInstance<TimelineAsset>();
|
||||
var track = timeline.CreateTrack<CinemachineTrack>(null, trackName);
|
||||
director.playableAsset = timeline;
|
||||
director.SetGenericBinding(track, brain);
|
||||
return timeline;
|
||||
}
|
||||
|
||||
private static string CreateGeneratedDirectory(bool includeHashes)
|
||||
{
|
||||
var directory = Path.Combine(
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.mingle.cw-ai",
|
||||
"version": "0.4.13",
|
||||
"version": "0.4.14",
|
||||
"displayName": "Mingle Camera Work AI",
|
||||
"description": "Self-contained high-quality Unity Timeline camera generation with an embedded prepared reference library, per-shot editable clips, and A/B review tools.",
|
||||
"unity": "6000.0",
|
||||
|
||||
8
Editor/Constraints/Icons.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5f43322334040eda82a02238038c637
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Editor/Constraints/Icons/LerpAimConstraintIcon.png
Normal file
|
After Width: | Height: | Size: 210 KiB |
89
Editor/Constraints/Icons/LerpAimConstraintIcon.png.meta
Normal file
@ -0,0 +1,89 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07da6f60b8c84789bc7ee4602f68d356
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Editor/Constraints/Icons/LerpConstraintIcon.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
89
Editor/Constraints/Icons/LerpConstraintIcon.png.meta
Normal file
@ -0,0 +1,89 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f25ac2c42604ab79638fbe063e38a1e
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Editor/Constraints/Icons/LerpLookAtConstraintIcon.png
Normal file
|
After Width: | Height: | Size: 317 KiB |
89
Editor/Constraints/Icons/LerpLookAtConstraintIcon.png.meta
Normal file
@ -0,0 +1,89 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c84e46fbbf5438d8099a052a0afc864
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Editor/Constraints/Icons/LerpParentConstraintIcon.png
Normal file
|
After Width: | Height: | Size: 209 KiB |
89
Editor/Constraints/Icons/LerpParentConstraintIcon.png.meta
Normal file
@ -0,0 +1,89 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07856e0ad4ad45cea23acd5143fd834a
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Editor/Constraints/Icons/LerpPositionConstraintIcon.png
Normal file
|
After Width: | Height: | Size: 129 KiB |
89
Editor/Constraints/Icons/LerpPositionConstraintIcon.png.meta
Normal file
@ -0,0 +1,89 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f06836401f24edab7eb10cfa8cc366c
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Editor/Constraints/Icons/LerpRotationConstraintIcon.png
Normal file
|
After Width: | Height: | Size: 190 KiB |
89
Editor/Constraints/Icons/LerpRotationConstraintIcon.png.meta
Normal file
@ -0,0 +1,89 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb343fa7887e4c33841ba7c34114ba1b
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Editor/Constraints/Icons/LerpScaleConstraintIcon.png
Normal file
|
After Width: | Height: | Size: 324 KiB |
89
Editor/Constraints/Icons/LerpScaleConstraintIcon.png.meta
Normal file
@ -0,0 +1,89 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e8f1bdf638d4772bde06d7d0eeb8af3
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,13 +1,13 @@
|
||||
using Streamingle.Utils.RoughConstraints;
|
||||
using Streamingle.Utils.LerpConstraints;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
namespace Streamingle.Utils.LerpConstraintsEditor
|
||||
{
|
||||
[CustomEditor(typeof(RoughConstraintBase), true)]
|
||||
[CustomEditor(typeof(LerpConstraintBase), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public sealed class RoughConstraintEditor : UnityEditor.Editor
|
||||
public sealed class LerpConstraintEditor : UnityEditor.Editor
|
||||
{
|
||||
private SerializedProperty constraintActive;
|
||||
private SerializedProperty locked;
|
||||
@ -18,7 +18,7 @@ namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
private SerializedProperty useUnscaledTime;
|
||||
private SerializedProperty snapOnEnable;
|
||||
private ReorderableList sourceList;
|
||||
private bool roughFollowFoldout = true;
|
||||
private bool lerpFollowFoldout = true;
|
||||
private bool settingsFoldout = true;
|
||||
|
||||
private void OnEnable()
|
||||
@ -62,7 +62,7 @@ namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("Activate", EditorStyles.miniButton, GUILayout.Width(72f)))
|
||||
{
|
||||
ApplyAction("Activate Rough Constraint", ActivateConstraint);
|
||||
ApplyAction("Activate Lerp Constraint", ActivateConstraint);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Zero", EditorStyles.miniButton, GUILayout.Width(56f)))
|
||||
@ -84,8 +84,8 @@ namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
foreach (var selectedTarget in targets)
|
||||
{
|
||||
var constraint = (RoughConstraintBase)selectedTarget;
|
||||
Undo.RecordObject(constraint, "Change Rough Constraint Lock");
|
||||
var constraint = (LerpConstraintBase)selectedTarget;
|
||||
Undo.RecordObject(constraint, "Change Lerp Constraint Lock");
|
||||
constraint.SetLocked(newValue);
|
||||
EditorUtility.SetDirty(constraint);
|
||||
}
|
||||
@ -102,8 +102,8 @@ namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
|
||||
private void DrawTypeSettings()
|
||||
{
|
||||
roughFollowFoldout = EditorGUILayout.Foldout(roughFollowFoldout, "Rough Follow", true);
|
||||
if (roughFollowFoldout)
|
||||
lerpFollowFoldout = EditorGUILayout.Foldout(lerpFollowFoldout, "Lerp Follow", true);
|
||||
if (lerpFollowFoldout)
|
||||
{
|
||||
using (new EditorGUI.IndentLevelScope())
|
||||
{
|
||||
@ -128,27 +128,27 @@ namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
|
||||
private void DrawTypeProperties()
|
||||
{
|
||||
if (target is RoughPositionConstraint)
|
||||
if (target is LerpPositionConstraint)
|
||||
{
|
||||
DrawProperties("constrainedAxis", "positionOffset", "offsetInSourceSpace");
|
||||
}
|
||||
else if (target is RoughRotationConstraint)
|
||||
else if (target is LerpRotationConstraint)
|
||||
{
|
||||
DrawProperties("constrainedAxis", "rotationOffset");
|
||||
}
|
||||
else if (target is RoughScaleConstraint)
|
||||
else if (target is LerpScaleConstraint)
|
||||
{
|
||||
DrawProperties("constrainedAxis", "scaleOffset");
|
||||
}
|
||||
else if (target is RoughParentConstraint)
|
||||
else if (target is LerpParentConstraint)
|
||||
{
|
||||
DrawProperties("constrainedPositionAxis", "positionOffset", "positionOffsetInSourceSpace", "constrainedRotationAxis", "rotationOffset");
|
||||
}
|
||||
else if (target is RoughAimConstraint)
|
||||
else if (target is LerpAimConstraint)
|
||||
{
|
||||
DrawProperties("aimAxis", "upAxis", "worldUpVector", "rotationOffset");
|
||||
}
|
||||
else if (target is RoughLookAtConstraint)
|
||||
else if (target is LerpLookAtConstraint)
|
||||
{
|
||||
DrawProperties("forwardAxis", "worldUpVector", "targetPositionOffset", "rotationOffset");
|
||||
}
|
||||
@ -166,22 +166,22 @@ namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyAction(string undoName, System.Action<RoughConstraintBase> action)
|
||||
private void ApplyAction(string undoName, System.Action<LerpConstraintBase> action)
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
foreach (var selectedTarget in targets)
|
||||
{
|
||||
var constraint = (RoughConstraintBase)selectedTarget;
|
||||
var constraint = (LerpConstraintBase)selectedTarget;
|
||||
Undo.RecordObject(constraint.transform, undoName);
|
||||
action(constraint);
|
||||
EditorUtility.SetDirty(constraint.transform);
|
||||
}
|
||||
}
|
||||
|
||||
private void ActivateConstraint(RoughConstraintBase constraint)
|
||||
private void ActivateConstraint(LerpConstraintBase constraint)
|
||||
{
|
||||
Undo.RecordObject(constraint, "Activate Rough Constraint");
|
||||
Undo.RecordObject(constraint, "Activate Lerp Constraint");
|
||||
constraint.ActivateConstraint();
|
||||
EditorUtility.SetDirty(constraint);
|
||||
}
|
||||
@ -189,7 +189,7 @@ namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
private void ZeroOffsets()
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
Undo.RecordObjects(targets, "Zero Rough Constraint Offsets");
|
||||
Undo.RecordObjects(targets, "Zero Lerp Constraint Offsets");
|
||||
|
||||
SetVector3IfExists("positionOffset", Vector3.zero);
|
||||
SetVector3IfExists("rotationOffset", Vector3.zero);
|
||||
@ -261,13 +261,13 @@ namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
|
||||
private string GetSettingsTitle()
|
||||
{
|
||||
if (target is RoughLookAtConstraint)
|
||||
if (target is LerpLookAtConstraint)
|
||||
{
|
||||
return "Look At";
|
||||
}
|
||||
|
||||
var name = target.GetType().Name;
|
||||
name = name.Replace("Rough", string.Empty).Replace("Constraint", string.Empty);
|
||||
name = name.Replace("Lerp", string.Empty).Replace("Constraint", string.Empty);
|
||||
return ObjectNames.NicifyVariableName(name);
|
||||
}
|
||||
}
|
||||
69
Editor/Constraints/LerpConstraintIconInstaller.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Streamingle.Utils.LerpConstraints;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Streamingle.Utils.LerpConstraintsEditor
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
internal static class LerpConstraintIconInstaller
|
||||
{
|
||||
private const string IconDirectory = "Packages/com.streamingle.utilities/Editor/Constraints/Icons";
|
||||
|
||||
private static readonly IconDefinition[] IconDefinitions =
|
||||
{
|
||||
new IconDefinition(typeof(LerpAimConstraint), "LerpAimConstraintIcon"),
|
||||
new IconDefinition(typeof(LerpLookAtConstraint), "LerpLookAtConstraintIcon"),
|
||||
new IconDefinition(typeof(LerpParentConstraint), "LerpParentConstraintIcon"),
|
||||
new IconDefinition(typeof(LerpPositionConstraint), "LerpPositionConstraintIcon"),
|
||||
new IconDefinition(typeof(LerpRotationConstraint), "LerpRotationConstraintIcon"),
|
||||
new IconDefinition(typeof(LerpScaleConstraint), "LerpScaleConstraintIcon")
|
||||
};
|
||||
|
||||
static LerpConstraintIconInstaller()
|
||||
{
|
||||
EditorApplication.delayCall += ApplyIcons;
|
||||
}
|
||||
|
||||
private static void ApplyIcons()
|
||||
{
|
||||
string[] scriptGuids = AssetDatabase.FindAssets(
|
||||
"t:MonoScript",
|
||||
new[] { "Packages/com.streamingle.utilities/Runtime/Constraints" });
|
||||
|
||||
foreach (IconDefinition definition in IconDefinitions)
|
||||
{
|
||||
Texture2D icon = AssetDatabase.LoadAssetAtPath<Texture2D>(
|
||||
$"{IconDirectory}/{definition.IconName}.png");
|
||||
if (icon == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
MonoScript script = scriptGuids
|
||||
.Select(AssetDatabase.GUIDToAssetPath)
|
||||
.Select(AssetDatabase.LoadAssetAtPath<MonoScript>)
|
||||
.FirstOrDefault(candidate => candidate != null && candidate.GetClass() == definition.ConstraintType);
|
||||
|
||||
if (script != null)
|
||||
{
|
||||
EditorGUIUtility.SetIconForObject(script, icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly struct IconDefinition
|
||||
{
|
||||
public IconDefinition(Type constraintType, string iconName)
|
||||
{
|
||||
ConstraintType = constraintType;
|
||||
IconName = iconName;
|
||||
}
|
||||
|
||||
public Type ConstraintType { get; }
|
||||
|
||||
public string IconName { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/Constraints/LerpConstraintIconInstaller.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97633b0c6f0f4ca0a862c50e6de6f70b
|
||||
@ -1,8 +1,8 @@
|
||||
using Streamingle.Utils.RoughConstraints;
|
||||
using Streamingle.Utils.LerpConstraints;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraintsEditor
|
||||
namespace Streamingle.Utils.LerpConstraintsEditor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Vector3Bool))]
|
||||
public sealed class Vector3BoolDrawer : UnityEditor.PropertyDrawer
|
||||
|
||||
@ -37,7 +37,7 @@ Install **Git and Git LFS before opening Unity**, then use **Add package from
|
||||
git URL** with:
|
||||
|
||||
```text
|
||||
https://kindnick-git.duckdns.org/mingle/streamingle-unity-utilities.git?path=/CameraAI~#v0.1.19
|
||||
https://kindnick-git.duckdns.org/mingle/streamingle-unity-utilities.git?path=/CameraAI~#v0.1.20
|
||||
```
|
||||
|
||||
The Camera AI package includes the complete Windows x64
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraints
|
||||
namespace Streamingle.Utils.LerpConstraints
|
||||
{
|
||||
[MovedFrom(true, "Streamingle.Utils.RoughConstraints", "Assembly-CSharp", "RoughAimConstraint")]
|
||||
[ExecuteAlways]
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Rough Aim Constraint")]
|
||||
public class RoughAimConstraint : RoughConstraintBase
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Lerp Aim Constraint")]
|
||||
public class LerpAimConstraint : LerpConstraintBase
|
||||
{
|
||||
[Header("Aim")]
|
||||
public Vector3 aimAxis = Vector3.forward;
|
||||
@ -1,12 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraints
|
||||
namespace Streamingle.Utils.LerpConstraints
|
||||
{
|
||||
public enum RoughConstraintUpdateMode
|
||||
public enum LerpConstraintUpdateMode
|
||||
{
|
||||
Update,
|
||||
LateUpdate,
|
||||
@ -14,8 +15,9 @@ namespace Streamingle.Utils.RoughConstraints
|
||||
Manual
|
||||
}
|
||||
|
||||
[MovedFrom(true, "Streamingle.Utils.RoughConstraints", "Assembly-CSharp", "RoughConstraintBase")]
|
||||
[ExecuteAlways]
|
||||
public abstract class RoughConstraintBase : MonoBehaviour
|
||||
public abstract class LerpConstraintBase : MonoBehaviour
|
||||
{
|
||||
[Header("Constraint")]
|
||||
public bool constraintActive = true;
|
||||
@ -24,13 +26,13 @@ namespace Streamingle.Utils.RoughConstraints
|
||||
[Range(0f, 1f)]
|
||||
public float weight = 1f;
|
||||
|
||||
public List<RoughConstraintSource> sources = new List<RoughConstraintSource>();
|
||||
public List<LerpConstraintSource> sources = new List<LerpConstraintSource>();
|
||||
|
||||
[Header("Rough Follow")]
|
||||
[Header("Lerp Follow")]
|
||||
[Min(0f)]
|
||||
public float damping = 12f;
|
||||
|
||||
public RoughConstraintUpdateMode updateMode = RoughConstraintUpdateMode.LateUpdate;
|
||||
public LerpConstraintUpdateMode updateMode = LerpConstraintUpdateMode.LateUpdate;
|
||||
public bool useUnscaledTime;
|
||||
public bool snapOnEnable = true;
|
||||
|
||||
@ -47,7 +49,7 @@ namespace Streamingle.Utils.RoughConstraints
|
||||
return 1f / 60f;
|
||||
}
|
||||
|
||||
if (updateMode == RoughConstraintUpdateMode.FixedUpdate)
|
||||
if (updateMode == LerpConstraintUpdateMode.FixedUpdate)
|
||||
{
|
||||
return useUnscaledTime ? Time.fixedUnscaledDeltaTime : Time.fixedDeltaTime;
|
||||
}
|
||||
@ -94,7 +96,7 @@ namespace Streamingle.Utils.RoughConstraints
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
if (updateMode != RoughConstraintUpdateMode.Manual)
|
||||
if (updateMode != LerpConstraintUpdateMode.Manual)
|
||||
{
|
||||
Evaluate();
|
||||
}
|
||||
@ -102,7 +104,7 @@ namespace Streamingle.Utils.RoughConstraints
|
||||
return;
|
||||
}
|
||||
|
||||
if (updateMode == RoughConstraintUpdateMode.Update)
|
||||
if (updateMode == LerpConstraintUpdateMode.Update)
|
||||
{
|
||||
Evaluate();
|
||||
}
|
||||
@ -115,7 +117,7 @@ namespace Streamingle.Utils.RoughConstraints
|
||||
return;
|
||||
}
|
||||
|
||||
if (updateMode == RoughConstraintUpdateMode.LateUpdate)
|
||||
if (updateMode == LerpConstraintUpdateMode.LateUpdate)
|
||||
{
|
||||
Evaluate();
|
||||
}
|
||||
@ -128,7 +130,7 @@ namespace Streamingle.Utils.RoughConstraints
|
||||
return;
|
||||
}
|
||||
|
||||
if (updateMode == RoughConstraintUpdateMode.FixedUpdate)
|
||||
if (updateMode == LerpConstraintUpdateMode.FixedUpdate)
|
||||
{
|
||||
Evaluate();
|
||||
}
|
||||
@ -165,7 +167,7 @@ namespace Streamingle.Utils.RoughConstraints
|
||||
return;
|
||||
}
|
||||
|
||||
if (Application.isPlaying || updateMode == RoughConstraintUpdateMode.Manual)
|
||||
if (Application.isPlaying || updateMode == LerpConstraintUpdateMode.Manual)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraints
|
||||
namespace Streamingle.Utils.LerpConstraints
|
||||
{
|
||||
[Serializable]
|
||||
public struct RoughConstraintSource
|
||||
public struct LerpConstraintSource
|
||||
{
|
||||
public Transform sourceTransform;
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraints
|
||||
namespace Streamingle.Utils.LerpConstraints
|
||||
{
|
||||
[MovedFrom(true, "Streamingle.Utils.RoughConstraints", "Assembly-CSharp", "RoughLookAtConstraint")]
|
||||
[ExecuteAlways]
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Rough Look At Constraint")]
|
||||
public class RoughLookAtConstraint : RoughConstraintBase
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Lerp Look At Constraint")]
|
||||
public class LerpLookAtConstraint : LerpConstraintBase
|
||||
{
|
||||
[Header("Look At")]
|
||||
public Vector3 forwardAxis = Vector3.forward;
|
||||
@ -1,10 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraints
|
||||
namespace Streamingle.Utils.LerpConstraints
|
||||
{
|
||||
[MovedFrom(true, "Streamingle.Utils.RoughConstraints", "Assembly-CSharp", "RoughParentConstraint")]
|
||||
[ExecuteAlways]
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Rough Parent Constraint")]
|
||||
public class RoughParentConstraint : RoughConstraintBase
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Lerp Parent Constraint")]
|
||||
public class LerpParentConstraint : LerpConstraintBase
|
||||
{
|
||||
[Header("Position")]
|
||||
public Vector3Bool constrainedPositionAxis = Vector3Bool.All;
|
||||
@ -1,10 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraints
|
||||
namespace Streamingle.Utils.LerpConstraints
|
||||
{
|
||||
[MovedFrom(true, "Streamingle.Utils.RoughConstraints", "Assembly-CSharp", "RoughPositionConstraint")]
|
||||
[ExecuteAlways]
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Rough Position Constraint")]
|
||||
public class RoughPositionConstraint : RoughConstraintBase
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Lerp Position Constraint")]
|
||||
public class LerpPositionConstraint : LerpConstraintBase
|
||||
{
|
||||
[Header("Position")]
|
||||
public Vector3Bool constrainedAxis = Vector3Bool.All;
|
||||
@ -1,10 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraints
|
||||
namespace Streamingle.Utils.LerpConstraints
|
||||
{
|
||||
[MovedFrom(true, "Streamingle.Utils.RoughConstraints", "Assembly-CSharp", "RoughRotationConstraint")]
|
||||
[ExecuteAlways]
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Rough Rotation Constraint")]
|
||||
public class RoughRotationConstraint : RoughConstraintBase
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Lerp Rotation Constraint")]
|
||||
public class LerpRotationConstraint : LerpConstraintBase
|
||||
{
|
||||
[Header("Rotation")]
|
||||
public Vector3Bool constrainedAxis = Vector3Bool.All;
|
||||
@ -1,10 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraints
|
||||
namespace Streamingle.Utils.LerpConstraints
|
||||
{
|
||||
[MovedFrom(true, "Streamingle.Utils.RoughConstraints", "Assembly-CSharp", "RoughScaleConstraint")]
|
||||
[ExecuteAlways]
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Rough Scale Constraint")]
|
||||
public class RoughScaleConstraint : RoughConstraintBase
|
||||
[AddComponentMenu("Streamingle Utilities/Constraints/Lerp Scale Constraint")]
|
||||
public class LerpScaleConstraint : LerpConstraintBase
|
||||
{
|
||||
[Header("Scale")]
|
||||
public Vector3Bool constrainedAxis = Vector3Bool.All;
|
||||
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Streamingle.Utils.RoughConstraints
|
||||
namespace Streamingle.Utils.LerpConstraints
|
||||
{
|
||||
[Serializable]
|
||||
public struct Vector3Bool
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.streamingle.utilities",
|
||||
"displayName": "Streamingle Utilities",
|
||||
"version": "0.1.7",
|
||||
"version": "0.1.22",
|
||||
"unity": "6000.0",
|
||||
"description": "Reusable Streamingle runtime components and Unity editor utilities.",
|
||||
"keywords": [
|
||||
|
||||