TargetDistanceSlider.cs 547 B

12345678910111213141516
  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. float distance = this.GetComponent<Slider>().value * 70f;
  10. TargetBody target = GameObject.Find("GameArea/010").GetComponentInChildren<TargetBody>();
  11. target.SetDistance(distance);
  12. Text text = this.transform.Find("Text").GetComponent<Text>();
  13. text.text = "箭靶距离 - " + distance.ToString("#0.00") + "米";
  14. }
  15. }