Exemplo n.º 1
0
        void OnSceneGUI()
        {
            Handles.BeginGUI();

            mUserValuesLabel = new GUIStyle(EditorStyles.boldLabel);
            mUserValuesLabel.normal.textColor = Color.green;

            if (Target.UserValueSize > 0 && CurvySpline.Gizmos.HasFlag(CurvySplineGizmos.UserValues))
            {
                foreach (CurvySplineSegment cp in Target.ControlPoints)
                {
                    string uvalues = "";
                    for (int i = 0; i < cp.UserValues.Length; i++)
                    {
                        uvalues += string.Format("{0}: {1}\n", new object[] { i, cp.UserValues[i] });
                    }
                    Handles.Label(cp.Transform.position + new Vector3(0, -0.2f, 0), uvalues, mUserValuesLabel);
                }
            }

            if (CurvySpline.Gizmos.HasFlag(CurvySplineGizmos.Labels))
            {
                GUIStyle stLabel = new GUIStyle(EditorStyles.boldLabel);
                stLabel.normal.textColor = Color.white;
                Handles.Label(Target.Transform.position - new Vector3(-0.5f, 0.2f, 0), Target.name, stLabel);
                foreach (CurvySplineSegment cp in Target.ControlPoints)
                {
                    Handles.Label(cp.Position + new Vector3(-0.5f, HandleUtility.GetHandleSize(cp.Position) * 0.35f, 0), cp.name, stLabel);
                }
            }

            Handles.EndGUI();
            Toolbar.Render();
        }
Exemplo n.º 2
0
        void OnSceneGUI()
        {
            Handles.ArrowCap(0, Target.Position, Quaternion.LookRotation(Target.Transform.up), HandleUtility.GetHandleSize(Target.Position));

            if (IsActive)
            {
                // Bezier-Handles
                if (Target.Spline.Interpolation == CurvyInterpolation.Bezier)
                {
                    Handles.color = Color.grey;
                    Vector3 handleOut = Target.HandleOutPosition;
                    Vector3 handleIn  = Target.HandleInPosition;

                    EditorGUI.BeginChangeCheck();
                    Vector3 pOut = Handles.PositionHandle(Target.HandleOutPosition, Tools.handleRotation);

                    Handles.CubeCap(0, pOut, Quaternion.identity, HandleUtility.GetHandleSize(Target.HandleOutPosition) * 0.1f);
                    Handles.DrawLine(pOut, Target.Position);

                    Vector3 pIn = Handles.PositionHandle(Target.HandleInPosition, Tools.handleRotation);
                    Handles.CubeCap(0, pIn, Quaternion.identity, HandleUtility.GetHandleSize(Target.HandleInPosition) * 0.1f);
                    Handles.DrawLine(pIn, Target.Position);

                    bool chgOut = Target.HandleOutPosition != pOut;
                    bool chgIn  = Target.HandleInPosition != pIn;

                    if (chgOut || chgIn)
                    {
#if OLD_UNDO
                        Undo.RegisterUndo(Target, "Move Handle");
#else
                        Undo.ClearUndo(Target);
                        Undo.RecordObject(Target, "Move Handle");
#endif
                        if (chgOut)
                        {
                            Target.HandleOutPosition = pOut;
                        }

                        if (chgIn)
                        {
                            Target.HandleInPosition = pIn;
                        }
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        Target.Spline.RefreshImmediately(true, true, false);
                        var lcons = Toolbar.GetItem <CurvyEditor.ToolbarItems.TBLengthConstraint>();
                        if (lcons.Enabled && Target.Spline.Length > lcons.MaxSplineLength)
                        {
                            Target.HandleOutPosition = handleOut;
                            Target.HandleInPosition  = handleIn;
                            Target.Spline.RefreshImmediately(true, true, false);
                        }
                    }
                }
            }
            Toolbar.Render();
        }
Exemplo n.º 3
0
        void OnSceneGUI()
        {
            Target._RemoveEmptySplines();
            for (int i = 0; i < Target.Count; i++)
            {
                Handles.Label(Target[i].Transform.position, i.ToString(), mLargeFont);
            }

            Toolbar.Render();
        }