CameraFacingBillboard.cs 548 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using UnityEngine;
  3. namespace BasicTools
  4. {
  5. public class CameraFacingBillboard : MonoBehaviour
  6. {
  7. private void Awake()
  8. {
  9. if (this.autoInit)
  10. {
  11. if (this.m_Camera == null)
  12. {
  13. this.m_Camera = Camera.main;
  14. }
  15. this.amActive = true;
  16. }
  17. }
  18. private void Update()
  19. {
  20. if (this.amActive)
  21. {
  22. base.transform.LookAt(this.m_Camera.transform);
  23. }
  24. }
  25. public Camera m_Camera;
  26. public bool amActive;
  27. public bool autoInit;
  28. private GameObject myContainer;
  29. }
  30. }