@@ -10,11 +10,13 @@ namespace UnityEngine
1010 public class SerializedScene : ISerializationCallbackReceiver
1111 {
1212#if UNITY_EDITOR
13- private static Dictionary < SceneAsset , int > cachedBuildIndexes = new Dictionary < SceneAsset , int > ( ) ;
13+ private readonly static Dictionary < SceneAsset , int > cachedBuildIndexes = new Dictionary < SceneAsset , int > ( ) ;
1414
1515 [ SerializeField ]
1616 private SceneAsset sceneReference ;
1717#endif
18+ [ SerializeField , HideInInspector ]
19+ private string sceneName ;
1820 [ SerializeField , HideInInspector ]
1921 private int buildIndex ;
2022
@@ -26,6 +28,7 @@ void ISerializationCallbackReceiver.OnBeforeSerialize()
2628 {
2729#if UNITY_EDITOR
2830 TryGetBuildIndex ( sceneReference , out buildIndex ) ;
31+ TryGetSceneName ( sceneReference , out sceneName ) ;
2932#endif
3033 }
3134
@@ -70,13 +73,32 @@ private static bool TryGetBuildIndex(SceneAsset sceneAsset, out int index)
7073 return true ;
7174 }
7275
76+ private static bool TryGetSceneName ( SceneAsset sceneAsset , out string name )
77+ {
78+ if ( sceneAsset == null )
79+ {
80+ name = null ;
81+ return false ;
82+ }
83+
84+ name = sceneAsset . name ;
85+ return true ;
86+ }
87+
7388
7489 public SceneAsset SceneReference
7590 {
7691 get => sceneReference ;
7792 set => sceneReference = value ;
7893 }
7994#endif
95+
96+ public string SceneName
97+ {
98+ get => sceneName ;
99+ set => sceneName = value ;
100+ }
101+
80102 public int BuildIndex
81103 {
82104 get => buildIndex ;
0 commit comments