Hi.
So I’ve searched countless of times for a solution to this problem, but I wasnt really able to find or understand how to work (around?) this. In practise:
I have an EditorWindow which has a variable of an object I want to make GUI of, for example:
class MyEditorWindow extends EditorWindow{
var targetObject:Foo;
function OnGUI(){
targetObject.myVar = FloatField(targetObject.myVar);
if (GUI.changed)
EditorUtility.SetDirty(targetObject);
}
@MenuItem("MyEditor/OpenEditor")
static function OpenWindow(targetObject:Foo){
var window = GetWindow(MyEditorWindow);
window.targetObject = targetObject;
window.Show();
}
}
All works good etc. Then I hit Play and everything has been decoupled. I still see my EditorWindow GUI and change the float for example from the control, but it doesnt refer to the targetObject anymore. So anyone know hot to work this?
Thanks, I believe I was prety clear on the issue
and hopefully other get help as well.
(PS: Foo is MonoBehaviour)
What is Foo? Is it a MonoBehaviour script? Because "normal" classes aren't serialized on their own. They are serialized along with a MonoBehaviour or ScriptableObject
– Bunny83Yes its a MonoBehaviour..Sorry
– nuverianThe issue is not that targetObject (Foo) is no sierializing the changes done from the editor, but rather that the editor window looses the connection with the targetObject as sson as I enter play mode
– nuverianMay i ask you how you open the window? Because MenuItems doesn't work on functions with parameters.
– Bunny83In my original code there is an object field and a buch of stuff as well :P, So in your test if you have the EditorWindow open and the targetObject set, and then hit play (while the window is still open) will the example FloatField still change the target object, without having to reopen the EditorWindow? Thanks a lot for your time (PS: I open the editor from the Inspector of the target object by a button. I just forgot the attribute in the example above)
– nuverian