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; }
public void OnFrameEnabled(bool enabled) { Editor.CollisionBox currentCollision = CharacterEditor.Instance.CurrentCollision(); currentCollision.enabledFrames[CharacterEditor.Instance.SelectedFrame] = enabled; OnFrameChanged(); CharacterEditor.Instance.RefreshCollisions(); }
public void OnCopyButton() { Editor.CollisionBox currentCollision = CharacterEditor.Instance.GetCollisionBox(_collisionsList.SelectedItem); Editor.Box originalBox = currentCollision.boxesPerFrame[CharacterEditor.Instance.SelectedFrame]; copyFramesPanel.GetComponent <CopyFramesPanel>().Setup(originalBox, _collisionsList.SelectedItem, false); copyFramesPanel.SetActive(true); }
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(); }
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); }
public void OnBoxChanged() { Editor.CollisionBox currentCollision = CharacterEditor.Instance.GetCollisionBox(_collisionsList.SelectedItem); currentCollision.boxesPerFrame[CharacterEditor.Instance.SelectedFrame] = new Editor.Box(_boxPanel.GetPoint1(), _boxPanel.GetPoint2()); CharacterEditor.Instance.RefreshCollisions(); }