MapBehaviour.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using UnityEngine;
  2. using XGame.Framework.ObjectCollection;
  3. namespace XGame.Framework.Map
  4. {
  5. /// <summary>
  6. /// 地图根节点
  7. /// </summary>
  8. [DisallowMultipleComponent]
  9. [AddComponentMenu("XGame/Map/MapBehaviour")]
  10. public class MapBehaviour : MonoBehaviour
  11. {
  12. /// <summary>
  13. /// 序列化器
  14. /// </summary>
  15. [SerializeField]
  16. private ObjectCollector _collector = new ObjectCollector();
  17. /// <summary>
  18. /// 地图相机
  19. /// </summary>
  20. [SerializeField]
  21. private Camera _camera;
  22. /// <summary>
  23. /// 序列化器
  24. /// </summary>
  25. public IObjectCollector Collector => _collector;
  26. /// <summary>
  27. /// 地图相机
  28. /// </summary>
  29. public Camera Camera => _camera;
  30. private void Start()
  31. {
  32. if (_camera == null)
  33. {
  34. _camera = transform.GetComponentInChildren<Camera>();
  35. }
  36. if (_camera == null)
  37. {
  38. _camera = Camera.main;
  39. }
  40. if ( _camera == null)
  41. {
  42. Log.Error($"地图没有相机.Name:{gameObject.name}");
  43. }
  44. }
  45. }
  46. }