Exemple #1
0
 public static bool OnOpen(int instanceID, int line)
 {
     AnimationBaker.StateMachine.XNode.NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as AnimationBaker.StateMachine.XNode.NodeGraph;
     if (nodeGraph != null)
     {
         NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "Animation Baker", true) as NodeEditorWindow;
         w.wantsMouseMove = true;
         w.graph          = nodeGraph;
         return(true);
     }
     return(false);
 }
 private static void OnReloadEditor()
 {
     // Find all NodeGraph assets
     string[] guids = AssetDatabase.FindAssets("t:" + typeof(AnimationBaker.StateMachine.XNode.NodeGraph));
     for (int i = 0; i < guids.Length; i++)
     {
         string assetpath = AssetDatabase.GUIDToAssetPath(guids[i]);
         AnimationBaker.StateMachine.XNode.NodeGraph graph = AssetDatabase.LoadAssetAtPath(assetpath, typeof(AnimationBaker.StateMachine.XNode.NodeGraph)) as AnimationBaker.StateMachine.XNode.NodeGraph;
         if (graph == null)
         {
             return;
         }
         graph.nodes.RemoveAll(x => x == null); //Remove null items
         Object[] objs = AssetDatabase.LoadAllAssetRepresentationsAtPath(assetpath);
         // Ensure that all sub node assets are present in the graph node list
         for (int u = 0; u < objs.Length; u++)
         {
             graph.ImportSerialized(objs[u]);
         }
     }
 }
Exemple #3
0
        public void SaveAs()
        {
            string path = EditorUtility.SaveFilePanelInProject("Save NodeGraph", "NewNodeGraph", "asset", "");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            else
            {
                AnimationBaker.StateMachine.XNode.NodeGraph existingGraph = AssetDatabase.LoadAssetAtPath <AnimationBaker.StateMachine.XNode.NodeGraph>(path);
                if (existingGraph != null)
                {
                    AssetDatabase.DeleteAsset(path);
                }
                AssetDatabase.CreateAsset(graph, path);
                // EditorUtility.SetDirty(graph);
                graph.IsDirty = true;
                if (NodeEditorPreferences.GetSettings().autoSave)
                {
                    AssetDatabase.SaveAssets();
                }
            }
        }