Skip to content

Commit d602451

Browse files
committed
fix: null ref in _newBlockId / _newBlockSprite / _newBlockPrefab after CreateLibrary
1 parent d1321e0 commit d602451

File tree

12 files changed

+135
-12
lines changed

12 files changed

+135
-12
lines changed

Assets/Code/LevelEditor/BlockLibraryWindow.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,20 @@ public static void ShowWindow()
2222
[BoxGroup("📦 Block Library", centerLabel: true)]
2323
[ReadOnly, ShowInInspector, HideLabel]
2424
private BlockLibrary _blockLibrary;
25-
25+
2626
[BoxGroup("🧱 Create Block", centerLabel: true)]
2727
[ShowInInspector, LabelText("Block ID")]
2828
private string _newBlockId = "";
29-
3029
[BoxGroup("🧱 Create Block")]
3130
[ShowInInspector, LabelText("Icon")]
3231
private Sprite _newBlockSprite;
33-
3432
[BoxGroup("🧱 Create Block")]
3533
[ShowInInspector, LabelText("Prefab")]
3634
private GameObject _newBlockPrefab;
37-
35+
3836
[BoxGroup("🔍 Search & Sort", centerLabel: true)]
3937
[ShowInInspector, LabelText("Filter")]
4038
private string _searchFilter = "";
41-
4239
[BoxGroup("🔍 Search & Sort")]
4340
[HorizontalGroup("🔍 Search & Sort/SortRow")]
4441
[EnumToggleButtons, HideLabel, PropertyOrder(0)]
@@ -71,14 +68,13 @@ protected override void DrawEditor(int index)
7168
}
7269

7370
GUILayout.Space(10);
74-
75-
DrawSelectedBlockSection();
76-
GUILayout.Space(10);
77-
7871
_scroll = EditorGUILayout.BeginScrollView(_scroll);
7972
DrawExistingBlocks();
8073
GUILayout.FlexibleSpace();
8174
EditorGUILayout.EndScrollView();
75+
76+
GUILayout.Space(10);
77+
DrawSelectedBlockSection();
8278
}
8379

8480
private void LoadOrCreateLibrary()
@@ -244,9 +240,6 @@ private void CreateNewBlock()
244240
AssetDatabase.SaveAssets();
245241

246242
Debug.Log($"✅ Created new block: {_newBlockId}");
247-
_newBlockId = "";
248-
_newBlockSprite = null;
249-
_newBlockPrefab = null;
250243
}
251244

252245
private int SafeCompare(UnityEngine.Object a, UnityEngine.Object b)

Assets/Resources/StaticData/BlocksData/BlockLibrary.asset

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ MonoBehaviour:
1919
- {fileID: 11400000, guid: 6f840c6e80be02847a36539af4966f44, type: 2}
2020
- {fileID: 11400000, guid: 653a1b7a0d0a7584db631a6d3fe22975, type: 2}
2121
- {fileID: 11400000, guid: 275269e371b517a4c904804a054d498d, type: 2}
22+
- {fileID: 11400000, guid: fe351b0a1c67ed04a93553f36a2c6c17, type: 2}
23+
- {fileID: 11400000, guid: 3fddecc790456f245919a58dea069552, type: 2}
24+
- {fileID: 11400000, guid: bea2451b1a5ce3a458317800588169f1, type: 2}
25+
- {fileID: 11400000, guid: fec0b7c3518cd74459f0ed42ede2827c, type: 2}
26+
- {fileID: 11400000, guid: 7b0fa29ca43f6c843994988a93b871bc, type: 2}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: 73698c54e77f2b34ea84f49756a68126, type: 3}
13+
m_Name: Test_bat
14+
m_EditorClassIdentifier:
15+
id: Test_bat
16+
icon: {fileID: 21300000, guid: 77f7a09b29bc7c648bd42550021c1029, type: 3}
17+
prefab: {fileID: 0}

Assets/Resources/StaticData/BlocksData/Test_bat.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: 73698c54e77f2b34ea84f49756a68126, type: 3}
13+
m_Name: 'Tetris '
14+
m_EditorClassIdentifier:
15+
id: 'Tetris '
16+
icon: {fileID: 21300000, guid: bad82fec17db2864c87c5c6fcfd4bdb5, type: 3}
17+
prefab: {fileID: 0}

Assets/Resources/StaticData/BlocksData/Tetris .asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: 73698c54e77f2b34ea84f49756a68126, type: 3}
13+
m_Name: Tetris_1
14+
m_EditorClassIdentifier:
15+
id: Tetris_1
16+
icon: {fileID: 21300000, guid: 7717b28d4af90ce4e9eae2c8ae0876ce, type: 3}
17+
prefab: {fileID: 0}

Assets/Resources/StaticData/BlocksData/Tetris_1.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: 73698c54e77f2b34ea84f49756a68126, type: 3}
13+
m_Name: Tetris_2
14+
m_EditorClassIdentifier:
15+
id: Tetris_2
16+
icon: {fileID: 21300000, guid: 1c2691b95cb8945428c5e656e7bcb6cb, type: 3}
17+
prefab: {fileID: 0}

Assets/Resources/StaticData/BlocksData/Tetris_2.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)