-
Notifications
You must be signed in to change notification settings - Fork 414
Can no longer save to the scene or load from the scene (get errors) #82
Comments
Which version are you using? There seem to be problems with the latest 5.3.5 which I didn't adress yet... |
I pulled from develop, so the latest. o.0 I needed the save/load to/from scene functionality. D: I can still test/develop (still can reference scene gameobjects/components) so I'll sit tight until it's fixed. :) Any way I could "refresh" the save data? It doesn't matter if I lose anything (for right now at least). |
Sorry I meant the Unity version 5.3.5:) |
Oh! Well I have multiple versions of Unity installed, but for this project, I'm using Unity 5.3.4. |
Huh, then this is should not be a problem. Any way you can reproduce it? I am experiencing no problems here... Or maybe I did something to fix it but did not publish yet? 😕 |
It worked for me for an entire week straight. o.0 I downloaded it on Monday I think, so maybe you fixed it after? |
Nope I did not work on the project too much the past weeks... |
I think it might be triggered if the saved canvas in the entry is null. This is not possible if the canvas is correctly serialized into the scene. It might be related to that atleast, means there is most likely a bug in the seperation of the scene canvases from the asset saves... |
Okay no worries - I'll look into it and try and figure it out! |
My subscribing/unsubscribing to/from delegates stopped working also - might these be related? |
Weird, these are not connected at all - what do you mean with 'stopped working'? There's no hacky code or something like that could break easily, it's simple callback/delegate logic.... |
I have the same code, but added a second one:
It incrementally calls the methods. So it calls it once, than twice, than three times, etc. |
And without it works? |
Saving/Loading Delegates When I remove the newly added subscription, it still doesn't work even though that same code worked last week (breaks exactly as described above). Maybe the delegates working but another issue is causing it to re-call itself more and more each time? EDIT: Fixed (delegate issue), I'm dumb. I figured it out... My bad. Just in-case you're curious, here's what I did:
Sorry for wasting your time. D: |
Alright, good you resolved that:) You're not wasting my time, I'm happy to help you out getting something useful from this project:) To remove your corrupted saves, although not a fix, replace the first two methods and add the third one in NodeEditorSaveManager (attention pseudo code!): /// <summary>
/// Gets all existing stored saves in the current scene and returns their names
/// </summary>
public static string[] GetSceneSaves ()
{
return GetAllSaves ().Select (((NodeCanvasSceneSave save) => save.savedNodeCanvas.name)).ToArray ();
}
/// <summary>
/// Finds a scene save in the current scene with specified name or null if it does not exist
/// </summary>
private static NodeCanvasSceneSave FindSceneSave (string saveName)
{
return GetAllSaves ().Find ((NodeCanvasSceneSave save) => save.savedNodeCanvas.name == saveName);
}
/// <summary>
/// Flushes corrupted scene saves and returns all others
/// </summary>
private static List<NodeCanvasSceneSave> GetAllSaves ()
{ // TODO: Fix cause of occasionally corrupted saves
FetchSceneSaveHolder ();
List<NodeCanvasSceneSave> saves = sceneSaveHolder.GetComponents<NodeCanvasSceneSave> ().ToList ();
for (int cnt = 0; cnt < saves.Count; cnt++)
{
if (saves[cnt].savedNodeCanvas == null)
{
saves.RemoveAt (cnt);
cnt--;
Debug.LogWarning ("Deleted one corrupted scene save!");
}
}
return saves;
} That will do for now until I find a fix for the real cause;) |
Thank you for that ^^^ ! :D So.. delegates seem to be acting funky still. Occasionally they start behaving as before or stop working altogether. When I restart Unity, it usually starts working again. It stops working altogether super frequently now.. like OnEnable() won't even be called. o.0 But if OnEnable isn't working, isn't it a Unity related issue? |
That sounds to me like serialization issues... |
So it seems that it's breaking after each compile. I'm subscribing to the events in an editor script on enable (I unsubscribe, then subscribe as not to have duplicate subscriptions. I'm Googling and it appears a couple of others have had similar issues, but I haven't seem to find a solution yet. :( |
Ok then it's a common problem of Unity... Re-Serialization, which occurs on recompilation, always wipes out unserializable data. This means delegates are usually unsubscribed, too. |
Uh oh: "This is a bug in 5.3.4p4+. It's not fixed yet (as of 5.3.5p2)." Looks like it might be a Unity bug like you said: I'm going to try and jump back to before 5.3.4. |
I mean I developed a solution for serializable delegates but still these callbacks are stored as static variables in NodeEditorCallbackReceiver and thus have no chance of being properly serialized and restored... |
It's not straight a Unity bug, serialization is a normal process. Just unitys fault for not providing a good interface/API to handle this 😠 |
Forgive my lack of understanding, but what exactly do you mean by recurrently resubscribe? |
I thought of doing the process of unsubscribing and resubscribing in Update so you can be sure it is subscribed. It's dirty but my brain's currently too tired to do better:P Because the initial problem you got is that when a re-serialization is performed, your subscriptions are wiped. So this would make sure it is always subscribed, and always only one instance:) |
So I ended up making a class that extended NodeEditorCallbackReceiver and it's working SOO much better for me lol. No weird delegate issues, no editor scripts randomly not working, no DestroyImmediate issues... New question: Any way to deleted Canvases saved to the scene? It's bugging me have old debug canvases just sitting there lol. |
My next task was to include the Delete option for assets saved to the Scene. I've got leftover scene assets littering the scene. I was also thinking of saving the nodes themselves to .asset files as well. Interested in hearing progress anyone makes with this if I don't get around to sorting out first. From: PJ Legendre <notifications@github.commailto:notifications@github.com> So I ended up making a class that extended NodeEditorCallbackReceiver and it's working SOO much better for me lol. No weird delegate issues, no editor scripts randomly not working, no DestroyImmediate issues... New question: Any way to deleted Canvases saved to the scene? It's bugging me have old debug canvases just sitting there lol. You are receiving this because you are subscribed to this thread. |
@pi3butcher Good solution, if thats possible for you :) Yes I haven't implemented a GUI option for this. It's theoretially easy, there is a save object holding all canvases as components... simply delete the component (by code, as it's invisible, or change hideFlags). |
@Votrubec If you'dbe willing to implement it (not necessarily with the whole GUI but would be easie in the long run) that'd be great:) |
I'll certainly have a crack at doing it properly. As for the "why?"... I recently implemented an Inventory system that used one Scriptable Object to store a List<> of Items. And each Item was it's own Scriptable Object. These were saved to the file system as individual files, just as the Canvas can be saved to its own asset and the Last Session canvas is stored as its own asset file. Taking this further, I wanted the option to store the Nodes themselves as individual asset files. It just felt a little "safer" to me, and version control just picks up the asset files so there's no extra work needed there. The Item Scriptable Objects were easy to tweak individually if needed, without going through the custom editor window. I have a very visual designer colleague who has filled the Scene with test canvases until he got used to saving the Canvas to File instead of to the Scene. At the moment, there was no way for him to delete these discarded canvases. I updated the Node and created the custom ConnectionType to allow the designer to add and remove "evolution paths" and the number of paths from each Node without him having to touch any code (and yes, the Node size grows and shrinks correctly with the number of Output Knobs ;) ). From that point, I was wanting him to be able to grab any Node .asset file of his choosing from the Project Window and drop it into the Inspector fields I set up for individual Nodes. And there you have it, Robert's your mother's brother, or Bob's you uncle, either way, the visual designer can design away to his hearts content. After all of that, I was wanting to take a look at the zooming feature. It seems that sometimes the Node content get's stuck in an incorrect zoom state, so the content sometimes looks like it's a smaller size, but zoomed and blurred to be the current size. The image shows the problem if you look REALLY closely. The Nodes on the left of the Canvas, in particular the wording "Previous" is blurred. The Nodes on the right of the Canvas, the content is crisp and not zoomed. |
Sorry for the late reply, just came back from a horrible trip from the new forums, need some rest to cool down 😞 If you want to have control over the nodes, it's not too hard. First of, they are already technically stored as single assets, just as (hidden) subassets. If you go into NodeEditorSaveManager.cs you see in the apropriate functions that
Regarding the zooming glitch, that's a known problem but is out of our reach. It's related to Unity's crappy implementation of zooming support (which also required a hell lot of extra hacking work to do to get it properly working, see GUIScaleUtility):/ |
Any updates on this? Don't hesitate to reopen, but I'll just close for now:) |
Last week, everything worked perfectly. This morning I opened my project and attempted to load from the scene, then to save to the scene. I got these errors:
Any idea what I might have done to break the scene saving/loading or how I might fix this?
The text was updated successfully, but these errors were encountered: