コード例 #1
0
        public static void MirrorTangent <T>(this PathEditorTool <T> pathEditorTool) where T : ScriptablePath
        {
            var targets = pathEditorTool.targets;

            foreach (var target in targets)
            {
                var path = pathEditorTool.GetPath(target);

                if (path.selection.Count == 0)
                {
                    continue;
                }

                path.undoObject.RegisterUndo("Mirror Tangents");

                for (var i = 0; i < path.pointCount; ++i)
                {
                    if (!path.selection.Contains(i))
                    {
                        continue;
                    }

                    path.MirrorTangent(i);
                }

                pathEditorTool.SetPath(target);
            }
        }
コード例 #2
0
        public static void CycleTangentMode <T>(this PathEditorTool <T> pathEditorTool) where T : ScriptablePath
        {
            var first       = true;
            var mixed       = false;
            var tangentMode = TangentMode.Linear;
            var targets     = pathEditorTool.targets;

            foreach (var target in targets)
            {
                var path = pathEditorTool.GetPath(target);

                if (path.selection.Count == 0)
                {
                    continue;
                }

                for (var i = 0; i < path.pointCount; ++i)
                {
                    if (!path.selection.Contains(i))
                    {
                        continue;
                    }

                    var point = path.GetPoint(i);

                    if (first)
                    {
                        first       = false;
                        tangentMode = point.tangentMode;
                    }
                    else if (point.tangentMode != tangentMode)
                    {
                        mixed = true;
                        break;
                    }
                }

                if (mixed)
                {
                    break;
                }
            }

            if (mixed)
            {
                tangentMode = TangentMode.Linear;
            }
            else
            {
                tangentMode = GetNextTangentMode(tangentMode);
            }

            foreach (var target in targets)
            {
                var path = pathEditorTool.GetPath(target);

                if (path.selection.Count == 0)
                {
                    continue;
                }

                path.undoObject.RegisterUndo("Cycle Tangent Mode");

                for (var i = 0; i < path.pointCount; ++i)
                {
                    if (!path.selection.Contains(i))
                    {
                        continue;
                    }

                    path.SetTangentMode(i, tangentMode);
                }

                pathEditorTool.SetPath(target);
            }
        }