CharacterMotionData CreateMotionDataObject(HitboxAnimation hitbox) { CharacterMotionData res = new CharacterMotionData(); res.motionName = hitbox.clip.name; Debug.Log($"res.motionName: {res.motionName}"); res.frameData = hitbox.frameData .Select(x => new CharacterMotionFrame() { collider = x.collider, events = x.events, }).ToArray(); var curves = AnimationUtility.GetObjectReferenceCurveBindings(hitbox.clip); foreach (var item in curves) { if (item.propertyName != "m_Sprite") { continue; } string[] imageNames = AnimationUtility.GetObjectReferenceCurve(hitbox.clip, item) .Select(x => x.value.ToString().Replace(" (UnityEngine.Sprite)", "")) .ToArray(); for (int i = 0; i < res.frameData.Length; i++) { res.frameData[i].imageName = imageNames[i]; } } return(res); }
public internalFrameData(HitboxAnimation source, int frameID) { frame = source.frameData[frameID]; hasnextframe = ((frameID + 1) < source.frameData.Length); framerate = (source.clip != null) ? source.clip.frameRate : 0f; }
public override void OnInspectorGUI() { if (Application.isPlaying) { GUILayout.Label("Cannot edit animations while the game is running.", EditorStyles.miniTextField); return; } UpdateSerializedObject(); // HitboxManager m_Target = (HitboxManager)target; SerializedProperty Animations = m_targetObject.FindProperty(nameof(m_targetManager.m_Animations)); EditorGUILayout.BeginVertical(); RefreshAnimationOptionLabels(); GUIAddNewAnimationButton(m_targetManager, Animations); GUIAddFromAttachedAnimatorButton(Animations); // GUIRemoveCurrentAnimationButton(m_targetManager, Animations); ResetEditorColors(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); GUISelectAnimationToEditPopup(); EditorGUILayout.Separator(); if (SelectedAnimation < Animations.arraySize) { SerializedProperty HitboxData = Animations.GetArrayElementAtIndex(SelectedAnimation); HitboxAnimation selectedAnimation = m_targetManager.m_Animations[SelectedAnimation]; if (HitboxData != null) { var clip = HitboxData.FindPropertyRelative(nameof(selectedAnimation.clip)); var framedata = HitboxData.FindPropertyRelative(nameof(selectedAnimation.frameData)); var oldclip = clip.objectReferenceValue; GUIAnimationSettingsLayout(HitboxData, clip); // GUIAttackDataLayout(HitboxData); GUIFrameDataLayout(m_targetManager, clip, framedata, oldclip); } } EditorGUILayout.EndVertical(); var maxHitboxes = 1; if (this.Animations != null) { for (int i = 0; i < this.Animations.Length; i++) { if (this.Animations[i].frameData != null) { for (int j = 0; j < this.Animations[i].frameData.Length; j++) { if (this.Animations[i].frameData[j].collider != null) { maxHitboxes = Mathf.Max(maxHitboxes, this.Animations[i].frameData[j].collider.Length); } } } } } m_targetObject.FindProperty(nameof(m_targetManager.m_MaxHitboxes)).intValue = maxHitboxes; ApplySerializedProperties(); if (Event.current.type != EventType.Repaint && Event.current.type != EventType.MouseMove && Event.current.type != EventType.Layout) { Profiler.BeginSample("Hitbox Inspector: Bake Animation"); if (SelectedAnimation < Animations.arraySize) { m_targetManager.BakeAnimation(SelectedAnimation); } //m_Target.BakeAnimations(); Profiler.EndSample(); } UpdatePreview(); EditorGUI.indentLevel = 0; }