TargetDistanceSlider.cs 624 B

123456789101112131415161718
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class TargetDistanceSlider : MonoBehaviour
  6. {
  7. public void onSlider()
  8. {
  9. GameObject target = GameObject.Find("GameArea/010");
  10. Text text = this.transform.Find("Text").GetComponent<Text>();
  11. float value = this.GetComponent<Slider>().value;
  12. Vector3 v3 = target.transform.localPosition;
  13. v3.x = 7.718f + (-17.12f - 7.718f) * value;
  14. target.transform.localPosition = v3;
  15. text.text = "箭靶距离 - " + (10f + value * 60f).ToString("#0.00") + "米";
  16. }
  17. }