Exemple #1
0
        public static void NewCanvas()
        {
            Path = @"Assets/Ou/Property/Node/Default.asset";
            if (curNodeEditorState != null)
            {
                if (AssetDatabase.GetAssetPath(curNodeEditorState).Contains("Default"))
                {
                    curNodeEditorState.CurGraph.Clear();
                    return;
                }
            }
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(Path);
            NodeGraph       graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
                graph.Clear();
            }
            else
            {
                TriggerEditorUtility.Init();
                state          = ScriptableObject.CreateInstance <NodeEditorState>();
                graph          = ScriptableObject.CreateInstance <NodeGraph>();
                state.CurGraph = graph;
                AssetDatabase.CreateAsset(state, Path);
                AssetDatabase.AddObjectToAsset(graph, state);
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
            CreateCache(Path);
        }
Exemple #2
0
        public static void LoadCanvas(string path)
        {
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(path);

            TriggerEditorUtility.Init();
            NodeGraph graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
            CreateCache(path);
        }
Exemple #3
0
        public static Node CreateNode(Vector2 pos, string nodeId)
        {
            Node node = NodeTypes.getDefaultNode(nodeId);

            if (node == null)
            {
                Debug.Log("node editor running is warning!");
                TriggerEditorUtility.Init();
            }
            var npos = (pos - NodeEditor.curNodeEditorState.PanOffset) / NodeEditor.curNodeEditorState.GraphZoom;

            node = node.Create(
                npos);
            node.Init();
            return(node);
        }
Exemple #4
0
        public static void LoadCanvas()
        {
            string path = EditorUtility.OpenFilePanel("Load Canvas", Application.dataPath + "/Ou/Property/Node", "asset");

            path = Regex.Replace(path, @"^.+/Assets", "Assets");
            TriggerEditorUtility.Init();
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(path);
            NodeGraph       graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
            CreateCache(path);
        }
Exemple #5
0
        public static void InitAssetData()
        {
            TriggerEditorUtility.Init();
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(Path);
            NodeGraph       graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
            }
            else
            {
                state          = ScriptableObject.CreateInstance <NodeEditorState>();
                graph          = ScriptableObject.CreateInstance <NodeGraph>();
                state.CurGraph = graph;
                AssetDatabase.CreateAsset(state, Path);
                AssetDatabase.AddObjectToAsset(graph, state);
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
        }
Exemple #6
0
        public static void SaveAs()
        {
            string path = EditorUtility.SaveFilePanel("Save unit", Application.dataPath + "/Ou/Property/Node",
                                                      "Duplicate", "asset");

            path = Regex.Replace(path, @"^.+/Assets", "Assets");
            AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(curNodeEditorState), path);
            AssetDatabase.Refresh();
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(path);

            state.Name = Regex.Match(path, @"/.+?\.", RegexOptions.RightToLeft).Value.TrimStart('/').TrimEnd('.');
            TriggerEditorUtility.Init();
            NodeGraph graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
            CreateCache(path);
        }
 void Awake()
 {
     TriggerEditorUtility.Init();
     Instance = this;
 }