Obi Official Forum
How to save rope blueprint? - Printable Version

+- Obi Official Forum (http://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (http://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (http://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: How to save rope blueprint? (/thread-3159.html)



How to save rope blueprint? - linkinb - 01-11-2021

Hi,
I create ropes via script using the RopeBetweenTwoPoints.cs sample script.

Once the rope is generated, I want to be able to edit the blueprint to my liking and save the blueprint of the rope for future use.
The only problem is the blueprint is created using 
var blueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();

Now I can edit the rope in playmode but since the blueprint is an instance it doesn't get saved. 
If I save the rope as a prefab the blueprint still dissapears. 
I know I can manually create blueprints and edit them in the editor, but I intend to create 20+ ropes and it would be tedious to manually create each new rope and blueprint.

How can I save a rope as a prefab/save the rope's blueprint after it has been generated and edited in playmode?


RE: How to save rope blueprint? - josemendez - 01-11-2021

(01-11-2021, 12:06 PM)linkinb Wrote: Hi,
I create ropes via script using the RopeBetweenTwoPoints.cs sample script.

Once the rope is generated, I want to be able to edit the blueprint to my liking and save the blueprint of the rope for future use.
The only problem is the blueprint is created using 
var blueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();

Now I can edit the rope in playmode but since the blueprint is an instance it doesn't get saved. 
If I save the rope as a prefab the blueprint still dissapears. 
I know I can manually create blueprints and edit them in the editor, but I intend to create 20+ ropes and it would be tedious to manually create each new rope and blueprint.

How can I save a rope as a prefab/save the rope's blueprint after it has been generated and edited in playmode?

Blueprints are just scriptable objects, so you can use CreateAsset the usual way in Unity:
https://docs.unity3d.com/ScriptReference/AssetDatabase.CreateAsset.html

This will write your blueprint to disk, creating a file in your project that you can then use.