Cesium for Unity 1.15.2
Loading...
Searching...
No Matches
CesiumCameraManager.cs
Go to the documentation of this file.
1using Reinterop;
2using System;
3using System.Collections.Generic;
4using System.Collections.ObjectModel;
5using UnityEngine;
6
7namespace CesiumForUnity
8{
12 [DisallowMultipleComponent]
13 [AddComponentMenu("Cesium/Cesium Camera Manager")]
14 [Icon("Packages/com.cesium.unity/Editor/Resources/Cesium-24x24.png")]
15 public class CesiumCameraManager : MonoBehaviour
16 {
28 public static CesiumCameraManager GetOrCreate(GameObject gameObject)
29 {
30 if (gameObject == null) throw new ArgumentNullException("gameObject");
31
32 CesiumCameraManager result = gameObject.GetComponentInParent<CesiumCameraManager>();
33 if (result == null)
34 return CesiumCameraManager.Create(gameObject);
35 else
36 return result;
37 }
38
39 private static CesiumCameraManager Create(GameObject gameObject)
40 {
41 // Add it to the same game object that has the CesiumGeoreference, if any.
42 // Otherwise, add it to the current game object.
43 CesiumGeoreference georeference = gameObject.GetComponentInParent<CesiumGeoreference>();
44 GameObject owner = georeference == null ? gameObject : georeference.gameObject;
45 if (owner == null) return null;
46
47 return owner.AddComponent<CesiumCameraManager>();
48 }
49
50 #region User-editable properties
51
52 [SerializeField]
53 private bool _useMainCamera = true;
54
59 public bool useMainCamera
60 {
61 get => this._useMainCamera;
62 set
63 {
64 this._useMainCamera = value;
65 }
66 }
67
68 [SerializeField]
69 private bool _useSceneViewCameraInEditor = true;
70
77 {
78 get => this._useSceneViewCameraInEditor;
79 set
80 {
81 this._useSceneViewCameraInEditor = value;
82 }
83 }
84
85 [SerializeField]
86 private List<Camera> _additionalCameras = new List<Camera>();
87
98 public List<Camera> additionalCameras
99 {
100 get => this._additionalCameras;
101 }
102
103 #endregion
104 }
105}
Manages the set of cameras that are used for Cesium3DTileset culling and level-of-detail.
static CesiumCameraManager GetOrCreate(GameObject gameObject)
Gets the instance suitable for use with the given game object.
List< Camera > additionalCameras
Other cameras to use for Cesium3DTileset culling and level-of-detail, in addition to the ones control...
bool useSceneViewCameraInEditor
Determines whether the camera associated with the Editor's active scene view should be used for Cesiu...
bool useMainCamera
Determines whether the camera tagged MainCamera should be used for Cesium3DTileset culling and level-...
Controls how global geospatial coordinates are mapped to coordinates in the Unity scene.