The Blackboard can easily be accessed manually to read/write from/to its variables. All you need is a reference to it of course. Within tasks and nodes, you get a reference through the .blackboard inherited property, but you can always of course use GetComponent<Blackboard>() since blackboard is a component.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
//Adds a new variable to the Blackboard of type and name specified. public Variable AddVariable(string name, Type type) //Gets the Variable instance of name and type specified. public Variable GetVariable(string name, Type type) //The generic version of the above. public Variable<T> GetVariable<T>(string name) //Get a variable value that is of specified name and of type T or assignable to type T. //This is easier because it returns the value directly instead of the variable instance. public T GetVariableValue<T>(string name) //Set the value of a variable with specified name to the new value passed. public void SetVariableValue(string name, object value) /// ///Following is the API for saving/loading the blackboard variables. /// //Save the variables state in PlayerPrefs with the key specified. //Returns the serialized blackboard json string. public string Save(string prefsKey) //Loads the variables back from PlayerPrefs from the key specified. Returns true if success. public bool Load(string prefsKey) //Returns the serialized blackboard to json. Unity object references will be stored in the provided list. public string Serialize(List<UnityEngine.Object> references, bool pretyJson = false) //Deserialize a previously serialized json blackboard. Unity object references will be loaded from the provided list. Returns true if success. public bool Deserialize(string json, List<UnityEngine.Object> references) |
© Paradox Notion 2014-2024. All rights reserved.