Exemplo n.º 1
0
        private static void GroupSelected()
        {
            if (!Selection.activeTransform)
            {
                return;
            }
            var go = new GameObject(Selection.activeTransform.name + " Group");

            Undo.RegisterCreatedObjectUndo(go, "Group Selected");
            go.transform.SetParent(Selection.activeTransform.parent, false);

            //position parent in middle of group
            Vector3[] positions = new Vector3[Selection.transforms.Length];
            for (var i = 0; i < Selection.transforms.Length; i++)
            {
                positions[i] = Selection.transforms[i].position;
            }

            go.transform.position = DookTools.GetMeanVector(positions);

            //parent
            foreach (var transform in Selection.transforms)
            {
                Undo.SetTransformParent(transform, go.transform, "Group Selected");
            }

            Selection.activeGameObject = go;
        }
Exemplo n.º 2
0
    public void UseMove(int moveIndex)
    {
        //Check if performing move
        if (IsPerformingMove())
        {
            return;
        }

        Move m = Moves[moveIndex];

        m.Init(); //Init the move if cooldown is good
        _isPerformingMove = moveIndex;

        //Reset isPerforming after animation has finished
        //Assumes the animation name is the same as the trigger name
        if (m.AnimationTriggerName != "" || !m.fireImmediate)
        {
            var resetTime = 1f;
            if (myAnim)
            {
                resetTime = DookTools.GetAnimationLength(myAnim, m.AnimationTriggerName);
            }
            Debug.Assert(resetTime > 0, "Couldn't find clip in animator, you probably have the wrong " +
                         "AnimationTriggerName on the move prefab");
            Invoke("ResetMove", resetTime);
        }
        else
        {
            ResetMove();
        }
    }