Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Force reload a new blueprint and save it to a file
#2
(24-08-2020, 06:04 AM)nexar Wrote: - How could we save the new Blueprint (with the updated properties and groups) in a different file, so that we could open it later? Currently we are only creating it as a memory object.

Blueprints are just ScriptableObjects, as such, they are saved and managed the same way as you do with any asset in Unity. This is not specific to Obi.

You need to call AsseDatabase.CreateAsset:
https://docs.unity3d.com/ScriptReference...Asset.html

followed by a call to AssetDatabase.SaveAssets:
https://docs.unity3d.com/ScriptReference...ssets.html

(24-08-2020, 06:04 AM)nexar Wrote: - What is the right way to reassign the new Blueprint to the "Obi SkinnedCloth" component, and force it to reload?
(As we didn't find the "set" option for the "blueprint" property of the "Obi SkinnedCloth" class, we changed the "m_SkinnedClothBlueprint" property from protected to public, and re-assigned it to the new generated blueprint).

Just assign the new blueprint to cloth.skinnedClothBlueprint property. Each ObiActor subclass has its own read/write blueprint property (skinnedClothBlueprint, tearableClothBlueprint , clothBlueprint). The generic "blueprint" property is just an accessor, its return type is the base class for the actor's blueprint, and intended to get access to the blueprint w/polymorphism: when you just have a reference to a ObiActor but you don't know what's the actual type of the instance. See the API docs for details.

Making the backing variable public and changing it directly won't have any effect at all, all you're doing is setting a variable but skipping all the code that actually loads the blueprint. This takes place in the skinnedClothBlueprint's property setter.

(24-08-2020, 06:04 AM)nexar Wrote: - Currently we have initially deactivated the components "Obi SkinnedCloth" and "Obi SkinnedCloth Renderer", and, in addition, the component "Obi SkinnedCloth" already has in the editor defined the reference to an existing blueprint, which we update with the new values, and after that we activate both components. But it seems that this is not working...
Is there a correct way to pause the Solver, or do we just have to deactivate these components while updating the blueprint, and then reactivate them, in order to force the reading of the new blueprint?

There's no need to do any of that. Simply assigning the new blueprint should be enough, the property setter takes care of all this.
Reply


Messages In This Thread
RE: Force reload a new blueprint and save it to a file - by josemendez - 24-08-2020, 07:23 AM