FollowShowOrHide.cs 438 B

12345678910111213141516171819
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class FollowShowOrHide : MonoBehaviour
  5. {
  6. public GameObject Follow;
  7. // Update is called once per frame
  8. void Update()
  9. {
  10. if(this.transform.localPosition.z>0)
  11. this.GetComponent<MeshRenderer>().enabled=Follow.activeSelf;
  12. else
  13. {
  14. this.GetComponent<MeshRenderer>().enabled=true;
  15. }
  16. }
  17. }