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

Commit caf0c4f

Browse files
Fixed improper handling of non-persistent objects in the runtimeset editor
1 parent 0643833 commit caf0c4f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Assets/SO Architecture/Documentation/Runtime-Set.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Introduction
2-
Runtime Sets are simply a collection of objects that are assigned during runtime. Note that the inspector is merely there for debugging purposes, and not supposed to let you drag data into the set. You can see all objects within the set, click on them to see where they are in the scene view, and even remove entries.
2+
Runtime Sets are simply a collection of objects
3+
4+
Note that Unity **realy** doesn't like it if you reference scene objects in assets, and as such have made certain editor functions incompatible with them. Therefore if any object in the set is not persistent they're disabled, although you can still reorder, delete and click on them to see them in your scene view. Note that none of these conditions affect how they work under the hood, these precautions are merely related to the editor
35

46
## Script Reference
57
There are various ways to interact with the runtime set. Available are the following members

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,18 @@ private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
5656

5757
if (SOArchitecture_EditorUtility.HasPropertyDrawer(Target.Type))
5858
{
59-
EditorGUI.PropertyField(rect, property, new GUIContent(""));
59+
//Unity doesn't like it when you have scene objects on assets,
60+
//so we do some magic to display it anyway
61+
if (typeof(Object).IsAssignableFrom(Target.Type) && !EditorUtility.IsPersistent(property.objectReferenceValue) && property.objectReferenceValue != null)
62+
{
63+
EditorGUI.BeginDisabledGroup(true);
64+
EditorGUI.ObjectField(rect, new GUIContent(""), property.objectReferenceValue, Target.Type, false);
65+
EditorGUI.EndDisabledGroup();
66+
}
67+
else
68+
{
69+
EditorGUI.PropertyField(rect, property, new GUIContent(""));
70+
}
6071
}
6172
else
6273
{

0 commit comments

Comments
 (0)