Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

References to Node Graphs in Scene Graph are all gone #372

Open
FancifulEight opened this issue Aug 12, 2023 · 3 comments
Open

References to Node Graphs in Scene Graph are all gone #372

FancifulEight opened this issue Aug 12, 2023 · 3 comments

Comments

@FancifulEight
Copy link

I entered Unity's Safe Mode to fix some errors and when I returned to normal operations all references to graphs went missing.

Where do the ScriptableObject NodeGraphs get saved when created by the SceneGraph? If I could find that, that would solve all my problems.

@FancifulEight
Copy link
Author

After some digging it seems XNode uses ScriptableObject.CreateInstance() and nothing else, which shouldn't save to disk... So how have I worked on these for several months without encountering this problem?

@FancifulEight
Copy link
Author

In order for this to not happen again, I have added AssetDatabase.CreateAsset() to the SceneGraph CreateGraph() function.

        public void CreateGraph(Type type) {
            Undo.RecordObject(sceneGraph, "Create graph");
            sceneGraph.graph = ScriptableObject.CreateInstance(type) as NodeGraph;
            sceneGraph.graph.name = sceneGraph.name + "-graph";
            AssetDatabase.CreateAsset(
                sceneGraph.graph, 
                string.Format(
                    "Assets/DialogueTrees/{0}/{1}.asset", 
                    (sceneGraph.transform.parent == null) ? "None":((sceneGraph.transform.parent.parent == null) ? "None":sceneGraph.transform.parent.parent.name), 
                    sceneGraph.graph.name)
                );
        }

@tommardis
Copy link

I think I might be having the same issue, @FancifulEight

When I add a scene graph component to a gameobject, it does still show the "new graph" button, which works, and then the open and remove graph buttons, but when I added my xNode code to another project, it also shows the "script" and "graph" fields for some reason. And if I create a scene graph, then leave and reopen the scene, the scene graph is empty and it's showing the "new graph" button again.

The strange thing is that it's still working fine in my other project! I though it might be the differing Unity version or that I included XNode through github in my newer one, but when I changed them both to match the working project, it was still doing the same thing! Was this the same issue you were having?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants