Esempio n. 1
0
        public static SerializedProperty AddPoint(SerializedProperty aPath, Vector2 aPt, int aIndex = -1)
        {
            Path2D path = (Path2D)EditorTools.GetTargetObjectOfProperty(aPath);

            GetSelection(path).ids.Clear();

            SerializedProperty _points        = aPath.FindPropertyRelative("_points");
            SerializedProperty _pointControls = aPath.FindPropertyRelative("_pointControls");
            bool closed = aPath.FindPropertyRelative("_closed").boolValue;

            if (_points.arraySize == 0)
            {
                return(AddPoint(aPath, aPt, PointType.Sharp));
            }

            int segment = aIndex == -1 ? _points.arraySize - 1 : aIndex;
            SerializedProperty ctrlPrev = _pointControls.GetArrayElementAtIndex(PathUtil.WrapIndex(segment, _points.arraySize, closed));
            SerializedProperty ctrlNext = _pointControls.GetArrayElementAtIndex(PathUtil.WrapIndex(segment + 1, _points.arraySize, closed));

            return(AddPoint(aPath, aPt,
                            (PointType)ctrlPrev.FindPropertyRelative("type").enumValueIndex,
                            Mathf.Max(ctrlPrev.FindPropertyRelative("radius").floatValue, ctrlNext.FindPropertyRelative("radius").floatValue),
                            ctrlPrev.FindPropertyRelative("controlPrev").vector2Value,
                            ctrlPrev.FindPropertyRelative("controlNext").vector2Value, aIndex));
        }
Esempio n. 2
0
        public static void SetDirty(SerializedProperty aPath)
        {
            Path2D p = EditorTools.GetTargetObjectOfProperty(aPath) as Path2D;

            if (p != null)
            {
                p.SetDirty();
            }
        }
Esempio n. 3
0
        public static void OnSceneGUIEasy(SerializedProperty aPath, Path2D.Plane aPlane = Path2D.Plane.XY, PathSnap aSnapMode = PathSnap.Unity, float aSmartSnapDist = 0, PathEditorVisuals aVisuals = null)
        {
            SerializedObject obj = aPath.serializedObject;
            Transform        t   = ((Component)obj.targetObject).transform;
            Path2D           raw = EditorTools.GetTargetObjectOfProperty(aPath) as Path2D;

            OnSceneGUI(t.localToWorldMatrix, t.worldToLocalMatrix, aPath, raw, true, null, null, aPlane, aSnapMode, aSmartSnapDist, KeyCode.C, aVisuals);
            DoDragSelect(t.localToWorldMatrix, raw, new Rect(0, 0, Screen.width, Screen.height), aVisuals);
            obj.ApplyModifiedProperties();
        }