コード例 #1
0
 private void Reset()
 {
     values = new TSSItemValues();
     TSSItemBase.InitValues(ref values);
     TSSItemBase.DoAllEffects(this, 0);
     UpdateState(ItemState.closed);
 }
コード例 #2
0
 private void Awake()
 {
     TSSBehaviour.OnItemAwake(this);
     TSSItemBase.InitValues(ref values);
     TSSItemBase.DoAllEffects(this, 0);
     UpdateState(ItemState.closed);
 }
コード例 #3
0
        public void Update()
        {
            if (!enabled || direction == TweenDirection.Button)
            {
                return;
            }

            if ((item.state == ItemState.closing || item.state == ItemState.closed) && direction == TweenDirection.Open ||
                (item.state == ItemState.opening || item.state == ItemState.opened) && direction == TweenDirection.Close)
            {
                return;
            }

            if (item.time < startPoint && item.time > endPoint)
            {
                return;
            }

            if (mode == TweenMode.Single)
            {
                effectValue = Evaluate(item.time, type);
            }
            else
            {
                openValue  = Evaluate(item.time, type);
                closeValue = Evaluate(item.time, closingType);
                if ((item.state == ItemState.closing && blendTime < blendFactor) ||
                    (item.state == ItemState.opening && blendTime > 0))
                {
                    blendTime += item.deltaTime;
                }
                effectValue = Mathf.SmoothStep(openValue, closeValue, Mathf.Clamp01(blendTime / blendFactor));
            }

            if (matProperty != null && effect == ItemEffect.property)
            {
                TSSItemBase.DoProperty(item, matProperty, effectValue);
            }
            else
            {
                TSSItemBase.DoEffect(item, effectValue, effect);
            }
        }
コード例 #4
0
        public void UpdateButton(float deltaTime)
        {
            if (buttonEvaluation > 0)
            {
                buttonEvaluation -= deltaTime;
                if (buttonEvaluation < 0)
                {
                    buttonEvaluation = 0;
                }

                for (int i = 0; i < tweens.Count; i++)
                {
                    if (!tweens[i].enabled || tweens[i].direction != TweenDirection.Button)
                    {
                        continue;
                    }
                    TSSItemBase.DoEffect(this, tweens[i].Evaluate(buttonDirection == ButtonDirection.open2Close ?
                                                                  buttonEvaluation / buttonDuration :
                                                                  1 - (buttonEvaluation / buttonDuration), tweens[i].type), tweens[i].effect);
                }
            }
        }
コード例 #5
0
        /// <summary>Refresh items inheritance and components (automatically only at editor, called once on awake at runtime)</summary>
        public void Refresh()
        {
            if (gameObject == null)
            {
                return;
            }

            TSSItem[] childs = GetComponentsInChildren <TSSItem>();

            childItems.Clear();
            childCountWithoutLoops = 0;

            for (int i = 0; i < childs.Length; i++)
            {
                if (childs[i] == this || childs[i].ignoreParent || TSSItemBase.GetItemParentTransform(childs[i]) != transform || !childs[i].enabled)
                {
                    continue;
                }

                if (ignoreChilds)
                {
                    childs[i].ID     = 1;
                    childs[i].parent = null;
                }
                else
                {
                    childItems.Add(childs[i]);
                    childs[i].ID     = childItems.Count;
                    childs[i].parent = this;
                    if (childs[i].loops == 0)
                    {
                        childCountWithoutLoops++;
                    }
                }

                childs[i].Refresh();
            }

            this.UpdateItemDelaysInChain((int)ItemKey.closed);
            this.UpdateItemDelaysInChain((int)ItemKey.opened);

            canvasGroup    = GetComponent <CanvasGroup>();
            image          = GetComponent <Image>();
            rawImage       = GetComponent <RawImage>();
            text           = GetComponent <Text>();
            gradient       = GetComponent <TSSGradient>();
            rect           = GetComponent <RectTransform>();
            button         = GetComponent <Button>();
            colider        = GetComponent <Collider>();
            audioPlayer    = GetComponent <AudioSource>();
            videoPlayer    = GetComponent <VideoPlayer>();
            sphereCollider = GetComponent <SphereCollider>();
            itemLight      = GetComponent <Light>();
            itemRenderer   = GetComponent <Renderer>();
            path           = GetComponent <TSSPath>();

            if (button != null)
            {
                button.onClick.AddListener(OnClick);
            }

            RefreshMaterial();
            if (path != null)
            {
                path.Refresh();
            }
        }
コード例 #6
0
 /// <summary>Open (if closed) or close (if opened) this item's branch immediately without activation modes</summary>
 public void OpenCloseBranchImmediately()
 {
     TSSItemBase.Activate(this, ActivationMode.openCloseBranchImmediately);
 }
コード例 #7
0
 /// <summary>Close item with close activation mode (CloseBranch as default)</summary>
 public void Close()
 {
     TSSItemBase.Activate(this, activationClose);
 }
コード例 #8
0
        private void DrawControlPanel()
        {
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            if (SelectedItemsStateIsIdentical(item.state))
            {
                switch (item.state)
                {
                case ItemState.closed:
                    GUI.color = Color.red;
                    EditorGUILayout.LabelField(closedState, EditorStyles.boldLabel, TSSEditorUtils.max80pxWidth);
                    break;

                case ItemState.opening:
                    GUI.color = Color.yellow;
                    EditorGUILayout.LabelField(openingState, EditorStyles.boldLabel, TSSEditorUtils.max80pxWidth);
                    break;

                case ItemState.opened:
                    GUI.color = Color.green;
                    EditorGUILayout.LabelField(openedState, EditorStyles.boldLabel, TSSEditorUtils.max80pxWidth);
                    break;

                case ItemState.closing:
                    GUI.color = Color.yellow;
                    EditorGUILayout.LabelField(closingState, EditorStyles.boldLabel, TSSEditorUtils.max80pxWidth);
                    break;

                case ItemState.slave:
                    GUI.color = Color.cyan;
                    EditorGUILayout.LabelField(timelineState, EditorStyles.boldLabel, TSSEditorUtils.max80pxWidth);
                    break;
                }
            }
            else
            {
                GUI.color = Color.grey;
                EditorGUILayout.LabelField(mixedState, EditorStyles.boldLabel, TSSEditorUtils.max80pxWidth);
            }

            GUI.color = TSSEditorUtils.redColor;
            if (GUILayout.Button(TSSEditorTextures.itemRecordClose, EditorStyles.miniButtonLeft, TSSEditorUtils.fixedLineHeight, TSSEditorUtils.max40pxWidth))
            {
                Undo.RecordObject(item, "[TSS Item] recording closed state");
                item.Capture(ItemKey.closed); InvokeItemMethod("CloseImmediately");
            }

            GUI.color = TSSEditorUtils.greenColor;
            if (GUILayout.Button(TSSEditorTextures.itemRecordOpen, EditorStyles.miniButtonRight, TSSEditorUtils.fixedLineHeight, TSSEditorUtils.max40pxWidth))
            {
                Undo.RecordObject(item, "[TSS Item] recording closed state");
                item.Capture(ItemKey.opened); InvokeItemMethod("OpenImmediately");
            }

            GUI.color = TSSEditorUtils.redColor;
            if (GUILayout.Button(TSSEditorTextures.itemClose, EditorStyles.miniButtonLeft, TSSEditorUtils.fixedLineHeight, TSSEditorUtils.max40pxWidth))
            {
                Undo.RecordObject(item, "[TSS Item] to closed state");
                if (Application.isPlaying)
                {
                    InvokeItemMethod("CloseBranch");
                }
                else
                {
                    InvokeItemMethod("CloseBranchImmediately");
                }
            }

            GUI.color = TSSEditorUtils.greenColor;
            if (GUILayout.Button(TSSEditorTextures.itemOpen, EditorStyles.miniButtonRight, TSSEditorUtils.fixedLineHeight, TSSEditorUtils.max40pxWidth))
            {
                Undo.RecordObject(item, "[TSS Item] to opened state");
                if (Application.isPlaying)
                {
                    InvokeItemMethod("OpenBranch");
                }
                else
                {
                    InvokeItemMethod("OpenBranchImmediately");
                }
            }

            GUI.color = Color.white;

            if (item != TSSTimeLineEditor.item && GUILayout.Button(openOnTimeLineButton, TSSEditorUtils.fixedLineHeight, TSSEditorUtils.max80pxWidth))
            {
                EditorWindow window = EditorWindow.GetWindow(typeof(TSSTimeLineEditor), false);
                if (TSSTimeLineEditor.item == null)
                {
                    TSSTimeLineEditor.mode = TSSTimeLineEditor.Mode.open;
                }
                TSSTimeLineEditor.item   = item;
                window.titleContent.text = "TSS TimeLine";
                item.state = ItemState.slave;
            }

            if (item == TSSTimeLineEditor.item && GUILayout.Button(takeOfTimeLineButton, TSSEditorUtils.fixedLineHeight, TSSEditorUtils.max80pxWidth))
            {
                TSSTimeLineEditor.item = null;
                TSSItemBase.Activate(item, ActivationMode.closeBranchImmediately);
            }

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(3);

            EditorGUILayout.BeginVertical();

            GUILayout.Space(3);

            EditorGUI.BeginDisabledGroup(item.parentChainMode);

            EditorGUILayout.BeginHorizontal();
            DrawItemProperty(item, "openDelay");
            DrawItemProperty(item, "closeDelay");
            EditorGUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginHorizontal();
            DrawItemProperty(item, "openDuration");
            DrawItemProperty(item, "closeDuration");
            EditorGUILayout.EndHorizontal();

            bool ignoreChilds = item.ignoreChilds && ValuesIsIdentical(GetSelectedItemsValues <bool>("ignoreChilds"));

            //if (ignoreChilds || item.childItems.Count == 0) { EditorGUILayout.EndVertical(); return; }

            EditorGUILayout.BeginHorizontal();
            DrawItemProperty(item, "openChildBefore");
            DrawItemProperty(item, "closeChildBefore");
            EditorGUILayout.EndHorizontal();

            bool chainMode = false;

            EditorGUILayout.BeginHorizontal();
            DrawItemProperty(item, "childChainMode");
            chainMode = (item.childChainMode && ValuesIsIdentical(GetSelectedItemsValues <bool>("childChainMode")));
            if (chainMode)
            {
                DrawItemProperty(item, "brakeChainDelay");
            }
            EditorGUILayout.EndHorizontal();

            if (chainMode)
            {
                EditorGUILayout.BeginHorizontal();
                DrawItemProperty(item, "chainOpenDelay");
                DrawItemProperty(item, "chainCloseDelay");
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                DrawItemProperty(item, "firstChildOpenDelay");
                DrawItemProperty(item, "firstChildCloseDelay");
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                DrawItemProperty(item, "chainOpenDirection");
                DrawItemProperty(item, "chainCloseDirection");
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }
コード例 #9
0
 /// <summary>Open (if closed) or close (if opened) only this item without activation modes</summary>
 public void OpenCloseSingle()
 {
     TSSItemBase.Activate(this, ActivationMode.openClose);
 }
コード例 #10
0
 /// <summary>Open only this item without activation mode</summary>
 public void OpenSinge()
 {
     TSSItemBase.Activate(this, ActivationMode.open);
 }
コード例 #11
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);
 }
コード例 #12
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);
 }
コード例 #13
0
 /// <summary>Controll item's branch (item with child and child of child of ... etc.) manualy</summary>
 /// <param name="value">time between 0 and 1</param>
 public void EvaluateBranch(float value)
 {
     TSSItemBase.EvaluateBranch(this, value);
 }
コード例 #14
0
 /// <summary>Activate item with specified activation mode</summary>
 /// <param name="mode">activation mode</param>
 public void Activate(ActivationMode mode)
 {
     TSSItemBase.Activate(this, mode);
 }
コード例 #15
0
 /// <summary>Open (if closed) or close (if opened) this item's branch without activation modes</summary>
 public void OpenCloseBranch()
 {
     TSSItemBase.Activate(this, ActivationMode.openCloseBranch);
 }
コード例 #16
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);
            }
        }
コード例 #17
0
 /// <summary>Close only this item immediately without activation mode</summary>
 public void CloseImmediately()
 {
     TSSItemBase.Activate(this, ActivationMode.closeImmediately);
 }
コード例 #18
0
 public void Awake()
 {
     TSSItemBase.InitValues(ref values);
 }
コード例 #19
0
 /// <summary>Open item with open activation mode (OpenBranch as default)</summary>
 public void Open()
 {
     TSSItemBase.Activate(this, activationOpen);
 }