void DrawAnimationClip(int index, AnimationClipEvents animationClipEvents) { GUILayout.BeginHorizontal(); { DrawRemoveAnimationClipButton(index); DrawAnimationClipControlButton(index, animationClipEvents); } GUILayout.EndHorizontal(); }
void DrawAnimationClipControlButton(int index, AnimationClipEvents animationClipEvents) { string buttonName = "Don't have AnimationClip"; Color defaultColor = GUI.color; if (animationClipEvents.AnimationClip == null) { GUI.color = Color.red; } else if (EditorWindowInfo.Selector.AnimationClipEvents == animationClipEvents) { buttonName = animationClipEvents.AnimationClip.name; GUI.color = Color.green; } else { buttonName = animationClipEvents.AnimationClip.name; GUI.color = defaultColor; } if (GUILayout.Button(buttonName)) { if (EditorWindowInfo.IsPlaying) { if (animationClipEvents.AnimationClip != null) { EditorWindowInfo.StopAnimation(); } } else { EditorWindowInfo.StopAnimation(); } EditorWindowInfo.Selector.AnimationClipEvents = animationClipEvents; } GUI.color = defaultColor; }