Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit 24794c7

Browse files
Commented runtime set editor inspector code regarding handling of scene objects
1 parent 7d2949c commit 24794c7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Assets/SO Architecture/Editor/Inspectors/RuntimeSetEditor.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,21 @@ private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
3636

3737
SerializedProperty property = _reorderableList.serializedProperty.GetArrayElementAtIndex(index);
3838

39+
//We differentiate between the two so we can show scene objects that are assigned during runtime
40+
//Assets cannot contain scene objects, so we disallow assigning out of runtime
41+
//Note that scene objects must be assigned through code. Due to the above statement, the Unity editor specifically disallows it
42+
3943
if(Application.isPlaying)
4044
{
41-
EditorGUI.ObjectField(rect, "Element " + index, property.objectReferenceValue, _targetType, true);
45+
//Very important not to assign to property here. Due to the comments made above, doing so will make all scene object entries null
46+
Object obj = EditorGUI.ObjectField(rect, "Element " + index, property.objectReferenceValue, _targetType, false);
47+
48+
//If the object is a scene object we do nothing. This allows scene objects assigned through code to be visible in the editor,
49+
// while still allowing designers to manually assign non-scene objects
50+
if (EditorUtility.IsPersistent(obj))
51+
{
52+
property.objectReferenceValue = obj;
53+
}
4254
}
4355
else
4456
{

0 commit comments

Comments
 (0)