Billboard.cs 643 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using UnityEngine;
  3. public class Billboard : BaseBehaviour
  4. {
  5. private void Awake()
  6. {
  7. if (this.AutoInitCamera)
  8. {
  9. this.Camera = Camera.main;
  10. this.Active = true;
  11. }
  12. this.camT = this.Camera.transform;
  13. this.contT = base.transform;
  14. }
  15. private void Update()
  16. {
  17. if (this.Active)
  18. {
  19. this.contT.LookAt(this.contT.position + this.camT.rotation * Vector3.back, this.camT.rotation * Vector3.up);
  20. }
  21. }
  22. public Camera Camera;
  23. public bool Active = true;
  24. public bool AutoInitCamera = true;
  25. private GameObject myContainer;
  26. private Transform camT;
  27. private Transform contT;
  28. }