bux fix, add PreviewCamera button
This commit is contained in:
@@ -41,7 +41,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
public AnimatorOverrideController OverrideController;
|
||||
public AnimatorOverrideController FaceOverrideController;
|
||||
public AnimatorOverrideController CameraOverrideController;
|
||||
public Animator CurrentCameraAnimator;
|
||||
public Animator PreviewCameraAnimator;
|
||||
public Camera PreviewCamera;
|
||||
|
||||
private void Awake()
|
||||
@@ -956,6 +956,8 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
|
||||
CurrentUMAContainer.UmaAnimator.Play("motion_1", -1);
|
||||
CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next");
|
||||
|
||||
CurrentUMAContainer.isAnimatorControl = false;
|
||||
}
|
||||
else if (clip.name.Contains("face"))
|
||||
{
|
||||
@@ -972,10 +974,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
var overrideController = Instantiate(CameraOverrideController);
|
||||
overrideController["clip_1"] = clip;
|
||||
CurrentCameraAnimator = Camera.main.gameObject.GetComponent<Animator>();
|
||||
CurrentCameraAnimator.runtimeAnimatorController = overrideController;
|
||||
PreviewCamera.enabled = true;
|
||||
CurrentCameraAnimator.Play("motion_1", 0, 0);
|
||||
SetPreviewCamera(overrideController);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -992,23 +991,27 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
RecursiveLoadAsset(facialMotion);
|
||||
}
|
||||
|
||||
if (cameraMotion != null)
|
||||
{
|
||||
RecursiveLoadAsset(cameraMotion);
|
||||
}
|
||||
|
||||
if (CurrentUMAContainer.IsMini)
|
||||
{
|
||||
SetPreviewCamera(null);
|
||||
}
|
||||
CurrentUMAContainer.UmaAnimator.Play("motion_2", 0, 0);
|
||||
CurrentUMAContainer.OverrideController["clip_2"].wrapMode = WrapMode.Loop;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentUMAContainer.isAnimatorControl = false;
|
||||
if (CurrentUMAContainer.FaceDrivenKeyTarget)
|
||||
if (CurrentUMAContainer.FaceDrivenKeyTarget)
|
||||
{
|
||||
CurrentUMAContainer.FaceDrivenKeyTarget.ResetLocator();
|
||||
PreviewCamera.enabled = false;
|
||||
|
||||
if (CurrentCameraAnimator)
|
||||
CurrentCameraAnimator.GetComponent<Animator>().runtimeAnimatorController = null;
|
||||
}
|
||||
CurrentUMAContainer.isAnimatorControl = false;
|
||||
SetPreviewCamera(null);
|
||||
|
||||
CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime);
|
||||
CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next");
|
||||
@@ -1017,6 +1020,20 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
|
||||
}
|
||||
public void SetPreviewCamera(RuntimeAnimatorController controller)
|
||||
{
|
||||
if (controller)
|
||||
{
|
||||
PreviewCameraAnimator.runtimeAnimatorController = controller;
|
||||
PreviewCamera.enabled = true;
|
||||
PreviewCameraAnimator.Play("motion_1", 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
PreviewCameraAnimator.runtimeAnimatorController = null;
|
||||
PreviewCamera.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UnloadBundle(AssetBundle bundle, bool unloadAllObjects)
|
||||
{
|
||||
|
||||
@@ -663,7 +663,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
{
|
||||
var animator = Builder.CurrentUMAContainer.UmaAnimator;
|
||||
var animator_face = Builder.CurrentUMAContainer.UmaFaceAnimator;
|
||||
var animator_cam = Builder.CurrentCameraAnimator;
|
||||
var animator_cam = Builder.PreviewCameraAnimator;
|
||||
var AnimeState = animator.GetCurrentAnimatorStateInfo(0);
|
||||
var state = animator.speed > 0f;
|
||||
if (state)
|
||||
@@ -701,7 +701,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
if (!Builder.CurrentUMAContainer || !Builder.CurrentUMAContainer.UmaAnimator) return;
|
||||
var animator = Builder.CurrentUMAContainer.UmaAnimator;
|
||||
var animator_face = Builder.CurrentUMAContainer.UmaFaceAnimator;
|
||||
var animator_cam = Builder.CurrentCameraAnimator;
|
||||
var animator_cam = Builder.PreviewCameraAnimator;
|
||||
if (animator != null)
|
||||
{
|
||||
var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"];
|
||||
@@ -726,7 +726,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
AnimationSpeedText.text = string.Format("Animation Speed: {0:F2}", val);
|
||||
if (!Builder.CurrentUMAContainer || !Builder.CurrentUMAContainer.UmaAnimator) return;
|
||||
Builder.CurrentUMAContainer.UmaAnimator.speed = val;
|
||||
Builder.CurrentCameraAnimator.speed = val;
|
||||
Builder.PreviewCameraAnimator.speed = val;
|
||||
if (Builder.CurrentUMAContainer.UmaFaceAnimator)
|
||||
{
|
||||
Builder.CurrentUMAContainer.UmaFaceAnimator.speed = val;
|
||||
|
||||
Reference in New Issue
Block a user