66
77namespace UnityEngine
88{
9+ /// <summary>
10+ /// Custom serializable class used to serialize the <see cref="SceneAsset"/> class.
11+ /// </summary>
912 [ Serializable ]
1013 public class SerializedScene : ISerializationCallbackReceiver
1114 {
@@ -18,6 +21,8 @@ public class SerializedScene : ISerializationCallbackReceiver
1821 [ SerializeField , HideInInspector ]
1922 private string sceneName ;
2023 [ SerializeField , HideInInspector ]
24+ private string scenePath ;
25+ [ SerializeField , HideInInspector ]
2126 private int buildIndex ;
2227
2328
@@ -29,6 +34,7 @@ void ISerializationCallbackReceiver.OnBeforeSerialize()
2934#if UNITY_EDITOR
3035 TryGetBuildIndex ( sceneReference , out buildIndex ) ;
3136 TryGetSceneName ( sceneReference , out sceneName ) ;
37+ TryGetScenePath ( sceneReference , out scenePath ) ;
3238#endif
3339 }
3440
@@ -85,6 +91,18 @@ private static bool TryGetSceneName(SceneAsset sceneAsset, out string name)
8591 return true ;
8692 }
8793
94+ public static bool TryGetScenePath ( SceneAsset sceneAsset , out string path )
95+ {
96+ if ( sceneAsset == null )
97+ {
98+ path = null ;
99+ return false ;
100+ }
101+
102+ path = AssetDatabase . GetAssetPath ( sceneAsset ) ;
103+ return true ;
104+ }
105+
88106
89107 public SceneAsset SceneReference
90108 {
@@ -99,6 +117,12 @@ public string SceneName
99117 set => sceneName = value ;
100118 }
101119
120+ public string ScenePath
121+ {
122+ get => scenePath ;
123+ set => scenePath = value ;
124+ }
125+
102126 public int BuildIndex
103127 {
104128 get => buildIndex ;
0 commit comments