Exemplo n.º 1
0
        void OnFrameChanged()
        {
            Editor.CharacterAnimation currentAnim = CharacterEditor.Instance.CurrentAnimation();
            if (currentAnim == null || currentAnim.collisionBoxes.Count == 0)
            {
                _boxPanel.SetInteractible(false);
                _copyButton.interactable = false;
                return;
            }
            Editor.CollisionBox currentCollision = currentAnim.collisionBoxes[CharacterEditor.Instance.SelectedCollisionId];
            int frameId = CharacterEditor.Instance.SelectedFrame;

            currentCollision.EnsureBoxExists(frameId);
            Editor.Box currentBox = currentCollision.boxesPerFrame[frameId];
            _enabledToggle.isOn = currentCollision.enabledFrames[frameId];
            if (currentBox != null)
            {
                if (!(currentBox.pointOne.Equals(FixedVector3.Zero) && currentBox.pointTwo.Equals(FixedVector3.Zero)))
                {
                    _boxPanel.SetPoints(currentBox.pointOne, currentBox.pointTwo);
                }
                else if (_enabledToggle.isOn)
                {
                    OnBoxChanged();
                }
            }
            _boxPanel.SetInteractible(_enabledToggle.isOn);
            _copyButton.interactable = _enabledToggle.isOn;
        }
Exemplo n.º 2
0
        public void OnCopyButton()
        {
            string text = _inputField.text;

            text = text.Replace(" ", string.Empty);
            char[]   separators = { ',' };
            string[] components = text.Split(separators);

            separators[0] = '-';
            string[]          subComponents;
            List <Editor.Box> boxes;
            List <bool>       enablings;

            if (isHitFrame)
            {
                Editor.HitBox hitBox = CharacterEditor.Instance.GetHitBox(listId);
                hitBox.EnsureBoxExists(CharacterEditor.Instance.CurrentAnimation().numFrames - 1);
                boxes     = hitBox.boxesPerFrame;
                enablings = hitBox.enabledFrames;
            }
            else
            {
                Editor.CollisionBox collisionBox = CharacterEditor.Instance.GetCollisionBox(listId);
                collisionBox.EnsureBoxExists(CharacterEditor.Instance.CurrentAnimation().numFrames - 1);
                boxes     = collisionBox.boxesPerFrame;
                enablings = collisionBox.enabledFrames;
            }

            foreach (string component in components)
            {
                subComponents = component.Split(separators);
                if (subComponents.Length == 2)
                {
                    int first;
                    int last;
                    if (int.TryParse(subComponents[0], out first) && int.TryParse(subComponents[1], out last))
                    {
                        first = Mathf.Clamp(first, 1, boxes.Count);
                        last  = Mathf.Clamp(last, first, boxes.Count);
                        PopulateList(first - 1, last - 1, boxes, enablings);
                    }
                }
                else
                {
                    int frameId;
                    if (int.TryParse(component, out frameId))
                    {
                        frameId = Mathf.Clamp(frameId, 1, boxes.Count);
                        SetBox(frameId - 1, boxes, enablings);
                    }
                }
            }

            Close();
        }
Exemplo n.º 3
0
 public CollisionBox GetCollisionBox(int collisionId)
 {
     Editor.CharacterAnimation currentAnim = CurrentAnimation();
     if (currentAnim == null || collisionId >= currentAnim.collisionBoxes.Count)
     {
         return(null);
     }
     Editor.CollisionBox currentCollision = currentAnim.collisionBoxes[collisionId];
     currentCollision.EnsureBoxExists(selectedFrame);
     return(currentCollision);
 }