Merge pull request #4 from gamer-jp/master
Add animation sliders and Anti-Aliasing by Unity's postprocessing package
This commit is contained in:
@@ -4,16 +4,20 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
|
||||
public class CameraOrbit : MonoBehaviour
|
||||
{
|
||||
public int CameraMode = 0;
|
||||
public int AAMode = 0;
|
||||
|
||||
[Header("Light")]
|
||||
public GameObject Light;
|
||||
|
||||
public Dropdown CameraModeDropdown;
|
||||
|
||||
public Dropdown AAModeDropdown;
|
||||
|
||||
public GameObject CameraTargetHelper;
|
||||
public Vector3 TargetCenter;
|
||||
|
||||
@@ -75,6 +79,30 @@ public class CameraOrbit : MonoBehaviour
|
||||
}
|
||||
CameraMode = CameraModeDropdown.value;
|
||||
}
|
||||
|
||||
if (AAMode != AAModeDropdown.value)
|
||||
{
|
||||
var postprocessLayer = Camera.main.GetComponent<PostProcessLayer>();
|
||||
switch (AAModeDropdown.value) //new
|
||||
{
|
||||
case 0:
|
||||
postprocessLayer.antialiasingMode = PostProcessLayer.Antialiasing.None;
|
||||
break;
|
||||
case 1:
|
||||
postprocessLayer.antialiasingMode = PostProcessLayer.Antialiasing.FastApproximateAntialiasing;
|
||||
break;
|
||||
case 2:
|
||||
postprocessLayer.antialiasingMode = PostProcessLayer.Antialiasing.SubpixelMorphologicalAntialiasing;
|
||||
break;
|
||||
case 3:
|
||||
postprocessLayer.antialiasingMode = PostProcessLayer.Antialiasing.TemporalAntialiasing;
|
||||
break;
|
||||
default:
|
||||
postprocessLayer.antialiasingMode = PostProcessLayer.Antialiasing.None;
|
||||
break;
|
||||
}
|
||||
AAMode = AAModeDropdown.value;
|
||||
}
|
||||
#if UNITY_ANDROID
|
||||
switch (CameraModeDropdown.value)
|
||||
{
|
||||
|
||||
@@ -906,8 +906,18 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
CurrentUMAContainer.OverrideController["clip_1"] = CurrentUMAContainer.OverrideController["clip_2"];
|
||||
var lastTime = CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime;
|
||||
CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime);
|
||||
CurrentUMAContainer.OverrideController["clip_2"] = clip;
|
||||
|
||||
// If Cut-in, play immediately without state interpolation
|
||||
if (clip.name.Contains("crd"))
|
||||
{
|
||||
CurrentUMAContainer.UmaAnimator.Play("motion_2", 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime);
|
||||
}
|
||||
|
||||
CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next");
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,14 @@ public class UmaViewerUI : MonoBehaviour
|
||||
public TextMeshProUGUI ProgressText;
|
||||
public Text LyricsText;
|
||||
|
||||
//animations
|
||||
public Slider AnimationSlider;
|
||||
public Slider AnimationSpeedSlider;
|
||||
public Button AnimationPlayButton;
|
||||
public TextMeshProUGUI AnimationTitleText;
|
||||
public TextMeshProUGUI AnimationSpeedText;
|
||||
public TextMeshProUGUI AnimationProgressText;
|
||||
|
||||
//settings
|
||||
public TMP_InputField SSWidth, SSHeight;
|
||||
|
||||
@@ -65,6 +73,9 @@ public class UmaViewerUI : MonoBehaviour
|
||||
Instance = this;
|
||||
AudioPlayButton.onClick.AddListener(AudioPause);
|
||||
AudioSlider.onValueChanged.AddListener(AudioProgressChange);
|
||||
AnimationPlayButton.onClick.AddListener(AnimationPause);
|
||||
AnimationSlider.onValueChanged.AddListener(AnimationProgressChange);
|
||||
AnimationSpeedSlider.onValueChanged.AddListener(AnimationSpeedChange);
|
||||
if (Application.platform == RuntimePlatform.Android)
|
||||
canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Shrink;
|
||||
}
|
||||
@@ -409,6 +420,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(animationList.content, container.GetComponent<Image>());
|
||||
Builder.LoadAsset(entryInstance);
|
||||
LoadedAnimation();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -423,6 +435,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(animationList.content, container.GetComponent<Image>());
|
||||
Builder.LoadAsset(entryInstance);
|
||||
LoadedAnimation();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -435,11 +448,19 @@ public class UmaViewerUI : MonoBehaviour
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(animationList.content, container.GetComponent<Image>());
|
||||
Builder.LoadAsset(entryInstance);
|
||||
LoadedAnimation();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadedAnimation()
|
||||
{
|
||||
AnimationSlider.value = 0f;
|
||||
// Reset settings by Panel
|
||||
Builder.CurrentUMAContainer.UmaAnimator.speed = AnimationSpeedSlider.value;
|
||||
}
|
||||
|
||||
/// <summary> Toggles one object ON and all others from UI.TogglablePanels list OFF </summary>
|
||||
public void ToggleUIPanel(GameObject go)
|
||||
{
|
||||
@@ -530,6 +551,53 @@ public class UmaViewerUI : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void AnimationPause()
|
||||
{
|
||||
if (Builder.OverrideController.animationClips.Length > 0)
|
||||
{
|
||||
var animator = Builder.CurrentUMAContainer.UmaAnimator;
|
||||
var AnimeState = animator.GetCurrentAnimatorStateInfo(0);
|
||||
var state = animator.speed > 0f;
|
||||
if (state)
|
||||
{
|
||||
animator.speed = 0;
|
||||
}
|
||||
else if (AnimeState.normalizedTime < 1f)
|
||||
{
|
||||
animator.speed = AnimationSpeedSlider.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.speed = AnimationSpeedSlider.value;
|
||||
animator.Play(0, -1, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void AnimationProgressChange(float val)
|
||||
{
|
||||
var animator = Builder.CurrentUMAContainer.UmaAnimator;
|
||||
if (animator != null)
|
||||
{
|
||||
var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"];
|
||||
Builder.CurrentUMAContainer.UmaAnimator.speed = 0;
|
||||
animator.Play(0, -1, val);
|
||||
|
||||
AnimationProgressText.text = string.Format("{0} / {1}", ToTimeFormat(val * AnimeClip.length), ToTimeFormat(AnimeClip.length));
|
||||
}
|
||||
}
|
||||
|
||||
public void AnimationSpeedChange(float val)
|
||||
{
|
||||
var animator = Builder.CurrentUMAContainer.UmaAnimator;
|
||||
if (animator != null)
|
||||
{
|
||||
Builder.CurrentUMAContainer.UmaAnimator.speed = val;
|
||||
AnimationSpeedText.text = $"Animation Speed: {val}";
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Builder.CurrentAudioSources.Count > 0)
|
||||
@@ -543,6 +611,18 @@ public class UmaViewerUI : MonoBehaviour
|
||||
LyricsText.text = GetCurrentLyrics(MianSource.time);
|
||||
}
|
||||
}
|
||||
|
||||
if (Builder.CurrentUMAContainer != null && Builder.CurrentUMAContainer.OverrideController["clip_2"].name != "clip_2")
|
||||
{
|
||||
var AnimeState = Builder.CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0);
|
||||
var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"];
|
||||
if (AnimeClip && Builder.CurrentUMAContainer.UmaAnimator.speed != 0)
|
||||
{
|
||||
AnimationTitleText.text = AnimeClip.name;
|
||||
AnimationProgressText.text = string.Format("{0} / {1}", ToTimeFormat(AnimeState.normalizedTime * AnimeClip.length), ToTimeFormat(AnimeClip.length));
|
||||
AnimationSlider.SetValueWithoutNotify(AnimeState.normalizedTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetAudioPlayer()
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:800597811bcc5d848b15e12807d6de45"
|
||||
"GUID:800597811bcc5d848b15e12807d6de45",
|
||||
"GUID:d60799ab2a985554ea1a39cd38695018"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
Reference in New Issue
Block a user