Skip to content

Commit dfedc20

Browse files
author
Janine Liu
committed
Merge branch 'main' into update-readme
2 parents 5e5f6f0 + d04d805 commit dfedc20

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

Assets/CesiumForUnitySamples/CesiumSamplesScene.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818
[InitializeOnLoad]
1919
static class CesiumSamplesSceneManager
2020
{
21+
static readonly string samplesKey = "OpenedCesiumSamples";
22+
2123
static CesiumSamplesSceneManager()
2224
{
2325
DisableTextMeshProIcons();
2426

2527
EditorSceneManager.sceneOpened += ResetSceneViewCamera;
28+
EditorApplication.update += OpenFirstSampleScene;
29+
EditorApplication.quitting += RemoveSamplesKeyFromPlayerPrefs;
2630
}
2731

2832
// There's no public API to disable component icons in the SceneView, which
@@ -61,6 +65,26 @@ static void DisableTextMeshProIcons()
6165
}
6266
}
6367

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+
6488
static void ResetSceneViewCamera(Scene scene, OpenSceneMode mode)
6589
{
6690
GameObject[] gameObjects = scene.GetRootGameObjects();
@@ -101,8 +125,6 @@ class CesiumSamplesScene : MonoBehaviour
101125
"for SceneView.LookAtDirect.")]
102126
private float _lookAtSize = 0;
103127

104-
private readonly float _sceneViewFarClip = 1000000;
105-
106128
[SerializeField]
107129
[Tooltip("The List of GameObjects that the scene should disable during play mode.")]
108130
private List<GameObject> _objectsToDisable = new List<GameObject>();
@@ -158,8 +180,6 @@ void ResetSceneView()
158180
public void ResetSceneViewOnLoad()
159181
{
160182
ResetSceneView();
161-
SceneView.lastActiveSceneView.cameraSettings.farClip = this._sceneViewFarClip;
162-
163183
EditorApplication.update -= ResetSceneViewOnLoad;
164184
}
165185
#endif

Assets/Scenes/03_CesiumSanFrancisco.unity

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ MonoBehaviour:
567567
_url:
568568
_ionAssetID: 1
569569
_ionAccessToken:
570-
_maximumScreenSpaceError: 16
570+
_maximumScreenSpaceError: 32
571571
_preloadAncestors: 1
572572
_preloadSiblings: 1
573573
_forbidHoles: 0
@@ -1020,8 +1020,8 @@ MonoBehaviour:
10201020
_url:
10211021
_ionAssetID: 1415196
10221022
_ionAccessToken:
1023-
_maximumScreenSpaceError: 2
1024-
_preloadAncestors: 0
1023+
_maximumScreenSpaceError: 8
1024+
_preloadAncestors: 1
10251025
_preloadSiblings: 1
10261026
_forbidHoles: 0
10271027
_maximumSimultaneousTileLoads: 20

0 commit comments

Comments
 (0)