CameraManager.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using UnityEngine;
  3. namespace GameWorld
  4. {
  5. public class CameraManager
  6. {
  7. public GameObject GameObject
  8. {
  9. get
  10. {
  11. GameObject result;
  12. if ((result = this._gameObject) == null)
  13. {
  14. result = (this._gameObject = this.Camera.gameObject);
  15. }
  16. return result;
  17. }
  18. }
  19. public Transform Transform
  20. {
  21. get
  22. {
  23. Transform result;
  24. if ((result = this._transform) == null)
  25. {
  26. result = (this._transform = this.Camera.transform);
  27. }
  28. return result;
  29. }
  30. }
  31. public Camera Camera
  32. {
  33. get
  34. {
  35. Camera result;
  36. if ((result = this._camera) == null)
  37. {
  38. result = (this._camera = Camera.main);
  39. }
  40. return result;
  41. }
  42. }
  43. public CameraController Controller
  44. {
  45. get
  46. {
  47. return SingletonMono<CameraController>.Instance;
  48. }
  49. }
  50. public T GetComponent<T>()
  51. {
  52. return this.GameObject.GetComponent<T>();
  53. }
  54. public T AddComponent<T>() where T : Component
  55. {
  56. return this.GameObject.AddComponent<T>();
  57. }
  58. public bool IsInView(GameObject go)
  59. {
  60. Vector3 vector = this.Camera.WorldToViewportPoint(go.transform.position);
  61. return vector.x > 0f && vector.x < 1f;
  62. }
  63. private Camera _camera;
  64. private GameObject _gameObject;
  65. private Transform _transform;
  66. }
  67. }