private void DrawWeaponSlot(AnimationConfigOverride slot, int width, int height) { GUILayout.BeginVertical(UIUtil.BackgroundColor(0.3f, 0.3f, 0.3f), GUILayout.Width(width), GUILayout.Height(height)); DrawAnimationDropbox(slot); GUILayout.EndVertical(); }
public static bool DrawAnimaitonConfigEditor(AnimationConfigOverride selectedSlot) { bool isDirty = false; if (null != selectedSlot) { GUILayout.BeginVertical(EditorStyles.helpBox); if (selectedSlot.preset) { GUILayout.Label("Using Preset: " + selectedSlot.preset.name); } selectedSlot.Config.name = EditorGUILayout.TextField("Name", selectedSlot.Config.name); selectedSlot.Config.animation = (AnimationClip)EditorGUILayout.ObjectField("Animation", selectedSlot.Config.animation, typeof(AnimationClip), true); GUILayout.Label("Weights"); isDirty |= Slider( "Full Body", ref selectedSlot.Config.fullBody.layerWeight, 0f, 1f); isDirty |= Slider( "Upper Body", ref selectedSlot.Config.upperBody.layerWeight, 0f, 1f); isDirty |= Slider( "Lower Body", ref selectedSlot.Config.lowerBody.layerWeight, 0f, 1f); isDirty |= Slider( "Speed", ref selectedSlot.Config.speed, .1f, 2f); var value = EditorGUILayout.Toggle( "Mirror", selectedSlot.Config.mirror); if (value != selectedSlot.Config.mirror) { selectedSlot.Config.mirror = value; isDirty = true; } EditorGUILayout.EndVertical(); } return(isDirty); }
bool DrawAnimationDropbox(AnimationConfigOverride slot) { bool hasSlot = false; Rect myRect = GUILayoutUtility.GetRect(0, 0, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); GUIContent content = new GUIContent(slot.Config.animation ? slot.Config.animation.name : "Unassigned"); GUI.Box(myRect, content, UIUtil.BoxStyle); if (myRect.Contains(Event.current.mousePosition)) { if (Event.current.type == EventType.DragUpdated) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; Event.current.Use(); } else if (Event.current.type == EventType.DragPerform) { if (DragAndDrop.objectReferences.Length > 0) { object reference = DragAndDrop.objectReferences[0]; if (reference is AnimationClip) { slot.preset = null; slot.Config.animation = reference as AnimationClip; EditorUtility.SetDirty(config); } else if (reference is AnimationConfigPreset) { slot.preset = reference as AnimationConfigPreset; EditorUtility.SetDirty(config); } else if (reference is AudioClip) { var audio = reference as AudioClip; bool hasFile = false; var tags = slot.Config.soundTags; AnimationSoundTag[] newTags = new AnimationSoundTag[tags.Length + 1]; for (int i = 0; i < tags.Length; i++) { if (tags[i].sound.name == audio.name) { hasFile = true; } newTags[i] = tags[i]; } if (!hasFile) { newTags[tags.Length] = new AnimationSoundTag() { sound = audio }; slot.Config.soundTags = newTags; EditorUtility.SetDirty(config); } } } Event.current.Use(); } else if (Event.current.type == EventType.MouseDown) { Event.current.Use(); if (slot == selectedSlot) { selectedSlot = null; } else { if (null != selectedSlot) { onUnselectedSlot?.Invoke(slot); } selectedSlot = slot; onSelectedSlot?.Invoke(slot); } return(true); } } return(false); }