FocusModelViewCtrl.cs 563 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class FocusModelViewCtrl : MonoBehaviour
  5. {
  6. private Transform _focusTransform;
  7. private Camera _viewCamera;
  8. private bool _lookAtTarget=true;
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. _viewCamera=Camera.main;
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. if (_lookAtTarget&&_focusTransform!=null)
  18. {
  19. _viewCamera.transform.LookAt(_focusTransform);
  20. }
  21. }
  22. }