Пример #1
0
        private static void DropAreaGUI <T>(Rect drop_area, InLayerData layer, Func <T, bool> predicate, Action <InLayerData, T, Vector2> afterDrag) where T : Object, InITreeNode <T>
        {
            Event evt = Event.current;

            switch (evt.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:

                var item = DragAndDrop.objectReferences[0] as T;
                if (!drop_area.Contains(evt.mousePosition) || predicate(item))
                {
                    //DragAndDrop.visualMode = DragAndDropVisualMode.None;
                    return;
                }

                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                if (evt.type == EventType.DragPerform)
                {
                    DragAndDrop.AcceptDrag();
                    if (afterDrag != null)
                    {
                        afterDrag(layer, item, evt.mousePosition);
                    }
                    Event.current.UseEvent();
                }

                break;
            }
        }
Пример #2
0
        private static float DrawItem(InAudioNode node, InLayerData item)
        {
            EditorGUILayout.BeginVertical(GUILayout.Height(220));
            var trackData = node._nodeData as InTrackData;


            EditorGUILayout.BeginHorizontal();


            EditorGUILayout.BeginVertical(GUILayout.Width(150));
            GUILayout.Label("Left");
            GUILayout.Label("Inside left");
            InUndoHelper.GUIUndo(trackData, "Zoom", ref item.Zoom, () => Math.Max(0, EditorGUILayout.FloatField("Zoom", item.Zoom)));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Delete Layer"))
            {
                InUndoHelper.RecordObjectFull(trackData, "Remove layer");
                {
                    toRemove = item;
                }
            }
            EditorGUILayout.Separator();
            EditorGUILayout.EndVertical();

            Rect dragArea = EditorGUILayout.BeginVertical();

            //GUILayout.Label("Right");
            item.ScrollPos = EditorGUILayout.BeginScrollView(item.ScrollPos, false, false);
            GUILayout.Label("Hello");
            Rect start = GUILayoutUtility.GetLastRect();
            var  t     = new Texture2D(1, 1);

            t.SetPixel(0, 0, Color.white);
            GUI.DrawTexture(start, t, ScaleMode.StretchToFill);
            //start.y += 20;
            //GUI.Label(start, "Hello");

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();
            //EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            DropAreaGUI <InAudioNode>(dragArea, item, otherNode => !TreeWalker.IsParentOf(node, otherNode) || node == otherNode, AfterDrag);

            return(0);
        }
Пример #3
0
        private static float DrawItem(InAudioNode node, InLayerData item)
        {
            Rect dragArea = EditorGUILayout.BeginVertical();

            //var trackData = node.NodeData as InTrackData;


            EditorGUILayout.BeginHorizontal();


            EditorGUILayout.BeginVertical(GUILayout.Width(200));
            GUILayout.Label("Left");
            item.ScrollPos.y = EditorGUILayout.BeginScrollView(item.ScrollPos, false, false, GUILayout.Height(150) /*, GUILayout.Width(EditorWindow.GetWindow<InAudioWindow>().position.width - 365)*/).y;
            GUILayout.Label("Inside left");
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical();
            GUILayout.Label("Right");
            item.ScrollPos.x = EditorGUILayout.BeginScrollView(item.ScrollPos, true, false, GUILayout.Height(150) /*, GUILayout.Width(EditorWindow.GetWindow<InAudioWindow>().position.width - 365)*/).x;
            GUILayout.Label("");
            Rect start = GUILayoutUtility.GetLastRect();

            //start.y += 20;
            GUI.Label(start, "Hello");

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();
            //EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            DropAreaGUI <InAudioNode>(dragArea, otherNode => !TreeWalker.IsParentOf(node, otherNode) || node == otherNode);

            return(0);
        }
Пример #4
0
 private static void AfterDrag(InLayerData layer, InAudioNode inAudioNode, Vector2 position)
 {
     Debug.Log("Ok");
 }