Skip to content

Commit 115f995

Browse files
committed
* Fixed: setting empty string to SceneReference path caused exception.
1 parent c574bfa commit 115f995

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

Assets/DevLocker/Utils/SceneReference.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public string ScenePath
6161
m_ScenePath = value;
6262

6363
#if UNITY_EDITOR
64+
if (string.IsNullOrEmpty(m_ScenePath)) {
65+
m_SceneAsset = null;
66+
return;
67+
}
68+
6469
m_SceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(m_ScenePath);
6570
if (m_SceneAsset == null) {
6671
Debug.LogError($"Setting {nameof(SceneReference)} to {value}, but no scene could be located there.");

Assets/SceneReferenceTests/SceneReferenceTester.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ public class SceneReferenceTester : MonoBehaviour
1212

1313
public ScenesScriptableObject ScenesScriptableObject;
1414

15+
[Header("Tested on Awake")]
16+
public SceneReference SceneCloned;
17+
public SceneReference SceneEmpty;
18+
1519
private void Awake()
1620
{
1721
DontDestroyOnLoad(gameObject);
22+
23+
SceneCloned = Scene.Clone();
24+
SceneEmpty.ScenePath = "";
1825
}
1926

2027
// Update is called once per frame

Assets/Scenes/_StarterScene.unity

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,14 @@ MonoBehaviour:
400400
m_ScenePath: Assets/Scenes/SampleScene_1.unity
401401
Prefab: {fileID: 5893044413620456609, guid: f630998d0f817d3499f63e347d28058f, type: 3}
402402
ScenesScriptableObject: {fileID: 11400000, guid: aca86b8fbbc914b4db3184331499c19e, type: 2}
403+
SceneCloned:
404+
m_SceneAsset: {fileID: 0}
405+
m_IsDirty: 0
406+
m_ScenePath:
407+
SceneEmpty:
408+
m_SceneAsset: {fileID: 102900000, guid: 26d92f6ceae54f747b5f4ef157f8d8e3, type: 3}
409+
m_IsDirty: 0
410+
m_ScenePath: Assets/Scenes/SampleScene_3.unity
403411
--- !u!4 &1877703096
404412
Transform:
405413
m_ObjectHideFlags: 0

0 commit comments

Comments
 (0)