NodeCanvas Forums › General Discussion › Persistent Blackboard › Reply To: Persistent Blackboard
Hi
I have a similar problem, and I would like to know what is the best aproach to achieve this.
PROBLEM:
I need some global settings to remain through levels. Let say I have a few scenes i.e.:
At Settings screen I set some parameters to GlobalBB, and load further levels by standard Unity LoadLevel.
Unfortunately on Level 1, 2 and so on I can’t set any reference to GlobalBB variables. I understand that – there is no such object in particular scene so it can’t get reference. So I make a copy of my GlobalBB to every single scene. It is not so hard when you make a Prefab. But that way every single scene have its own GlobalBB – it is local, and dosn’t really connected with Settings GlobalBB.
Possible approaches:
1. DontDestroyOnLoad
In this approach on the first (Settings) scene I set GlobalBB object as DontDestroyOnLoad. When I LoadLevel this GlobalBB persist to next scene, and values are used properly, but trully there are two GlobalBB object now in evely Level scene – the local one which is set in the Level scene, and this persistence one from Settings scene. In play mode Unity warn me there is two BB with the same name. Although it works, but I don’t feel very comfortable with that – I’m not sure if it is stable solution or simply I have a luck and it is more random and uncertain which GlobalBB will be used?
2. Save and Load BB between levels
In this approach I don’t preserve Settings GlobalBB from being destroyed. Instead I save my GlobalBB parameters to PlayerPrefs before exit from particular scene, and load this parameters at the next Level . That way I have only one (local) GlobalBB at every scene, but the whole solution isn’t very convenient and is probably less efficient.
3. Others
I have some other ideas how to do it, but with heavily custom code which make it questionable to use GlobalBB at all.
Summary:
So I would like to ask the author once more – could you please specify what is the most proper way to achieve this with NodeCanvas2?
BTW. plugin is absolutely great – I really appreciate it very much.