25-11-2019, 06:51 PM
Hi!
I'm trying to load and save the state of an obi actor, but so far I did not manage to: I am used to the old way involving irectly getting the data from the actor after pulling it from the solver.
How should I approach this now?
I tried to create a blueprint, save the actor to it, and then load the blueprint, but so far no luck.
Is that the way I should do it?
Here is my current approach:
I'm trying to load and save the state of an obi actor, but so far I did not manage to: I am used to the old way involving irectly getting the data from the actor after pulling it from the solver.
How should I approach this now?
I tried to create a blueprint, save the actor to it, and then load the blueprint, but so far no luck.
Is that the way I should do it?
Here is my current approach:
Code:
public object Save()
{
// var blueprint = ScriptableObject.CreateInstance<ObiActorBlueprint>();
ObiActorBlueprint bp = (ObiActorBlueprint) ScriptableObject.CreateInstance(Actor.blueprint.GetType());
bp.GenerateImmediate();
Actor.SaveStateToBlueprint(bp);
//am I saving that properly?
return bp;
}
public void Load(object saveFile)
{
if (saveFile == null)
return;
//needed? no idea
var solver = Actor.solver;
Actor.RemoveFromSolver();
var blueprint = (ObiActorBlueprint) saveFile;
Actor.blueprint = blueprint;
//doing that doesnt work
///blueprint.GenerateImmediate();
Actor.transform.SetParent(solver.transform);
Actor.AddToSolver();
//no working
Actor.LoadBlueprint(solver);
}