LookAtMainCamera.cs 553 B

123456789101112131415161718192021
  1. using UnityEngine;
  2. namespace Mirror.Examples.AdditiveLevels
  3. {
  4. // This script is attached to portal labels to keep them facing the camera
  5. public class LookAtMainCamera : MonoBehaviour
  6. {
  7. // This will be enabled by Portal script in OnStartClient
  8. void OnValidate()
  9. {
  10. this.enabled = false;
  11. }
  12. // LateUpdate so that all camera updates are finished.
  13. [ClientCallback]
  14. void LateUpdate()
  15. {
  16. transform.forward = Camera.main.transform.forward;
  17. }
  18. }
  19. }