SpoitNameController.cs 898 B

12345678910111213141516171819202122232425262728293031
  1. using UnityEngine;
  2. using Blue;
  3. using UnityEngine.UI;
  4. public class SpoitNameController : AbstractController
  5. {
  6. private Transform target;
  7. private bool look;
  8. private GameObject child;
  9. public Text spoitText;
  10. private void Start()
  11. {
  12. target = GameObject.Find("ARSpaceForAll/mesh_test/SceneRoot/Player").transform;
  13. child = transform.GetChild(0).gameObject;
  14. spoitText.text = transform.parent.name;
  15. this.RegisterEvent<EditorSettingEvent>((e)=>
  16. {
  17. if(e.editor)
  18. child.SetActive(true);
  19. else
  20. child.SetActive(false);
  21. look = e.editor;
  22. }).UnRegisterWhenGameObjectDestroyed(gameObject);
  23. }
  24. void Update()
  25. {
  26. if(look)
  27. transform.LookAt(new Vector3(target.position.x, transform.position.y, target.position.z));
  28. }
  29. }