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();
        }
示例#2
0
        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();
        }
示例#3
0
 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);
         }
     }
 }
示例#4
0
        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);
        }
示例#5
0
        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);
                }
            }
        }
        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();
        }