|
|
@@ -0,0 +1,30 @@
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+using UnityEngine;
|
|
|
+using UnityEngine.UI;
|
|
|
+
|
|
|
+public class AnimalSlider : MonoBehaviour
|
|
|
+{
|
|
|
+ public Transform animalRoot;
|
|
|
+ public Slider slider;
|
|
|
+ public Text text;
|
|
|
+
|
|
|
+
|
|
|
+ void Start()
|
|
|
+ {
|
|
|
+ onSlider(slider.value);
|
|
|
+ slider.onValueChanged.AddListener(onSlider);
|
|
|
+
|
|
|
+ foreach (var item in animalRoot.GetComponentsInChildren<AnimationPlayer>())
|
|
|
+ {
|
|
|
+ item.play(0, WrapMode.Loop);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void onSlider(float v) {
|
|
|
+ Vector3 pos = animalRoot.transform.localPosition;
|
|
|
+ pos.z = 70f * v;
|
|
|
+ animalRoot.transform.localPosition = pos;
|
|
|
+ text.text = pos.z.ToString("#0.00") + "米";
|
|
|
+ }
|
|
|
+}
|