fullinspector
fullinspector copied to clipboard
"Proxy editor for Gradient" leaking
A new object is being created after each assembly reload when we have a gradient property in a behavior. I'm drawing the inspector using the toolkit.
@jacobdufault could this be related to the lack of multi-scene support?
This actually happens for anything using the proxy editors.
A quick fix is below (might submit a PR when I have more time).
Just replace the MetadataObject
implementation with the given one, on the file fiGenericPropertyDrawerPropertyEditorManager.cs
private GameObject MetadataObject {
get {
if (s_metadataObject == null) {
var name = "Proxy editor for " + typeof(T).CSharpName();
// note: using HideFlags.HideAndDontSave includes
// HideFlags.NotEditable
var flags = HideFlags.HideInHierarchy | HideFlags.DontSave;
s_metadataObject = GameObject.Find(name);
if (s_metadataObject == null) {
s_metadataObject = EditorUtility.CreateGameObjectWithHideFlags(name, flags);
}
}
There's another issue with those proxies: they break using serializedObject.targetObject
in the drawers.
If you have something like this
public override void OnGUI( Rect position, SerializedProperty property, GUIContent label ) {
var behaviour = property.serializedObject.targetObject as MonoBehaviour;
var animator = behaviour.GetComponent<Animator>();
}
Then your animator
will be null, since the targetObject
is actually the proxy container, not the object itself.
I did a bit of work on this, to make the containers be stored in the object itself (with proper hideflags), but I gave up because I was getting nowhere. I may open another issue with further details eventually.