- Home /
EditorWindow that changes properties of a custom gameObject
Hello.
I'm attempting to create a custom heightmap/3D noise gameobject. I don't want to get one from asset store because I'm doing this to learn. The actual object, for the most part, works as designed. So, to extend functionality/convenience, I wanted to play around with GUI controls. I've got the basics of making an inspector. I understand the idea of the serialized game object. I was running into troubles with getting NULLs when trying to findProperty, but I got it.
So, if it helps, my gameobject really is node based, and the "root" really contains one node. That node can be either an arithmetic operation, or an algebraic representation of shape. Essentially, all the "leaves" are shapes or gradients. Then I extract a the value of the X,Y,Z of that "function". This is just how I know I can do it, pointers would be nice, but I kind of proud of my juvenile thing, and it has room to grow. The limited part is, I basically have to construct the whole "tree" by hand, with several nested constructor calls.
So, my problem really comes into with how I want my GUI tools to work. I want to attach a button to my inspector(done, no problems), that launches a window(which I kinda figured, so I don't think I'm really asking about the OnGUI line by line creating of the fields and buttons), which affects the properties of that one gameobject, and this is where I'm failing. I don't think I'm effectively finding the right gameObject or serializedObject or whatever.
At first, I was hoping to use the Show method I was making in that, and have a parameter of the object to give to, but the variable I want to assign it to "technically doesn't exist" at that point, so I don't know how to keep it persistent with that approach. Then I was trying to call another method right after launching the window, but I failed on the that approach, but then I started use the darn Find object, and then serialize it, then try to create the GUI with a similar approach I used in my inspector. That way, I'm getting NULL errors again, and my menu does nothing to change any properties of the game object. So, now I'd thought, I need someone smarter, even for a few seconds. Plus, I kinda get impression that if I make more than one of the object, it may not get the specific one I want.
I'd post code, but I've already gave a lot in paragraph form, and I don't want to over complicate it.
How can I effectively store the object in my menu class to make changes to it like I would in the inspector? Please consider, that the only way to open this menu will be from that objects Inspector.