|
Hello, I've got a problem trying to make a draggable container into the unity editor. My need is simple, I want to create a window inside Unity editor. This window will contain draggable containers, and containers will contains text, label, etc. I found only the GUILayout.window as container. Perhaps is it my first mistake ? In any circumstances, I created the editor window, the GUILayout.Window (the container) and added a label to the container. Here is the sample Now, I want this container to be draggable... No way... I spend some time on the reference documentation, some times on google, found potential solution (GUI.DragWindow(), EventType.mouseDrag, etc). But I can't make it work ! When logging EventType.mouseDrag, I see a drag event is happening, but how to drag the window automatically ? I suppose I could set the window position manually, but I'm sure something already exists to drag a window automaticcaly... Please !!! Help me, Obi-Wan Kenobi. You're my only hope. Best regards!
(comments are locked)
|
|
Here's a shot in the dark, feel free to downvote or whatever if it doesn't help you. :) I don't know if windows act entirely the same when they're in the editor, but when drawn in games, you need to call the function GUI.DragWindow in the window function before the window responds to mouse drags. I'm guessing the same applies to a GUILayout.Window when in the editor.
(comments are locked)
|
|
Hey ! I already tried this, but now, it works ! I found the "issue". Even it seems to be a bug. For information, if other peoples are in trouble too. Here is a working code: using UnityEngine; using UnityEditor; public class DialogEditor : EditorWindow { public Rect windowRect = new Rect (20, 20, 120, 50); } Now, just uncomment the "//GUI.Window (0, new Rect (25, 25, 100, 100), DoMyWindow, "My Window");" and comment the next line and it will not work anymore ! It seems that a windowRect variable must be declared, used and affected with the return value of the "GUI.Window". If the variable is not used in the function or is not affected with the return value, drag will not work... please don't post answer as comment OFC it will not work any more that's simple let me show you: is returning new rect to nothing so everything you change in it does nothing now when you'll want to drag your window you actually won't drag My window but SomeWindowRect
Feb 27 at 12:12 PM
sdgd
(comments are locked)
|

If I understood correctly, you want to create a Window inside a Window? Window-ception. I think there isn't an automatic drag function, you'll have to move it manually.
Hello,
Thanks for your response.
You're right, I try to create a Window inside the EditorWindow. Only because I want to move a group a components in one drag.
Do you know if there is another container than a Window that can be draggable ?
No i don't, but if I were you, I'd check the ShowXXX family of functions of http://unity3d.com/support/documentation/ScriptReference/EditorWindow.html
Hello,
Ok, thanks, but I already done it without success...
Thanks again for your help.