コード例 #1
0
        public void SetButtonsPositionOnCurve()
        {
            if (snapButtonsToCurve)
            {
                if (!curve)
                {
                    curve = GetComponent <CatmulRommSpline_1>();
                }
                if (!curve)
                {
                    return;
                }
                if (levelButtons == null)
                {
                    return;
                }

                pos = curve.GetPositions(levelButtons.Count);
                if (levelButtons.Count > 0)
                {
                    for (int i = 0; i < levelButtons.Count; i++)
                    {
                        if (levelButtons[i])
                        {
                            levelButtons[i].transform.position = transform.TransformPoint(pos[i]);                  //  if(levelButtons[i])  levelButtons[i].transform.position =pos[i];
                        }
                    }
                }
            }
        }
コード例 #2
0
 private void ShowControlPoints()
 {
     curve = target as CatmulRommSpline_1;
     for (int i = 0; i < curve.Count; i++)
     {
         ShowControlPoint(i);
     }
 }
コード例 #3
0
 void OnDisable()
 {
     curve = target as CatmulRommSpline_1;
     if (curve)
     {
         curve.Selected = false;
     }
 }
コード例 #4
0
 void OnEnable()
 {
     curve = target as CatmulRommSpline_1;
     if (curve)
     {
         curve.Selected = true;
     }
 }
コード例 #5
0
        private void OnSceneGUI()
        {
            curve           = target as CatmulRommSpline_1;
            handleTransform = curve.transform;
            handleRotation  = (Tools.pivotRotation == PivotRotation.Local) ? handleTransform.rotation : Quaternion.identity;

            ShowControlPoints();
            Handles.color = Color.gray;
            ShowPivot();
        }
コード例 #6
0
        public override void OnInspectorGUI()
        {
            //   DrawDefaultInspector();
            curve = target as CatmulRommSpline_1;
            if (!curve)
            {
                return;
            }
            if (selectedIndex >= 0 && selectedIndex < curve.handlesPositions.Count - 1)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Press to add or remove curve control point.");

                if (GUILayout.Button("Add Point"))
                {
                    Undo.RecordObject(curve, "Add Point");
                    EditorUtility.SetDirty(curve);
                    curve.AddPoint(selectedIndex);
                    curve.OnChangeSpline();
                }

                if (curve.Count > 3)
                {
                    if (GUILayout.Button("Remove Point"))
                    {
                        Undo.RecordObject(curve, "Remove Point");
                        EditorUtility.SetDirty(curve);
                        curve.RemovePoint(selectedIndex);
                        curve.OnChangeSpline();
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            if (selectedIndex >= 0 && selectedIndex < curve.handlesPositions.Count)
            {
                DrawSelectedPointInspector();
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Select curve control point for curve edit.");
                EditorGUILayout.EndHorizontal();
            }
        }