CameraController.cs 556 B

1234567891011121314151617181920212223242526
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace VoxelImporter
  4. {
  5. public class CameraController : MonoBehaviour
  6. {
  7. public Transform transformCache { get; protected set; }
  8. public Transform transformLookAt;
  9. protected Vector3 defaultPosition;
  10. void Awake()
  11. {
  12. transformCache = transform;
  13. defaultPosition = transformCache.position - transformLookAt.position;
  14. }
  15. void Update()
  16. {
  17. var pos = transformLookAt.position + defaultPosition;
  18. transformCache.position = new Vector3(pos.x, transformCache.position.y, pos.z);
  19. }
  20. }
  21. }