public static void Render(float positionX, float positionY, float width, float height) { InternalUiAnimationEditorGUI.DrawTexture(positionX + width - 1, positionY, 1, height, InternalUiAnimationEditorTextures.ColorBlack20); GUIStyle labelStyle = new GUIStyle(GUI.skin.GetStyle("Label")); labelStyle.fixedWidth = 130; GUILayout.BeginArea(new Rect(positionX, positionY, width - 2, height), new GUIStyle()); GUILayout.Space(5); GUILayout.Label("Animation Clip Settings"); GUILayout.BeginVertical(new GUIStyle(GUI.skin.GetStyle("HelpBox"))); GUILayout.Space(2); RenderAnimationClip(InternalUiAnimationEditorSelection.TargetAnimationClip); GUILayout.Space(2); GUILayout.EndVertical(); if (InternalUiAnimationEditorSelection.CanvasItemToEdit != null) { GUILayout.Space(5); GUILayout.Label("Segment Settings"); GUILayout.BeginVertical(new GUIStyle(GUI.skin.GetStyle("HelpBox"))); GUILayout.Space(2); RenderAnimationClipSegment(InternalUiAnimationEditorSelection.CanvasItemToEdit.Target); GUILayout.Space(2); GUILayout.EndVertical(); } GUILayout.EndArea(); }
public void Render() { if (Target.Predefined && Delay > 0) { float size = Delay * InternalUiAnimationEditorTimeline.SegmentWidth * 10; InternalUiAnimationEditorGUI.DrawTexture ( X - size, Y, size, Height, InternalUiAnimationEditorTextures.GenerateCanvasItemBackground ( (int)size, (int)Height, Target.ItemType, Target.EasingType, true ) ); } InternalUiAnimationEditorGUI.DrawTexture(X, Y, Width, Height, InternalUiAnimationEditorTextures.GenerateCanvasItemBackground((int)Width, (int)Height, Target.ItemType, Target.EasingType)); if (InternalUiAnimationEditorSelection.CanvasItemToEdit == this) { InternalUiAnimationEditorGUI.DrawTexture(X, Y, Width, Height, InternalUiAnimationEditorTextures.ColorWhite20); } GUILayout.BeginArea(new Rect(Mathf.Round(X) + 5, Mathf.Round(Y) + 3, Mathf.Round(Width) - 10, Mathf.Round(Height) - 3)); if (Target != null && Target.GameObject != null) { GUIStyle labelStyle = new GUIStyle(GUI.skin.GetStyle("Label")); if (IsCollided) { labelStyle.normal.textColor = Color.red; //IsCollided = false; } GUILayout.Label(Target.GameObject.name + " " + Target.ItemType.ToString(), labelStyle); } else { GUIStyle labelStyle = new GUIStyle(GUI.skin.GetStyle("Label")); labelStyle.normal.textColor = Color.red; GUILayout.Label("Missed", labelStyle); } GUILayout.EndArea(); }
private static void RenderLayers(float positionX, float positionY, float width, float height) { for (int i = 0; i < 30; i++) { if (i % 2 == 0) { InternalUiAnimationEditorGUI.DrawTexture(positionX, positionY + i * LayerHeight, width, LayerHeight, InternalUiAnimationEditorTextures.ColorBlack10); } else { InternalUiAnimationEditorGUI.DrawTexture(positionX, positionY + i * LayerHeight, width, LayerHeight, InternalUiAnimationEditorTextures.ColorBlack20); } } }
private static void RenderCursor(float positionX, float positionY, float width, float height) { float x = GetTimeByMousePosition(InternalUiAnimationEditor.MousePosition.x); float y = GetLayerByMousePosition(InternalUiAnimationEditor.MousePosition.y); x = positionX + x * InternalUiAnimationEditorTimeline.SegmentWidth * 10; y = positionY + y * LayerHeight; float sizex = InternalUiAnimationEditorTimeline.SegmentWidth * 10 * 0.5f; float sizey = LayerHeight; InternalUiAnimationEditorGUI.DrawTexture(x, y, sizex, 1, InternalUiAnimationEditorTextures.ColorWhite100); InternalUiAnimationEditorGUI.DrawTexture(x, y + sizey - 1, sizex, 1, InternalUiAnimationEditorTextures.ColorWhite100); InternalUiAnimationEditorGUI.DrawTexture(x, y, 1, sizey, InternalUiAnimationEditorTextures.ColorWhite100); InternalUiAnimationEditorGUI.DrawTexture(x + sizex - 1, y, 1, sizey, InternalUiAnimationEditorTextures.ColorWhite100); }
public static void Render(float positionX, float positionY, float width, float height) { if (Items.Count <= 0) { RenderPlayMode(); return; } RenderLayers(positionX, positionY, width, height); for (int i = 0; i < Items.Count; i++) { Items[i].Render(); if (InternalUiAnimationEditorSelection.CanvasItemToDrag == null && InternalUiAnimationEditorSelection.CanvasItemToResize == null) { Items[i].SetCursor(); } } if (InternalUiAnimationEditorSelection.CanvasItemToDrag != null) { EditorGUIUtility.AddCursorRect(new Rect(0, 0, InternalUiAnimationEditor.WindowWidth, InternalUiAnimationEditor.WindowHeight), MouseCursor.MoveArrow); } if (InternalUiAnimationEditorSelection.CanvasItemToResize != null) { EditorGUIUtility.AddCursorRect(new Rect(0, 0, InternalUiAnimationEditor.WindowWidth, InternalUiAnimationEditor.WindowHeight), MouseCursor.ResizeHorizontal); } if (InternalUiAnimationEditorPlayer.Activated) { float playerPosition = InternalUiAnimationEditorPlayer.Time * InternalUiAnimationEditorTimeline.SegmentWidth * 10; InternalUiAnimationEditorGUI.DrawTexture(positionX + playerPosition, positionY, 1, height, InternalUiAnimationEditorTextures.ColorBlack100); } if (InternalUiAnimationEditor.MouseDragFromScene) { if (InternalUiAnimationEditor.MousePosition.x > positionX && InternalUiAnimationEditor.MousePosition.y > positionY) { RenderCursor(positionX, positionY, width, height); } } }
private void RenderNoComponent() { GUIStyle labelStyle = new GUIStyle(GUI.skin.GetStyle("Label")); labelStyle.alignment = TextAnchor.UpperCenter; GUILayout.BeginArea(new Rect(WindowWidth / 2 / 2, (WindowHeight - 50) / 2, WindowWidth / 2, 50)); GUILayout.Label("To begin animating " + InternalUiAnimationEditorSelection.TargetGameObject.name + ", create UiTweener.", labelStyle); GUILayout.EndArea(); GUILayout.BeginArea(new Rect((WindowWidth - 120) / 2, (WindowHeight - 50) / 2 + 20, 120, 50)); InternalUiAnimationEditorGUI.Button ( "Create", () => { InternalUiAnimationEditorSelection.TargetGameObject.AddComponent <UiAnimation>(); } ); GUILayout.EndArea(); }
public static void Render(float positionX, float positionY, float width, float height) { InternalUiAnimationEditorGUI.DrawTexture(0, positionY, InternalUiAnimationEditor.WindowWidth, height, InternalUiAnimationEditorTextures.ColorWhite20); InternalUiAnimationEditorGUI.DrawTexture(0, positionY + height - 2, InternalUiAnimationEditor.WindowWidth, 1, InternalUiAnimationEditorTextures.ColorWhite20); InternalUiAnimationEditorGUI.DrawTexture(0, positionY + height - 1, InternalUiAnimationEditor.WindowWidth, 1, InternalUiAnimationEditorTextures.ColorBlack20); RenderMenu(0, 0, InternalUiAnimationEditorInspector.Width, height); GUIStyle labelStyle = new GUIStyle(); labelStyle.normal.textColor = new Color(0, 0, 0, 0.5f); labelStyle.fontSize = 10; float seconds = 0; float milliseconds = 0; for (int i = 0; i < SegmentsCount; i++) { float sizex = SegmentWidth; float sizey = height; float x = positionX + i * sizex; float y = positionY; bool expanded = false; if (sizex > 40) { expanded = true; } else if (sizex > 30) { expanded = i % 2 == 0; } else if (sizex > 20) { expanded = i % 5 == 0; } else if (sizex > 10) { expanded = i % 10 == 0; } else { expanded = i % 20 == 0; } if (expanded) { GUI.Label(new Rect(x + 3, y + height - 18, 100, height), seconds + ":" + Mathf.Round(milliseconds * 100).ToLeadingZerosString(2), labelStyle); if (i > 0) { InternalUiAnimationEditorGUI.DrawTexture(x, y + sizey - 10, 1, 10, InternalUiAnimationEditorTextures.ColorBlack100); } } else { InternalUiAnimationEditorGUI.DrawTexture(x, y + sizey - 4, 1, 4, InternalUiAnimationEditorTextures.ColorBlack100); } milliseconds += 0.1f; while (milliseconds >= 1) { milliseconds -= 1; seconds += 1; } } }
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(); }
private static void RenderAnimationClip(UiAnimationClip clip) { clip.Name = InternalUiAnimationEditorGUI.InspectorTextField ( "Name", clip.Name ); clip.Loop = InternalUiAnimationEditorGUI.InspectorBooleanField ( new GUIContent("Loop animation"), clip.Loop ); List <string> triggers = new List <string>(); if (clip.PlayOnAwake) { triggers.Add("Awake"); } if (clip.PlayOnLayoutElementShow) { triggers.Add("Element Show"); } if (clip.PlayOnLayoutElementHide) { triggers.Add("Element Hide"); } if (clip.PlayOnSignals.Length > 0) { triggers.Add("Signals"); } string playon = ""; if (triggers.Count > 1) { playon += " " + triggers.Count + " triggers"; } else if (triggers.Count > 0) { playon += " " + triggers[0]; } else { playon = " ..."; } _expandPlayOnBlock = EditorGUILayout.Foldout(_expandPlayOnBlock, "Play on" + playon, true); if (_expandPlayOnBlock) { clip.PlayOnAwake = InternalUiAnimationEditorGUI.InspectorBooleanField ( new GUIContent(" Awake"), clip.PlayOnAwake ); clip.PlayOnLayoutElementShow = InternalUiAnimationEditorGUI.InspectorBooleanField ( new GUIContent(" Element show"), clip.PlayOnLayoutElementShow ); clip.PlayOnLayoutElementHide = InternalUiAnimationEditorGUI.InspectorBooleanField ( new GUIContent(" Element hide"), clip.PlayOnLayoutElementHide ); InternalLayout.ButtonSignals ( " Signals", "Select signals to play animation clip", clip.PlayOnSignals, (string[] result) => { clip.PlayOnSignals = result; }, 15 ); } }
private static void RenderAnimationClipSegment(UiAnimationClipSegment segment) { if (segment.GameObject == null) { EditorGUILayout.HelpBox("Game object is missed! Setup another game object or delete this segment.", MessageType.Error); } segment.GameObject = InternalUiAnimationEditorGUI.InspectorObjectField ( "Game Object", segment.GameObject ); if (segment.GameObject != null) { segment.ItemType = (UiAnimationClipSegmentType)InternalUiAnimationEditorGUI.InspectorEnumPopup ( "Type", segment.ItemType, () => { RectTransform rectTransform = segment.GameObject.GetComponent <RectTransform>(); if (rectTransform != null) { segment.PositionFrom = new Vector2(rectTransform.anchoredPosition.x, rectTransform.anchoredPosition.y); segment.PositionTo = new Vector2(rectTransform.anchoredPosition.x, rectTransform.anchoredPosition.y); segment.RotationFrom = rectTransform.localRotation.eulerAngles.z; segment.RotationTo = rectTransform.localRotation.eulerAngles.z; segment.ScaleFrom = new Vector2(rectTransform.localScale.x, rectTransform.localScale.y); segment.ScaleTo = new Vector2(rectTransform.localScale.x, rectTransform.localScale.y); } } ); segment.EasingType = (EasingType)InternalUiAnimationEditorGUI.InspectorEnumPopup ( "Easing type", segment.EasingType ); switch (segment.ItemType) { case UiAnimationClipSegmentType.Alpha: segment.AlphaFrom = InternalUiAnimationEditorGUI.InspectorFloatField("Alpha From", segment.AlphaFrom); segment.AlphaTo = InternalUiAnimationEditorGUI.InspectorFloatField("Alpha To", segment.AlphaTo); break; case UiAnimationClipSegmentType.Color: segment.ColorFrom = InternalUiAnimationEditorGUI.InspectorColorField("Color From", segment.ColorFrom); segment.ColorTo = InternalUiAnimationEditorGUI.InspectorColorField("Color To", segment.ColorTo); break; case UiAnimationClipSegmentType.Position: segment.PositionFrom = InternalUiAnimationEditorGUI.InspectorVector2Field("Position From XY", segment.PositionFrom); segment.PositionTo = InternalUiAnimationEditorGUI.InspectorVector2Field("Position To XY", segment.PositionTo); break; case UiAnimationClipSegmentType.Rotation: segment.RotationFrom = InternalUiAnimationEditorGUI.InspectorFloatField("Rotation From", segment.RotationFrom); segment.RotationTo = InternalUiAnimationEditorGUI.InspectorFloatField("Rotation To", segment.RotationTo); break; case UiAnimationClipSegmentType.Scale: segment.ScaleFrom = InternalUiAnimationEditorGUI.InspectorVector2Field("Scale From XY", segment.ScaleFrom); segment.ScaleTo = InternalUiAnimationEditorGUI.InspectorVector2Field("Scale To XY", segment.ScaleTo); break; } segment.Predefined = InternalUiAnimationEditorGUI.InspectorBooleanField ( new GUIContent("Predefined", "Use From value as predefined value for " + segment.GameObject.name), segment.Predefined ); /* * UtilityReflection.SetMemberValue * ( * segment, "Predefined", * segment.Predefined = InternalUiAnimationEditorGUI.InspectorBooleanField * ( * new GUIContent("Predefined", "Use From value as predefined value for " + segment.GameObject.name), * (bool)UtilityReflection.GetMemberValue(segment, "Predefined") * ) * ); */ } GUIStyle buttonStyle = new GUIStyle(GUI.skin.GetStyle("Button")); buttonStyle.margin.left = 138; buttonStyle.margin.top = 5; EditorGUI.BeginChangeCheck(); GUILayout.Button("Delete segment", buttonStyle); if (EditorGUI.EndChangeCheck()) { InternalUiAnimationEditorSelection.TargetAnimationClip.Items.Remove(segment); InternalUiAnimationEditorSelection.TargetAnimationClip.Items.Sort((a, b) => (a.Delay.CompareTo(b.Delay))); InternalUiAnimationEditorSelection.SetCanvasItemToEdit(null); } }