Drag States in Custom Editor Window

Hello

I’m currently writing an AI System, which works pretty fine for me, but I want to customize it, so Artists can easily use it.

I’m thinking about a System which works like the Animator Window, so you can easily drag around states, connect them and set up conditions for different AI Behaviours etc.

The problem is to drag the states around, the new UI does not work for Editor Windows, so I tried to do this by using an GUI.Window but it seems like GUI.Window doesn’t work either for Editor Windows.
It’s just not shown up, the code is the same like the one shown up in the docs, so it have to be with Editor Window.

Well, talked enough :wink: , my main question :

So far, I can’t use GUI.DragWindow, is there any build-in solution for draging Buttons or whatever in an Editor Window ?
If not, what would you recommend to do ?
I thought about to write it from scratch, check for the mousePosition + Input and change the UI - Objects positions to the mouseposition, but maybe someone gots a better idea ?

Node editors are tricky. You might wanna pick apart some node-connecting package and see how they went about it, just to give you some ideas. The code for the Unity mecanim UI is in Unity/Editor/Data/Managed/UnityEditor.Graphs.dll - Get [ILSpy][1] and take a peek [1]: http://ilspy.net/

Thanks, I used dotPeek to decompile the package. Its a bit large but seems like its pretty good code, easy to read :)

1 Answer

1

I have not done this, but it can be done.

Take a look at the UnityEditor name space in the documentation. Some suggested reading can be:

This also may help:

http://forum.unity3d.com/threads/simple-node-editor.189230/

Let us know how you get on. I hope this will jump-start what you’re doing.

Thanks again Adam, that helped alot, especially the example of the Node Editor. I'm gonna to create a new thread to my AI System controlled by this editor window when I'm ready to show some work, but this will need some time :)

Makes sense. These things don't come overnight! Looking forward to it when it's done.