Hmm. There are two possible solutions that I can think of for this.
1) You can use the Blackboard API, to set the variables by code directly. For example:
1
2
3
4
5
6
7
publicvoidSetVariables(){
varbb=GetComponent<Blackboard>();
bb.SetValue("myFloat",13f);
bb.SetValue("myColor",Color.yellow);
}
2) You could save a Blackboard variables to a serialized json string and store it somewhere, then deserialize the target blackboard you want, using that json. Some example code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
publicclassExamples:MonoBehaviour{
publicstringblackboardPresetJson;
publicvoidSaveToJson(){
varbb=GetComponent<Blackboard>();
blackboardPresetJson=bb.Serialize();
}
publicvoidLoadFromJson(){
varbb=GetComponent<Blackboard>();
bb.Deserialize(blackboardPresetJson);
}
}
You could of course also create some editor utility to save the json string to a file in editor only, like for example:
1
2
3
4
5
6
7
8
9
10
11
[ContextMenu("Save Attached Blackboard To Preset File")]
Then in runtime you would need to of course have a reference to that saved TextAsset file and deserialize the blackboard from it’s contents. Once again, for example:
1
2
3
4
5
6
7
8
publicTextAsset presetFile;
publicvoidLoadPreset(){
varbb=GetComponent<Blackboard>();
bb.Deserialize(presetFile.text);
}
Let me know if any of the above solutions works for you.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.