- Home /
EditorWindow: wrong/misplaced??? reference value after assembly reload
Hello everyone, sorry for the title. Ok it goes like this,
I have a button in a property drawer that when clicked, it opens up an Editor Window that goes like this:
if (GUI.Button(btnRect, "Edit Pattern"))
PatternWindow.ShowWindow(instance, (PieceObject)property.serializedObject.targetObject, label.text);
I got an instance of PatternCollection within the property drawer by doing this:
PatternCollection GetInstance(SerializedProperty property)
{
var target = property.serializedObject.targetObject;
return (PatternCollection)fieldInfo.GetValue(target);
}
The method ShowWindow() in the Editor Window looks like this:
public static PatternWindow instance;
PieceObject target;
PatternCollection patterns;
void OnEnable()
{
instance = this;
}
public static void ShowWindow(PatternCollection patterns, PieceObject target, string name)
{
GetWindow<PatternWindow>(true, name + " Pattern").Show();
instance.target = target;
instance.patterns = patterns;
}
The references target and patterns are now passed in my Editor Window, and it works fine. I can apply patterns to the editor window which is also applied to the inspector.
But after an assembly reload, the values still stayed. Even the target and patterns are not null. But it doesn't apply to the inspector anymore.
I tried to reopen the window to see if its just a delayed change, but it didn't. The patterns are the same before the assembly reload. Then its back to normal after I reopened the window. The problem goes back after the assembly reload while the window is open. I have tried the following:
hideFlags = HideFlags.HideAndDontSave;
EditorUtility.SetDirty(target);
AssetDatabase.SaveAssets();
Your answer
Follow this Question
Related Questions
Undo issues in EditorWindow 0 Answers
How to avoid one button to be clicked when another button in footer overlaps it. 1 Answer
How do I stop new elements in a list/array from inheriting values from the last element? 1 Answer
Editor GUI Foldout header style customization 0 Answers
Scene Window goes grey in some scenes? 0 Answers