Ejemplo n.º 1
0
        void OnFrameChanged()
        {
            Editor.CharacterAnimation currentAnim = CharacterEditor.Instance.CurrentAnimation();
            if (currentAnim == null || currentAnim.hitBoxes.Count == 0)
            {
                _boxPanel.SetInteractible(false);
                _copyButton.interactable   = false;
                _typeDropdown.interactable = false;
                UpdateParameter();
                return;
            }
            Editor.HitBox currentHit = currentAnim.hitBoxes[CharacterEditor.Instance.SelectedHitId];
            int           frameId    = CharacterEditor.Instance.SelectedFrame;

            currentHit.EnsureBoxExists(frameId);
            Editor.Box currentBox = currentHit.boxesPerFrame[frameId];
            _enabledToggle.isOn = currentHit.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;
            _typeDropdown.interactable = true;
            UpdateParameter();
        }
Ejemplo 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();
        }