TargetDistanceSlider.cs 702 B

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