Example #1
0
 protected void HandleMouseCheck()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Execute(NodeFlowDataFactory.Create(Controller.transform));
     }
 }
Example #2
0
        override protected void OnExecuteStart(NodeFlowData p_flowData)
        {
            string eventName = GetParameterValue(Model.eventName, p_flowData);
            bool   global    = GetParameterValue(Model.global, p_flowData);
            bool   sendData  = GetParameterValue(Model.sendData, p_flowData);

            if (global)
            {
                #if UNITY_EDITOR
                if (DashEditorCore.Previewer.IsPreviewing)
                {
                    _graph.SendEvent(eventName, sendData ? p_flowData : NodeFlowDataFactory.Create());
                }
                else
                {
                    DashCore.Instance.SendEvent(eventName, sendData ? p_flowData : NodeFlowDataFactory.Create());
                }
                #else
                DashCore.Instance.SendEvent(eventName, sendData ? p_flowData : NodeFlowDataFactory.Create());
                #endif
            }
            else
            {
                _graph.SendEvent(eventName, sendData ? p_flowData : NodeFlowDataFactory.Create());
            }

            OnExecuteEnd();
            OnExecuteOutput(0, p_flowData);
        }
Example #3
0
        void OnUpdate()
        {
            if (!_previewStarted)
            {
                _previewStarted = true;
                _previewGraph.Nodes[_previewNodeIndex].Execute(NodeFlowDataFactory.Create(Controller.transform));
            }

            if (_isPreviewing)
            {
                if (_previewGraph.CurrentExecutionCount == 0)
                {
                    DashTween.DelayedCall(1f, StopPreview);
                }
            }
        }
Example #4
0
        private void OnEnable()
        {
            if (Graph == null)
            {
                return;
            }

            if (autoOnEnable)
            {
#if UNITY_EDITOR
                DashEditorDebug.Debug(new ControllerDebugItem(ControllerDebugItem.ControllerDebugItemType.ONENABLE, this));
#endif
                NodeFlowData data = NodeFlowDataFactory.Create(GetTarget());
                Graph.ExecuteGraphInput(autoOnEnableInput, data);
            }
        }
Example #5
0
        void Start()
        {
            if (Graph == null)
            {
                return;
            }

            if (autoStart)
            {
#if UNITY_EDITOR
                DashEditorDebug.Debug(new ControllerDebugItem(ControllerDebugItem.ControllerDebugItemType.START, this));
#endif
                NodeFlowData data = NodeFlowDataFactory.Create(GetTarget());
                Graph.ExecuteGraphInput(autoStartInput, data);
            }
        }
Example #6
0
        public void SendEvent(string p_name, NodeFlowData p_flowData)
        {
            if (Graph == null || GetTarget() == null)
            {
                return;
            }

            p_flowData = p_flowData == null?NodeFlowDataFactory.Create(GetTarget()) : p_flowData.Clone();

            if (!p_flowData.HasAttribute(NodeFlowDataReservedAttributes.TARGET))
            {
                p_flowData.SetAttribute(NodeFlowDataReservedAttributes.TARGET, GetTarget());
            }

            p_flowData.SetAttribute(NodeFlowDataReservedAttributes.EVENT, p_name);

            Graph.SendEvent(p_name, p_flowData);
        }
Example #7
0
        protected override void Initialize()
        {
            List <Button> buttons = new List <Button>();
            Button        button;
            Transform     transform;

            if (Model.useReference)
            {
                button = Model.buttonReference.Resolve(Controller);
                if (button != null)
                {
                    buttons.Add(button);
                }
            }
            else
            {
                if (Model.isChild)
                {
                    if (Model.useFind)
                    {
                        if (Model.findAll)
                        {
                            List <Transform> transforms = Controller.transform.DeepFindAll(Model.button);
                            foreach (Transform t in transforms)
                            {
                                button = t.GetComponent <Button>();
                                if (button != null)
                                {
                                    buttons.Add(button);
                                }
                            }
                        }
                        else
                        {
                            transform = Controller.transform.DeepFind(Model.button);
                            button    = transform == null ? null : transform.GetComponent <Button>();
                            if (button != null)
                            {
                                buttons.Add(button);
                            }
                        }
                    }
                    else
                    {
                        transform = Controller.transform.Find(Model.button);
                        button    = transform == null ? null : transform.GetComponent <Button>();
                        if (button != null)
                        {
                            buttons.Add(button);
                        }
                    }
                }
                else
                {
                    if (Model.useFind)
                    {
                        if (Model.findAll)
                        {
                            List <Transform> transforms = Controller.transform.root.DeepFindAll(Model.button);
                            foreach (Transform t in transforms)
                            {
                                button = t.GetComponent <Button>();
                                if (button != null)
                                {
                                    buttons.Add(button);
                                }
                            }
                        }
                        else
                        {
                            transform = Controller.transform.root.DeepFind(Model.button);
                            button    = transform == null ? null : transform.GetComponent <Button>();
                            if (button != null)
                            {
                                buttons.Add(button);
                            }
                        }
                    }
                    else
                    {
                        GameObject go = GameObject.Find(Model.button);
                        button = go == null ? null : go.GetComponent <Button>();
                        if (button != null)
                        {
                            buttons.Add(button);
                        }
                    }
                }
            }

            foreach (Button b in buttons)
            {
                if (Model.retargetToButton)
                {
                    b.onClick.AddListener(() => Execute(NodeFlowDataFactory.Create(b.transform)));
                }
                else
                {
                    b.onClick.AddListener(() => Execute(NodeFlowDataFactory.Create(Controller.transform)));
                }
            }
        }
Example #8
0
        public override void DrawInspectorControls(Rect p_rect)
        {
            if (!(this is IAnimationNodeBindable) || !DashEditorCore.EditorConfig.enableAnimateNodeInterface)
            {
                return;
            }

            Transform target = ResolveEditorTarget();

            if (target == null)
            {
                return;
            }

            GUIStyle style = new GUIStyle();

            GUI.backgroundColor     = new Color(0, 0, 0, 0.5f);
            style.normal.background = Texture2D.whiteTexture;
            GUI.Box(new Rect(p_rect.x, p_rect.y + p_rect.height + 4, 390, 38), "", style);
            GUI.backgroundColor = Color.white;

            GUILayout.BeginArea(new Rect(p_rect.x + 20, p_rect.y + p_rect.height + 8, p_rect.width - 20, 30));
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            style           = new GUIStyle(GUI.skin.button);
            style.fontStyle = FontStyle.Bold;

            GUI.enabled = ((IAnimationNodeBindable)this).IsFromEnabled();
            if (_bindFrom)
            {
                GUI.backgroundColor = new Color(1, 0, 0);
                if (GUILayout.Button("UNBIND FROM", style, GUILayout.Width(110), GUILayout.ExpandHeight(true)))
                {
                    _bindFrom = false;
                }
                GUI.backgroundColor = Color.white;
            }
            else
            {
                if (GUILayout.Button("BIND FROM", style, GUILayout.Width(110), GUILayout.ExpandHeight(true)))
                {
                    ((IAnimationNodeBindable)this).SetTargetFrom(target);
                    _bindTo   = false;
                    _bindFrom = true;
                }
            }

            GUILayout.FlexibleSpace();

            GUI.enabled = ((IAnimationNodeBindable)this).IsToEnabled();
            if (_bindTo)
            {
                GUI.backgroundColor = new Color(1, 0, 0);
                if (GUILayout.Button("UNBIND TO", style, GUILayout.Width(110), GUILayout.ExpandHeight(true)))
                {
                    _bindTo = false;
                }
                GUI.backgroundColor = Color.white;
            }
            else
            {
                if (GUILayout.Button("BIND TO", style, GUILayout.Width(110), GUILayout.ExpandHeight(true)))
                {
                    ((IAnimationNodeBindable)this).SetTargetTo(target);
                    _bindFrom = false;
                    _bindTo   = true;
                }
            }

            GUILayout.FlexibleSpace();

            GUI.backgroundColor    = new Color(1, .75f, .5f);
            style.fontSize         = 16;
            style.normal.textColor = GUI.backgroundColor;

            if (GUILayout.Button("PREVIEW", style, GUILayout.Width(100), GUILayout.ExpandHeight(true)))
            {
                TransformStorageData data = new TransformStorageData(target, TransformStorageOption.POSITION);
                AnimateOnTarget(target, NodeFlowDataFactory.Create())?.OnComplete(() =>
                {
                    DashTweenCore.Uninitialize();
                    data.Restore(target);
                }).Start();
            }

            GUI.backgroundColor = Color.white;
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            GUI.enabled = true;

            GUI.color = Color.yellow;
            GUI.DrawTexture(new Rect(p_rect.x + 8, p_rect.y + p_rect.height + 16, 16, 16),
                            IconManager.GetIcon("experimental_icon"));
            GUI.color = Color.white;

            if (_bindFrom)
            {
                ((IAnimationNodeBindable)this).GetTargetFrom(target);
            }
            else if (_bindTo)
            {
                ((IAnimationNodeBindable)this).GetTargetTo(target);
            }
        }