Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to Save / Load Obi Actors in 5.0
#1
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:

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);
   }
Reply


Messages In This Thread
How to Save / Load Obi Actors in 5.0 - by Bill Sansky - 25-11-2019, 06:51 PM