Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to Save / Load Obi Actors in 5.0
#4
Some more info, if I do this:
Quote:
Code:
   public object Save()
   {
       ObiActorBlueprint bp = Instantiate(Actor.blueprint);
       Actor.SaveStateToBlueprint(bp);
       return bp;
   }

   public void Load(object saveFile)
   {
       if (saveFile == null)
           return;
       
       var solver = Actor.solver;
       Actor.RemoveFromSolver();

       var blueprint = (ObiRopeBlueprint) saveFile;
     
       Actor.ropeBlueprint = blueprint;
       Actor.LoadBlueprint(solver);
   }
then there is an exception on load:
(The odin inspector part is just the button press in the editor)
Code:
NullReferenceException: Object reference not set to an instance of an object
Obi.ObiActor.LoadBlueprintParticles (Obi.ObiActorBlueprint bp) (at Assets/Plugins/Obi/Scripts/Common/Actors/ObiActor.cs:764)
Obi.ObiActor.LoadBlueprint (Obi.ObiSolver solver) (at Assets/Plugins/Obi/Scripts/Common/Actors/ObiActor.cs:915)
Obi.ObiRope.LoadBlueprint (Obi.ObiSolver solver) (at Assets/Plugins/Obi/Scripts/RopeAndRod/Actors/ObiRope.cs:105)
ObiRopeSaver.Load (System.Object saveFile) (at Assets/Plugins/BFT/BFT/Plugins Extensions/Obi/Save/ObiRopeSaver.cs:28)
BFT.SavedObjectListComponent.Load (System.Object saveFile) (at Assets/Plugins/BFT/BFT/Serialization/Game Save/Lists/SavedObjectListComponent.cs:55)
BFT.SavedObjectListComponent.Load (System.Object saveFile) (at Assets/Plugins/BFT/BFT/Serialization/Game Save/Lists/SavedObjectListComponent.cs:55)
BFT.BFTAction`1[T].Invoke (T val) (at Assets/Plugins/BFT/BFT/Referencing/Generic/Delegates/Actions/BFTAction1.cs:226)
BFT.FunctionToActionSetter`3[T,T1,T2].SetValue () (at Assets/Plugins/BFT/BFT/Referencing/Generic/Delegates/Function/FunctionToActionSetter.cs:24)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer.InvokeButton () (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:329)
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:InvokeButton() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:344)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:DrawNormalButton() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:217)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:DrawPropertyLayout(GUIContent) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:129)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:176)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:544)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/InspectorUtilities.cs:374)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:303)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:93)
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:215)
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:85)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Additionally, saving and loading during runtime causes a crash of the editor, I attached the dump file but it doesn't seem to bring anything
https://drive.google.com/open?id=1FThylJ...LtNLkFeoup

I also got to realize that I need to save the raw data, not the blueprint since I can't serialize a runtime-created blueprint: how can I modify all the arrays of data manually?
Reply


Messages In This Thread
RE: How to Save / Load Obi Actors in 5.0 - by Bill Sansky - 26-11-2019, 04:53 PM