コード例 #1
0
        //Inspector
        public override void OnInspectorGUI()
        {
            //Loop checkbox
            EditorGUI.BeginChangeCheck();
            bool loop = EditorGUILayout.Toggle("Loop", m_Spline.GetLoop());

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(m_Spline, "Toggle Loop");
                EditorUtility.SetDirty(m_Spline);
                m_Spline.SetLoop(loop);
            }

            //Add curve button
            if (m_SelectedIndex >= 0 && m_SelectedIndex < m_Spline.GetControlPointCount())
            {
                DrawSelectedPointInspector();
            }

            m_Spline = target as BezierSpline;
            if (GUILayout.Button("Add Curve"))
            {
                Undo.RecordObject(m_Spline, "Add Curve"); //Makes sure we can undo
                EditorUtility.SetDirty(m_Spline);         //Makes sure unity asks us to save after changing
                m_Spline.AddCurve();
            }
        }
コード例 #2
0
        //Scene
        private void OnSceneGUI()
        {
            m_Spline          = target as BezierSpline;
            m_HandleTransform = m_Spline.transform;
            m_HandleRotation  = Tools.pivotRotation == PivotRotation.Local ? m_HandleTransform.rotation : Quaternion.identity;

            //Show points
            Vector3 p0 = ShowPoint(0);

            for (int i = 1; i < m_Spline.GetControlPointCount(); i += 3)
            {
                Vector3 p1 = ShowPoint(i);
                Vector3 p2 = ShowPoint(i + 1);
                Vector3 p3 = ShowPoint(i + 2);

                //Draw the handle lines
                Handles.color = Color.gray;
                Handles.DrawLine(p0, p1); //p1 helps p0
                Handles.DrawLine(p2, p3); //p2 helps p3

                //Draw the bezier lines
                Handles.DrawBezier(p0, p3, p1, p2, Color.white, null, 3.0f);
                p0 = p3;
            }

            //Show the directions
            //ShowDirections();
        }
コード例 #3
0
        //Scene
        private void OnSceneGUI()
        {
            m_Spline = target as BezierSpline;
            m_HandleTransform = m_Spline.transform;
            m_HandleRotation = Tools.pivotRotation == PivotRotation.Local ? m_HandleTransform.rotation : Quaternion.identity;

            //Show points
            Vector3 p0 = ShowPoint(0);

            for (int i = 1; i < m_Spline.GetControlPointCount(); i += 3)
            {
                Vector3 p1 = ShowPoint(i);
                Vector3 p2 = ShowPoint(i + 1);
                Vector3 p3 = ShowPoint(i + 2);

                //Draw the handle lines
                Handles.color = Color.gray;
                Handles.DrawLine(p0, p1); //p1 helps p0
                Handles.DrawLine(p2, p3); //p2 helps p3

                //Draw the bezier lines
                Handles.DrawBezier(p0, p3, p1, p2, Color.white, null, 3.0f);
                p0 = p3;
            }

            //Show the directions
            //ShowDirections();
        }