Exemplo n.º 1
0
 protected void SetError(string p_warning = null)
 {
     if (!string.IsNullOrEmpty(p_warning))
     {
         Debug.LogWarning(p_warning+" on node " + _model.id);
         #if UNITY_EDITOR
         DashEditorDebug.Debug(new ErrorDebugItem(p_warning));
         #endif
     }
     hasErrorsInExecution = true;
 }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        public void Execute(NodeFlowData p_flowData)
        {
            ExecutionCount++;
            
#if UNITY_EDITOR
            if (!_hasDebugOverride)
            {
                DashEditorDebug.Debug(new NodeDebugItem(NodeDebugItem.NodeDebugItemType.EXECUTE, Graph.Controller, Graph.GraphPath, _model.id,
                    p_flowData.GetAttribute<Transform>("target")));
            }
            
            executeTime = 1;
#endif

            OnExecuteStart(p_flowData == null ? new NodeFlowData() : p_flowData.Clone());
        }
Exemplo n.º 5
0
        protected override void OnExecuteStart(NodeFlowData p_flowData)
        {
            if (Model.debugFlowData)
            {
                DebugFlowData(p_flowData);
            }
            else
            {
                var value = GetParameterValue(Model.debug, p_flowData);

#if UNITY_EDITOR
                DashEditorDebug.Debug(new CustomDebugItem(value));
#endif

                Debug.Log(value);
            }

            OnExecuteEnd();
            OnExecuteOutput(0, p_flowData);
        }
Exemplo n.º 6
0
        override protected void OnExecuteStart(NodeFlowData p_flowData)
        {
            Transform target = null;

            if (!p_flowData.HasAttribute("target") && Model.isChild)
            {
                Debug.LogWarning("Cannot retarget to a child of null in node " + _model.id);
                hasErrorsInExecution = true;

                return;
            }


            target = p_flowData.GetAttribute <Transform>("target");

            // Handle retargeting
            if (Model.retarget)
            {
                if (Model.useReference)
                {
                    if (Model.useExpression)
                    {
                        // var value = ExpressionEvaluator.EvaluateTypedExpression(Model.targetExpression, typeof(Transform),
                        //     ParameterResolver, p_flowData);
                        var value = ExpressionEvaluator.EvaluateUntypedExpression(Model.targetExpression,
                                                                                  ParameterResolver, p_flowData, false);

                        if (ExpressionEvaluator.hasErrorInEvaluation)
                        {
                            SetError(ExpressionEvaluator.errorMessage);
                            return;
                        }

                        target = value as Transform;

                        if (target == null && value.GetType() == typeof(GameObject))
                        {
                            target = (value as GameObject).transform;
                        }
                        else if (target == null && value is Component)
                        {
                            target = (value as Component).transform;
                        }
                    }
                    else
                    {
                        target = Model.targetReference.Resolve(Controller);
                    }
                }
                else
                {
                    if (target != null)
                    {
                        if (Model.isChild)
                        {
                            string find = GetParameterValue(Model.target, p_flowData);
                            target = target.Find(find, true);
                        }
                        else
                        {
                            string     find = GetParameterValue(Model.target, p_flowData);
                            GameObject go   = GameObject.Find(find);
                            target = go == null ? null : go.transform;
                        }
                    }
                }
            }

            #if UNITY_EDITOR
            DashEditorDebug.Debug(new NodeDebugItem(NodeDebugItem.NodeDebugItemType.EXECUTE, Graph.Controller, Graph.GraphPath, _model.id, target));
            #endif

            if (CheckException(target, "No valid target found"))
            {
                return;
            }

            ExecuteOnTarget(target, p_flowData);
        }