예제 #1
0
파일: DebugItem.cs 프로젝트: pshtif/Dash
 public ControllerDebugItem(ControllerDebugItemType p_type, DashController p_controller)
 {
     _type           = DebugItemType.CONTROLLER;
     _subType        = p_type;
     _controller     = p_controller;
     _controllerName = p_controller?.name;
 }
예제 #2
0
파일: DebugItem.cs 프로젝트: pshtif/Dash
        public NodeDebugItem(NodeDebugItemType p_subType, DashController p_controller, string p_graphPath,
                             string p_nodeId, Transform p_target)
        {
            _type    = DebugItemType.NODE;
            _subType = p_subType;
            TimeSpan span = TimeSpan.FromSeconds(_time);

            _timeString        = span.ToString(@"hh\:mm\:ss\:fff");
            _controllerName    = p_controller != null ? p_controller.name : "NULL";
            _graphPath         = p_graphPath;
            _relativeGraphPath = _graphPath.IndexOf("/") >= 0 ? _graphPath.Substring(_graphPath.IndexOf("/") + 1) : "";
            _targetName        = p_target != null ? p_target.name : "NONE";
            _nodeId            = p_nodeId;
        }
예제 #3
0
        public static void EditController(DashController p_controller, string p_graphPath = "")
        {
            SelectionManager.ClearSelection();

            if (p_controller != null)
            {
                EditorConfig.editingRootGraph  = p_controller.Graph;
                EditorConfig.editingGraphPath  = p_graphPath;
                EditorConfig.editingGraph      = GraphUtils.GetGraphAtPath(p_controller.Graph, p_graphPath);
                EditorConfig.editingController = p_controller;
            }
            else
            {
                EditorConfig.editingGraph = null;
            }
        }
예제 #4
0
        public void StopPreview()
        {
            DashTween.CleanAll();
            DashTweenCore.Uninitialize();
            DashCore.Instance.CleanPrefabPools();
            DashCore.Instance.CleanSequencers();

            EditorApplication.update -= OnUpdate;

            if (!_isPreviewing)
            {
                return;
            }

            _isPreviewing = false;

            if (_stage == null)
            {
                // Since we can do almost anything in preview we need to reload the scene before it
                EditorSceneManager.OpenScene(EditorSceneManager.GetActiveScene().path);

                DashController[] controllers = GameObject.FindObjectsOfType <DashController>();
                DashController   controller  = controllers.ToList().Find(c => c.previewing);
                DashEditorCore.EditController(controller, DashEditorCore.EditorConfig.editingGraphPath);
                controller.previewing = false;

                EditorUtility.SetDirty(controller);
                EditorSceneManager.SaveOpenScenes();

                Selection.activeGameObject = controller.gameObject;
            }
            else
            {
                _stage.GetType().GetMethod("ReloadStage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(_stage, new object[] {});

                DashController[] controllers = _stage.prefabContentsRoot.GetComponentsInChildren <DashController>();
                DashController   controller  = controllers.ToList().Find(c => c.previewing);
                DashEditorCore.EditController(controller, DashEditorCore.EditorConfig.editingGraphPath);
                controller.previewing = false;
                if (_controllerSelected)
                {
                    Selection.objects = new Object[] { controller.gameObject };
                }

                bool state = (bool)_stage.GetType().GetMethod("SavePrefab", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(_stage, new object[] {});
            }
        }
예제 #5
0
        public void Initialize(DashController p_controller)
        {
            if (_initialized)
            {
                return;
            }

            if (version < DashCore.GetVersionNumber())
            {
                //Debug.LogWarning("Current Dash version is higher than initialized Graph, can result in possible issues please migrate in editor. Controller "+p_controller.name);
            }

            Controller = p_controller;

            _nodes.ForEach(n => ((INodeAccess)n).Initialize());
            variables.Initialize(p_controller.gameObject);

            _initialized = true;
        }
예제 #6
0
 public void Unbind(DashController p_controller)
 {
     _controllers.Remove(p_controller);
 }
예제 #7
0
 public void Bind(DashController p_controller)
 {
     _controllers.Add(p_controller);
 }
예제 #8
0
        public object Resolve(string p_name, IAttributeDataCollection p_collection, bool p_referenced)
        {
            hasErrorInResolving = false;

            string name = p_name;

            string[] nameSplit = null;
            if (p_name.IndexOf('.') > 0)
            {
                nameSplit = p_name.Split('.');
                name      = nameSplit[0];
            }

            if (p_collection != null)
            {
                if (p_collection.HasAttribute(name))
                {
                    return(ResolveNested(nameSplit, 0, p_collection.GetAttribute(name), p_collection, p_referenced));
                }
            }

            object result;

            if (ReservedParameters.Resolve(_graph, name, out result))
            {
                return(ResolveNested(nameSplit, 0, result, p_collection, p_referenced));
            }

            if (ResolveReference(name, p_collection, out result))
            {
                return(ResolveNested(nameSplit, 0, result, p_collection, true));
            }

            DashController controller = _graph.Controller;

            #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                controller = DashEditorCore.EditorConfig.editingController;
            }
            #endif

            if (controller != null && controller.Variables != null && controller.Variables.HasVariable(name))
            {
                Variable variable = controller.Variables.GetVariable(name);
                return(ResolveNested(nameSplit, 0, variable.value, p_collection, p_referenced));
            }

            if (_graph.variables.HasVariable(name))
            {
                Variable variable = _graph.variables.GetVariable(name);
                return(ResolveNested(nameSplit, 0, variable.value, p_collection, p_referenced));
            }

            if (DashCore.Instance.GlobalVariables != null && DashCore.Instance.GlobalVariables.HasVariable(name))
            {
                Variable variable = DashCore.Instance.GlobalVariables.GetVariable(name);
                return(ResolveNested(nameSplit, 0, variable.value, p_collection, p_referenced));
            }

            hasErrorInResolving = true;
            errorMessage        = "Variable " + name + " not found.";
            return(null);
        }