|
18 | 18 | [InitializeOnLoad] |
19 | 19 | static class CesiumSamplesSceneManager |
20 | 20 | { |
| 21 | + static readonly string samplesKey = "OpenedCesiumSamples"; |
| 22 | + |
21 | 23 | static CesiumSamplesSceneManager() |
22 | 24 | { |
23 | 25 | DisableTextMeshProIcons(); |
24 | 26 |
|
25 | 27 | EditorSceneManager.sceneOpened += ResetSceneViewCamera; |
| 28 | + EditorApplication.update += OpenFirstSampleScene; |
| 29 | + EditorApplication.quitting += RemoveSamplesKeyFromPlayerPrefs; |
26 | 30 | } |
27 | 31 |
|
28 | 32 | // There's no public API to disable component icons in the SceneView, which |
@@ -61,6 +65,26 @@ static void DisableTextMeshProIcons() |
61 | 65 | } |
62 | 66 | } |
63 | 67 |
|
| 68 | + // Unity will not open the first sample scene on its own, so this manually opens |
| 69 | + // the sample scene when the Editor is first opened. The PlayerPref prevents |
| 70 | + // the first scene from being re-opened whenever the user's code compiles. |
| 71 | + static void OpenFirstSampleScene() |
| 72 | + { |
| 73 | + EditorApplication.update -= OpenFirstSampleScene; |
| 74 | + if(PlayerPrefs.GetInt(samplesKey, -1) > 0) |
| 75 | + { |
| 76 | + return; |
| 77 | + } |
| 78 | + |
| 79 | + PlayerPrefs.SetInt(samplesKey, 1); |
| 80 | + EditorSceneManager.OpenScene("Assets/Scenes/01_CesiumWorld.unity"); |
| 81 | + } |
| 82 | + |
| 83 | + static void RemoveSamplesKeyFromPlayerPrefs() |
| 84 | + { |
| 85 | + PlayerPrefs.DeleteKey(samplesKey); |
| 86 | + } |
| 87 | + |
64 | 88 | static void ResetSceneViewCamera(Scene scene, OpenSceneMode mode) |
65 | 89 | { |
66 | 90 | GameObject[] gameObjects = scene.GetRootGameObjects(); |
@@ -101,8 +125,6 @@ class CesiumSamplesScene : MonoBehaviour |
101 | 125 | "for SceneView.LookAtDirect.")] |
102 | 126 | private float _lookAtSize = 0; |
103 | 127 |
|
104 | | - private readonly float _sceneViewFarClip = 1000000; |
105 | | - |
106 | 128 | [SerializeField] |
107 | 129 | [Tooltip("The List of GameObjects that the scene should disable during play mode.")] |
108 | 130 | private List<GameObject> _objectsToDisable = new List<GameObject>(); |
@@ -158,8 +180,6 @@ void ResetSceneView() |
158 | 180 | public void ResetSceneViewOnLoad() |
159 | 181 | { |
160 | 182 | ResetSceneView(); |
161 | | - SceneView.lastActiveSceneView.cameraSettings.farClip = this._sceneViewFarClip; |
162 | | - |
163 | 183 | EditorApplication.update -= ResetSceneViewOnLoad; |
164 | 184 | } |
165 | 185 | #endif |
|
0 commit comments