Esempio n. 1
0
        //Callback when a element is selected
        void OnSelectList(ReorderableList list)
        {
            if (this.m_index == list.index)
            {
                return;
            }

            this.m_index    = list.index;
            this.m_editable = false;
            Tools.hidden    = true;
            if (this.m_tool == RTool.VIEW || this.m_tool == RTool.SETTINGS)
            {
                this.m_tool = RTool.MOVE;
            }
        }
Esempio n. 2
0
        //Show the Control Panel of Tools
        void DrawToolControls()
        {
            GUILayout.BeginHorizontal();
            if (this.ButtonToggle(this.m_tool == RTool.VIEW, EditorGUIUtility.IconContent("ViewToolOrbit"), new GUIStyle("miniButtonLeft"), GUILayout.Height(20)))
            {
                this.m_lastTool = m_tool;
                this.m_tool     = RTool.VIEW;
                Tools.hidden    = false;
            }

            if (this.ButtonToggle((this.m_tool & RTool.MOVE) == RTool.MOVE, EditorGUIUtility.IconContent("MoveTool"), new GUIStyle("miniButtonMid"), GUILayout.Height(20)))
            {
                if ((this.m_tool & RTool.MOVE) == RTool.MOVE)
                {
                    this.m_tool &= RTool.MOVE;
                }
                else
                {
                    this.m_tool |= RTool.MOVE;
                }
                Tools.hidden = true;
            }

            //PS:
            //I did not a Icon like look a curve bezier, so i had using this dot icon as icon for bezier
            //If you found a icon like look bezier, send a message or modify this script
            if (this.ButtonToggle((this.m_tool & RTool.BEZIER) == RTool.BEZIER, EditorGUIUtility.IconContent("sv_icon_dot8_sml"), new GUIStyle("miniButtonMid"), GUILayout.Height(20)))
            {
                if ((this.m_tool & RTool.BEZIER) == RTool.BEZIER)
                {
                    this.m_tool &= RTool.BEZIER;
                }
                else
                {
                    this.m_tool |= RTool.BEZIER;
                }
                Tools.hidden = true;
            }

            if (this.ButtonToggle(this.m_tool == RTool.SETTINGS, EditorGUIUtility.IconContent("SettingsIcon"), new GUIStyle("miniButtonRight"), GUILayout.Height(20)))
            {
                this.m_lastTool = m_tool;
                this.m_tool     = RTool.SETTINGS;
                Tools.hidden    = false;
            }
            GUILayout.EndHorizontal();
            this.Separator();
        }
Esempio n. 3
0
        //Draw Point of Waypoint
        Point HandleDrawPoint(int index, Point point, Vector3 cameraPos, bool selected)
        {
            Event evt = Event.current;

            Handles.color = selected ? this.m_waypoint.selectedPointColor : this.m_waypoint.pointColor;
            ///Scale of Handles in Scene
            float handleScale = (cameraPos - point.position).magnitude / 50f;

            //if Shift you can active FreeMove like Editor
            if (evt.shift)
            {
                if (selected)
                {
                    //Drawing Free Move Handle
                    if ((this.m_tool & RTool.MOVE) == RTool.MOVE)
                    {
                        point.position = Handles.FreeMoveHandle(point.position, Quaternion.identity, handleScale, Vector3.one, Handles.CircleHandleCap);
                    }

                    //Drawing Free Bezier Handle
                    if ((this.m_tool & RTool.BEZIER) == RTool.BEZIER)
                    {
                        if (point.uniqueTangent)
                        {
                            point.tangent = Handles.FreeMoveHandle(point.position + point.tangent, Quaternion.LookRotation(cameraPos - point.position), handleScale * 0.5f, Vector3.one, Handles.CircleHandleCap) - point.position;
                            point.tangent = -(Handles.FreeMoveHandle(point.position - point.tangent, Quaternion.LookRotation(cameraPos - point.position), handleScale * 0.5f, Vector3.one, Handles.CircleHandleCap) - point.position);
                            Handles.DrawLine(point.position + point.tangent, point.position);
                            Handles.DrawLine(point.position - point.tangent, point.position);
                        }
                        else
                        {
                            point.tangentL = Handles.FreeMoveHandle(point.position + point.tangentL, Quaternion.LookRotation(cameraPos - point.position), handleScale * 0.5f, Vector3.one, Handles.CircleHandleCap) - point.position;
                            point.tangentR = Handles.FreeMoveHandle(point.position + point.tangentR, Quaternion.LookRotation(cameraPos - point.position), handleScale * 0.5f, Vector3.one, Handles.CircleHandleCap) - point.position;
                            Handles.DrawLine(point.position + point.tangentL, point.position);
                            Handles.DrawLine(point.position + point.tangentR, point.position);
                        }
                    }
                }
                else
                {
                    //Drawing SphereButton to Select Points
                    if (Handles.Button(point.position, Quaternion.identity, handleScale, handleScale, Handles.SphereHandleCap))
                    {
                        this.m_index        = index;
                        this.m_relist.index = index;
                        Tools.hidden        = true;
                        this.Repaint();
                    }
                }
            }
            else
            {
                if (selected)
                {
                    //Drawing Move Handle
                    if ((this.m_tool & RTool.MOVE) == RTool.MOVE)
                    {
                        point.position = Handles.DoPositionHandle(point.position, Quaternion.identity);
                    }

                    //Drawing Bezier Handle
                    if ((this.m_tool & RTool.BEZIER) == RTool.BEZIER)
                    {
                        if (point.uniqueTangent)
                        {
                            point.tangent = Handles.DoPositionHandle(point.position + point.tangent, Quaternion.identity) - point.position;
                            point.tangent = -(Handles.DoPositionHandle(point.position - point.tangent, Quaternion.identity) - point.position);
                            Handles.DrawLine(point.position + point.tangent, point.position);
                            Handles.DrawLine(point.position - point.tangent, point.position);
                        }
                        else
                        {
                            point.tangentL = Handles.DoPositionHandle(point.position + point.tangentL, Quaternion.identity) - point.position;
                            point.tangentR = Handles.DoPositionHandle(point.position + point.tangentR, Quaternion.identity) - point.position;
                            Handles.DrawLine(point.position + point.tangentL, point.position);
                            Handles.DrawLine(point.position + point.tangentR, point.position);
                        }
                    }
                }

                if (Handles.Button(point.position, Quaternion.identity, handleScale, handleScale, Handles.SphereHandleCap))
                {
                    if (this.m_tool == RTool.VIEW || this.m_tool == RTool.SETTINGS)
                    {
                        this.m_lastTool = (this.m_lastTool == RTool.VIEW || this.m_lastTool == RTool.SETTINGS) ? RTool.MOVE : this.m_lastTool;
                        this.m_tool     = this.m_lastTool;
                    }
                    this.m_index        = index;
                    this.m_relist.index = index;
                    Tools.hidden        = true;
                    this.Repaint();
                }
            }
            return(point);
        }