|
|
@@ -8,7 +8,9 @@ public class TargetDistanceSlider : MonoBehaviour
|
|
|
public void onSlider()
|
|
|
{
|
|
|
float distance = this.GetComponent<Slider>().value * 70f;
|
|
|
- TargetBody target = GameObject.Find("GameArea/010").GetComponentInChildren<TargetBody>();
|
|
|
+ GameObject targetBodyNode = GameObject.Find("GameArea/010");
|
|
|
+ if (targetBodyNode == null) return;
|
|
|
+ TargetBody target = targetBodyNode.GetComponentInChildren<TargetBody>();
|
|
|
target.SetDistance(distance);
|
|
|
Text text = this.transform.Find("Text").GetComponent<Text>();
|
|
|
text.text = "箭靶距离 - " + distance.ToString("#0.00") + "米";
|