public void Update() { Instance = this; InternalUiAnimationEditorSelection.Update(); if (InternalUiAnimationEditorSelection.TargetGameObject == null) { return; } if (InternalUiAnimationEditorSelection.TargetAnimation == null) { return; } InternalUiAnimationEditorPlayer.Update(); InternalUiAnimationEditorTimeline.Update(); InternalUiAnimationEditorCanvas.Update(); Repaint(); }
private void OnLostFocus() { InternalUiAnimationEditorPlayer.Stop(); }
private static void RenderMenu(float positionX, float positionY, float width, float height) { GUIStyle splitStyle = new GUIStyle(); splitStyle.fixedWidth = 1; splitStyle.fixedHeight = height; splitStyle.margin = new RectOffset(0, 0, 0, 0); splitStyle.normal.background = InternalUiAnimationEditorTextures.ColorBlack20; GUIStyle dropdownStyle = new GUIStyle(new GUIStyle(GUI.skin.GetStyle("Popup"))); dropdownStyle.fixedHeight = height; dropdownStyle.margin = new RectOffset(0, 0, 0, 0); dropdownStyle.normal.background = InternalUiAnimationEditorTextures.ColorInvisible; dropdownStyle.hover.background = InternalUiAnimationEditorTextures.ColorBlack10; dropdownStyle.active.background = InternalUiAnimationEditorTextures.ColorBlack20; dropdownStyle.focused.background = InternalUiAnimationEditorTextures.ColorInvisible; GUIStyle buttonStyle = new GUIStyle(new GUIStyle(GUI.skin.GetStyle("Button"))); buttonStyle.fixedWidth = height; buttonStyle.fixedHeight = height; buttonStyle.normal.background = InternalUiAnimationEditorTextures.ColorInvisible; buttonStyle.hover.background = InternalUiAnimationEditorTextures.ColorBlack10; buttonStyle.active.background = InternalUiAnimationEditorTextures.ColorBlack20; buttonStyle.margin = new RectOffset(0, 0, 0, 0); buttonStyle.padding = new RectOffset(0, 0, 0, 0); GUILayout.BeginArea(new Rect(positionX, positionY, width - 0, height), new GUIStyle()); GUILayout.BeginHorizontal(); // Play button if (InternalUiAnimationEditorPlayer.Activated) { Texture2D icon = new Texture2D(8, 8); Color color = new Color(0.22f, 0.22f, 0.22f, 1); for (int x = 0; x < icon.width; x++) { for (int y = 0; y < icon.height; y++) { icon.SetPixel(x, y, color); } } icon.Apply(); InternalUiAnimationEditorGUI.Button ( icon, buttonStyle, () => { InternalUiAnimationEditorPlayer.Stop(); } ); GUILayout.Box(string.Empty, splitStyle); } else { InternalUiAnimationEditorGUI.Button ( EditorGUIUtility.IconContent("Animation.Play").image, buttonStyle, () => { InternalUiAnimationEditorPlayer.Play(); } ); GUILayout.Box(string.Empty, splitStyle); } // Active timeline popup InternalUiAnimationEditorGUI.Popup ( InternalUiAnimationEditorSelection.TargetAnimationClipIndex, InternalUiAnimationEditorSelection.GetAnimationClipsNames(), dropdownStyle, (int value) => { GUI.FocusControl(string.Empty); InternalUiAnimationEditorSelection.SetTargetAnimationClipIndex(value); } ); GUILayout.Box(string.Empty, splitStyle); // Add timeline button InternalUiAnimationEditorGUI.Button ( EditorGUIUtility.IconContent("Toolbar Plus").image, buttonStyle, () => { if (InternalUiAnimationEditorSelection.TargetAnimation != null) { UiAnimationClip timeline = new UiAnimationClip(); timeline.Name = "New Timeline " + InternalUiAnimationEditorSelection.TargetAnimation.AnimationClips.Count; InternalUiAnimationEditorSelection.TargetAnimation.AnimationClips.Add(timeline); InternalUiAnimationEditorSelection.SetTargetAnimationClipIndex(InternalUiAnimationEditorSelection.TargetAnimation.AnimationClips.IndexOf(timeline)); } } ); GUILayout.Box(string.Empty, splitStyle); // Remove timeline button InternalUiAnimationEditorGUI.Button ( EditorGUIUtility.IconContent("Toolbar Minus").image, buttonStyle, () => { if (InternalUiAnimationEditorSelection.TargetAnimation != null) { if (InternalUiAnimationEditorSelection.TargetAnimation.AnimationClips.Count > 1) { if (EditorUtility.DisplayDialog("Error", "Are you sure you want to delete " + InternalUiAnimationEditorSelection.TargetAnimationClip.Name + "?", "Yes", "No")) { InternalUiAnimationEditorSelection.TargetAnimation.AnimationClips.RemoveAt(InternalUiAnimationEditorSelection.TargetAnimationClipIndex); InternalUiAnimationEditorSelection.SetTargetAnimationClipIndex(0); } } else { EditorUtility.DisplayDialog("Error", "You can not delete last timeline.", "OK"); } } } ); GUILayout.Box(string.Empty, splitStyle); // Dropdown icon Texture dropdownIcon = EditorGUIUtility.IconContent("Icon Dropdown").image; InternalUiAnimationEditorGUI.DrawTexture(width - 60, positionY + 9, dropdownIcon.width, dropdownIcon.height, dropdownIcon); GUILayout.EndHorizontal(); GUILayout.EndArea(); }