Exemplo n.º 1
0
        static void PoseNodeWindow(int windowID)
        {
            PoseNode posenode = null;

            if (windowID < controller.posenodes.Count)
            {
                posenode = controller.posenodes[windowID];
            }
            else
            {
                posenode = controller.final;
            }
            if (posenode == null)
            {
                GUI.DragWindow();
                return;
            }

            // Delete this posenode
            if (draggingSlot == null && editingSlot == null && Event.current != null && Event.current.type == EventType.mouseDown)
            {
                if (Event.current.button == 1 && Event.current.mousePosition.y < 16)
                {
                    ControllerEditorMenu.PopupDelete(Event.current.mousePosition, null, posenode);
                }
            }

            // Multiple-click this posenode
            if (draggingSlot == null && editingSlot == null && Event.current != null && Event.current.type == EventType.mouseDown)
            {
                if (Event.current.button == 0 && Event.current.clickCount == 2 && Event.current.mousePosition.y < 16)
                {
                    if (posenode is Modifier)
                    {
                        CameraForgeWindow.nextCurrent = posenode;
                        mouseDown = false;
                    }
                }
            }

            GUILayout.BeginHorizontal(GUILayout.MinHeight(10));

            if (posenode.slots.Length + posenode.poseslots.Length > 0)
            {
                GUILayout.BeginVertical();
                GUILayout.Space(1);
                for (int i = 0; i < posenode.slots.Length; ++i)
                {
                    //GUILayout.Space(-1);
                    Rect rct = EditorGUILayout.BeginHorizontal();

                    GUI.color = posenode.slots[i].input == null ? new Color(1, 1, 1, 0.2f) : Color.white;
                    if (posenode.slots[i].name == "Name" || posenode.slots[i].name == "Count")
                    {
                        GUI.color = Color.clear;
                    }
                    GUILayout.Label(posenode.slots[i].input == null ? cfwindow.texInputSlot : cfwindow.texInputSlotActive);
                    GUI.color = Color.white;
                    EditorGUILayout.EndHorizontal();
                    GUILayout.Space(-3);

                    // Draw "drag slot area"
                    GUIStyle gs = new GUIStyle();
                    gs.normal.background = cfwindow.texInputSlot;
                    gs.hover.background  = cfwindow.texInputSlot;
                    gs.active.background = cfwindow.texInputSlot;

                    rct.x     += 2;
                    rct.y     += 1;
                    rct.width  = 16;
                    rct.height = 16;
                    Color c = NodeColor(posenode);
                    c.a       = 0.7f;
                    GUI.color = c;
                    if (posenode.slots[i].name != "Name" && posenode.slots[i].name != "Count")
                    {
                        if (Event.current != null && rct.Contains(Event.current.mousePosition))
                        {
                            GUI.Label(rct, "", gs);
                            // Begin drag slot
                            if (Event.current.type == EventType.MouseDown)
                            {
                                if (Event.current.button == 0)
                                {
                                    draggingSlot            = posenode.slots[i];
                                    draggingSlotIndex       = i;
                                    draggingSlot.input      = null;
                                    dragSlotExcludeNode     = null;
                                    dragPoseSlotExcludeNode = posenode;
                                }
                            }
                        }
                    }
                    GUI.color = Color.white;
                }
                for (int i = 0; i < posenode.poseslots.Length; ++i)
                {
                    //GUILayout.Space(-1);
                    Rect rct = EditorGUILayout.BeginHorizontal();

                    GUI.color = posenode.poseslots[i].input == null ? new Color(1, 1, 1, 0.2f) : Color.white;
                    GUILayout.Label(posenode.poseslots[i].input == null ? cfwindow.texInputSlot : cfwindow.texInputSlotActive);
                    GUI.color = Color.white;
                    EditorGUILayout.EndHorizontal();
                    GUILayout.Space(-3);

                    // Draw "drag slot area"
                    GUIStyle gs = new GUIStyle();
                    gs.normal.background = cfwindow.texInputSlot;
                    gs.hover.background  = cfwindow.texInputSlot;
                    gs.active.background = cfwindow.texInputSlot;

                    rct.x     += 2;
                    rct.y     += 1;
                    rct.width  = 16;
                    rct.height = 16;
                    Color c = NodeColor(posenode);
                    c.a       = 0.7f;
                    GUI.color = c;
                    if (Event.current != null && rct.Contains(Event.current.mousePosition))
                    {
                        GUI.Label(rct, "", gs);
                        // Begin drag slot
                        if (Event.current.type == EventType.MouseDown)
                        {
                            if (Event.current.button == 0)
                            {
                                draggingPoseSlot        = posenode.poseslots[i];
                                draggingPoseSlotIndex   = i;
                                draggingPoseSlot.input  = null;
                                dragSlotExcludeNode     = null;
                                dragPoseSlotExcludeNode = posenode;
                            }
                        }
                    }
                    GUI.color = Color.white;
                }
                GUILayout.Space(3);
                GUILayout.EndVertical();


                Rect nameRect = EditorGUILayout.BeginVertical(GUILayout.MinWidth(30), GUILayout.MaxWidth(200));
                GUILayout.Space(2);
                for (int i = 0; i < posenode.slots.Length; ++i)
                {
                    if (posenode.slots[i] == editingSlot)
                    {
                        GUI.color = Color.clear;
                    }
                    GUILayout.Label(posenode.slots[i].name);
                    GUI.color = Color.white;
                }
                for (int i = 0; i < posenode.poseslots.Length; ++i)
                {
                    GUILayout.Label(posenode.poseslots[i].name);
                }
                EditorGUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.MinWidth(20), GUILayout.MaxWidth(200));
                GUILayout.Space(2);
                for (int i = 0; i < posenode.slots.Length; ++i)
                {
                    string value = "";
                    if (!posenode.slots[i].value.isNull)
                    {
                        value = posenode.slots[i].value.ToEditString(false);
                    }

                    Rect rct = EditorGUILayout.BeginHorizontal();

                    GUIStyle gs = new GUIStyle(EditorStyles.label);
                    gs.alignment = TextAnchor.MiddleRight;
                    gs.padding   = new RectOffset(gs.padding.left, 5, gs.padding.top, gs.padding.bottom);

                    Color c = NodeColor(posenode);
                    c.a = 0.25f;

                    if (posenode.slots[i].input != null)
                    {
                        GUI.color = c;
                        GUILayout.Label(value, gs);
                        GUI.color = Color.white;
                    }
                    else
                    {
                        GUIStyle gbs = new GUIStyle(EditorStyles.miniButton);
                        gbs.hover.background = gbs.normal.background;

                        Rect btn_rct = new Rect(rct.xMin - (nameRect.width + 8), rct.yMin, rct.width + (nameRect.width + 8), rct.height - 1);

                        c.a       = 0.5f;
                        GUI.color = c;
                        if (!posenode.slots[i].value.isNull)
                        {
                            gbs.normal.background = null;
                        }
                        if (posenode.slots[i] != editingSlot && GUI.Button(btn_rct, "", gbs))
                        {
                            if (Event.current != null && Event.current.button == 0)
                            {
                                EndEditingSlot();
                                editingSlot      = posenode.slots[i];
                                editingSlotValue = posenode.slots[i].value.ToEditString(true);
                                if (posenode is PoseBlend)
                                {
                                    editingPoseBlend = posenode as PoseBlend;
                                }
                                else
                                {
                                    editingPoseBlend = null;
                                }
                                GUI.FocusControl("");
                            }
                        }
                        GUI.color = Color.white;

                        if (posenode.slots[i].value.isNull)
                        {
                            value = "?";
                        }

                        if (posenode.slots[i] == editingSlot)
                        {
                            GUI.color = Color.clear;
                        }
                        GUILayout.Label(value, gs);
                        GUI.color = Color.white;

                        if (posenode.slots[i] == editingSlot)
                        {
                            GUIStyle gfs = new GUIStyle(EditorStyles.textField);
                            gfs.alignment = TextAnchor.MiddleRight;
                            gfs.padding   = new RectOffset(gfs.padding.left, 5, gfs.padding.top, gfs.padding.bottom);
                            gfs.fontSize  = 10;
                            c.a           = 1;
                            //GUI.color = c;
                            GUI.SetNextControlName("EditSlot");
                            editingSlotValue = GUI.TextField(btn_rct, editingSlotValue, gfs);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                for (int i = 0; i < posenode.poseslots.Length; ++i)
                {
                    string value = "Camera Pose";

                    if (posenode is PoseBlend)
                    {
                        value = "Weight = " + (posenode as PoseBlend).GetWeight(i).ToString("0.000000");
                    }

                    EditorGUILayout.BeginHorizontal();

                    GUIStyle gs = new GUIStyle(EditorStyles.label);
                    gs.alignment = TextAnchor.MiddleRight;
                    gs.padding   = new RectOffset(gs.padding.left, 5, gs.padding.top, gs.padding.bottom);

                    Color c = NodeColor(posenode);
                    c.a = 0.25f;

                    if (posenode.poseslots[i].input != null)
                    {
                        GUI.color = c;
                        GUILayout.Label(value, gs);
                        GUI.color = Color.white;
                    }
                    else
                    {
                        GUI.color = c;
                        GUILayout.Label("Default Pose", gs);
                        GUI.color = Color.white;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
            else
            {
                GUILayout.BeginVertical(GUILayout.MaxWidth(5));
                GUILayout.Space(2);
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.MaxWidth(5));
                GUILayout.Space(2);
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.MinWidth(80));
                GUILayout.Space(0);
                Color c = NodeColor(posenode);
                c.a       = 0.25f;
                GUI.color = c;
                GUIStyle gs = new GUIStyle();
                gs.normal.textColor = Color.white;
                gs.alignment        = TextAnchor.LowerRight;
                GUILayout.Label("<Empty>", gs);
                GUI.color = Color.white;
                GUILayout.Space(1);
                GUILayout.EndVertical();
            }

            if (!(posenode is FinalPose))
            {
                GUILayout.Space(-13);
                GUILayout.BeginVertical();
                GUILayout.Space(-21);
                GUI.color = NodeColor(posenode);
                if (!posenodeOutputs[windowID])
                {
                    GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.2f);
                }
                if (posenode == dragPoseSlotExcludeNode)
                {
                    GUI.color = Color.clear;
                }
                GUILayout.Label(posenodeOutputs[windowID] ? cfwindow.texOutputSlotActive : cfwindow.texOutputSlot);
                GUI.color = Color.white;
                GUILayout.EndVertical();
                GUILayout.Space(-7);
            }
            else
            {
                GUILayout.BeginVertical();
                GUILayout.EndVertical();
            }

            GUILayout.EndHorizontal();

            if (dragPoseSlotExcludeNode != posenode)
            {
                GUI.DragWindow();
            }
        }
Exemplo n.º 2
0
        // Drag Pose Slot
        static void DragPoseSlot()
        {
            int stncnt = controller.posenodes.Count;

            // Drag pose slot
            if (draggingPoseSlot != null && Event.current != null)
            {
                for (int n = 0; n < stncnt; ++n)
                {
                    PoseNode posenode = controller.posenodes[n];

                    if (posenode == dragPoseSlotExcludeNode)
                    {
                        continue;
                    }
//					if (dragPoseSlotExcludeNode.IsDependencyOf(node))
//						continue;

                    Rect outputRect = posenodeRects[n];
                    outputRect.xMin   = outputRect.xMax - 20;
                    outputRect.yMin   = outputRect.yMin - 3;
                    outputRect.width  = 24;
                    outputRect.height = 24;

                    bool inRect = outputRect.Contains(Event.current.mousePosition);

                    if (!mouseDown)
                    {
                        if (inRect)
                        {
                            draggingPoseSlot.input = posenode;
                            draggingPoseSlot.value = Pose.Default;
                        }
                    }

                    Color c = NodeColor(posenode);
                    c.a = inRect ? 1.0f : 0.4f;
                    Color.Lerp(c, Color.white, inRect ? 0f : 0.5f);
                    GUI.color = c;
                    GUI.Label(outputRect, cfwindow.texTargetArea);
                    GUI.color = Color.white;
                }

                // Dragging , draw line
                Vector2 thispos = Node2Content(dragPoseSlotExcludeNode.editorPos);
                thispos.y += (30 + (draggingPoseSlotIndex + dragPoseSlotExcludeNode.slots.Length) * 18);
                thispos.x += 8;
                Vector2 targetpos = Event.current.mousePosition;

                float tgl = Vector2.Distance(targetpos, thispos) * 0.5f;
                tgl = Mathf.Min(100, tgl);

                Vector2 thistg   = thispos - Vector2.right * tgl;
                Vector2 targettg = targetpos + Vector2.right * tgl;

                if (Vector3.Distance(thispos, targetpos) > 8)
                {
                    Handles.DrawBezier(thispos, targetpos, thistg, targettg, new Color(1, 1, 1, 0.2f), null, 3f);
                }

                if (!mouseDown)
                {
                    draggingPoseSlot        = null;
                    draggingPoseSlotIndex   = -1;
                    dragSlotExcludeNode     = null;
                    dragPoseSlotExcludeNode = null;
                }
            }             // End 'Drag pose slot'
        }