Ejemplo n.º 1
0
 /// <summary>Controll item (only one) manualy</summary>
 /// <param name="value">time between 0 and 1</param>
 /// <param name="direction">use tween with specified direction</param>
 public void Evaluate(float value, ItemKey direction)
 {
     TSSItemBase.Evaluate(this, value, direction);
 }
Ejemplo n.º 2
0
        private void DrawItemOnTimeLine(TSSItem item, Vector2 position)
        {
            position.y = controlLineHeight + itemCount * (itemHeight + itemLineSpacing);

            if (item.parent != null && ItemChildBefore(item.parent))
            {
                position.x -= (ItemDelay(item.parent) - ItemDelay(item)) / GetPeriod() * timeLineRect.width;
            }
            else
            {
                position.x += ItemDelay(item) / GetPeriod() * timeLineRect.width;
            }

            bool itemChained   = (item.parent != null && item.parent.childChainMode);
            Rect itemRect      = new Rect(position.x, position.y, timeLineRect.width * ItemDuration(item) / GetPeriod(), itemHeight);
            Rect itemTitleRect = new Rect(itemRect.x + (itemChained ? 24 : 12), itemRect.y + itemRect.height * 0.5f - 6, itemRect.width - 24, 24);


            if (selectedItem == item)
            {
                if (!itemChained)
                {
                    EditorGUIUtility.AddCursorRect(new Rect(itemRect.x - itemHandleSize, itemRect.y, itemHandleSize * 2, itemHeight), MouseCursor.ResizeHorizontal);
                }
                EditorGUIUtility.AddCursorRect(new Rect(itemRect.x + itemHandleSize, itemRect.y, itemRect.width - itemHandleSize * 2, itemHeight), MouseCursor.SlideArrow);

                EditorGUIUtility.AddCursorRect(new Rect(itemRect.x + itemRect.width - itemHandleSize, itemRect.y, itemHandleSize * 2, itemHeight), MouseCursor.ResizeHorizontal);
            }
            else
            {
                EditorGUIUtility.AddCursorRect(itemRect, MouseCursor.Link);
            }

            if (boolMousePressed && new Rect(itemRect.x - itemHandleSize, itemRect.y, itemRect.width + itemHandleSize * 2, itemRect.height).Contains(mousePosition))
            {
                selectedItem     = item;
                selectedItemRect = itemRect;
                boolMousePressed = false;

                controlLineSelectionPosition = itemRect.x;
                controlLineSelectionSize     = itemRect.width;

                Selection.SetActiveObjectWithContext(item.gameObject, item);
                Undo.RegisterCompleteObjectUndo(item, "[TSS TimeLine]");
            }

            lastBackColor = !lastBackColor;
            if (!lastBackColor)
            {
                EditorGUI.DrawRect(new Rect(timeLineRect.x, itemRect.y - itemLineSpacing, timeLineRect.width, itemHeight + itemLineSpacing), new Color(0, 0, 0, 0.125f));
            }

            float itemEffectsValue = 0;

            if (itemRect.x > controlLineHandlerPosition)
            {
                itemEffectsValue = 0;
            }
            else if (itemRect.x + itemRect.width < controlLineHandlerPosition)
            {
                itemEffectsValue = 1;
            }
            else
            {
                itemEffectsValue = (controlLineHandlerPosition - itemRect.x) / itemRect.width;
            }

            if (direction == ItemKey.closed)
            {
                itemEffectsValue = 1 - itemEffectsValue;
            }


            if ((controlLineHandlerSelected || timeLinePlaying) && item.tweens.Count > 0)
            {
                item.state = ItemState.slave;

                if (mode == Mode.openClode)
                {
                    if (direction == ItemKey.closed && controlLineHandlerPosition > timeLineRect.width)
                    {
                        TSSItemBase.Evaluate(item, Mathf.Clamp01(itemEffectsValue), ItemKey.closed);
                    }
                    if (direction == ItemKey.opened && controlLineHandlerPosition < timeLineRect.width)
                    {
                        TSSItemBase.Evaluate(item, Mathf.Clamp01(itemEffectsValue), ItemKey.opened);
                    }
                }
                else
                {
                    TSSItemBase.Evaluate(item, Mathf.Clamp01(itemEffectsValue), direction);
                }
            }


            GUI.Box(itemRect, string.Empty, item == selectedItem ? itemSelectedStyle : (itemChained ? itemChainStyle : itemStyle));
            GUI.Label(itemTitleRect, TSSText.GetHumanReadableString(item.name), itemTitleStyle);

            if (itemChained)
            {
                Rect chainIconRect = new Rect(itemRect.x + 7, itemRect.y + itemRect.height * 0.5f - 7, 14, 14);
                GUI.DrawTexture(chainIconRect, TSSEditorTextures.itemChainIcon, ScaleMode.StretchToFill);
            }

            if (item == selectedItem)
            {
                if (!itemChained)
                {
                    Handles.color = new Color(1, 1, 1, 0.5f);
                    Handles.color = Color.white;
                    Handles.DrawLine(new Vector2(itemRect.x, itemRect.y), new Vector2(itemRect.x, itemRect.y + itemRect.height));
                }

                Handles.color = Color.white;
                Handles.DrawLine(new Vector2(itemRect.x + itemRect.width, itemRect.y), new Vector2(itemRect.x + itemRect.width, itemRect.y + itemRect.height));
            }

            if (item.parent == selectedItem && selectedItem != null)
            {
                EditorGUI.DrawRect(itemRect, new Color(0.45f, 0.66f, 1f, 0.15f));
            }
            else if (selectedItem != null)
            {
                EditorGUI.DrawRect(itemRect, new Color(0, 0, 0, 0.15f));
            }

            itemCount++;

            for (int i = 0; i < item.childItems.Count; i++)
            {
                DrawItemOnTimeLine(item.childItems[i], position);
            }
        }
Ejemplo n.º 3
0
 /// <summary>Controll item (only one) manualy</summary>
 /// <param name="value">time between 0 and 1</param>
 public void Evaluate(float value)
 {
     TSSItemBase.Evaluate(this, value);
 }