playMaker

Author Topic: How can I save an object form runtime to project as a prefab?  (Read 5329 times)

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Hi again, any tip how can I do that?
For example I'm going to change a cube shape to hexagonal on the game runtime and then I need to save that new shape as a prefab on project.
Thanks.
« Last Edit: July 25, 2016, 11:03:51 AM by Silicon Power »

Rockstarfreak

  • Playmaker Newbie
  • *
  • Posts: 10
Re: How can I save an object form runtime to project as a prefab?
« Reply #1 on: July 25, 2016, 11:22:29 AM »
I think you can use get property. Read the playmaker get property documantation - its a little bit more complicated than other things.

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Re: How can I save an object form runtime to project as a prefab?
« Reply #2 on: July 26, 2016, 05:16:40 AM »
I think you can use get property. Read the playmaker get property documantation - its a little bit more complicated than other things.

I can't figure out how it can be related to get property!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How can I save an object form runtime to project as a prefab?
« Reply #3 on: July 27, 2016, 06:35:32 AM »
Hi,
how are you changing to the hexa?

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Re: How can I save an object form runtime to project as a prefab?
« Reply #4 on: August 05, 2016, 08:30:14 PM »
Hi,
how are you changing to the hexa?

With morph (blend shape) system, I changed it with morph and now I need to save new shape somewhere in my project.

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: How can I save an object form runtime to project as a prefab?
« Reply #5 on: August 05, 2016, 09:15:04 PM »
Hi,

I looked into this on unity answers (going by the logic of; if you cannot do it in c#, it is very likely (or certain even?) that you cannot do it in playmaker).

So according to unity forums and other support;

There is no way to create prefabs during runtime, only in the editor:

Quote
Answer by aldonaletto
Are you using this script in the Editor or at runtime? As far as I know, prefabs are Editor stuff, and you can't create them at runtime. If you want to let the player construct "prefab-like" objects at runtime, simply declare the "prefab" game object inactive to make it disappear of the scene, and use it as a regular prefab in Instantiate (remember to activate the object when instantiated)
Found here: http://answers.unity3d.com/questions/366273/create-prefab-from-gameobjects-at-runtime.html

But luckily i think the above also gives you a solution. If you want to save objects in the game, just create them in the scene and deactivate them. (You can also parent them under a game object which has a 'dont destroy on load' action and then it will be saved in that object's children during loading of levels.)

Then for playmaker you just need to find a way to reference this object in the 'create object' action.

For example, you could use get child and target the object under which you parented the object you wanted to save.

If im not making much sense, or if you generally need a clearer explanation of how i would do it let me know. My main point of this post was really just to point out that it is impossible to save as a prefab  during runtime.

Hope this helps.
« Last Edit: August 05, 2016, 09:19:09 PM by Zeldag »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How can I save an object form runtime to project as a prefab?
« Reply #6 on: August 06, 2016, 06:11:50 AM »
Hi,
I have not worked yet with morph (blend shape) system,
but maybe if you can save the variables used to morph you could save those and use those to remake the morphed shape

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Re: How can I save an object form runtime to project as a prefab?
« Reply #7 on: August 06, 2016, 07:20:09 PM »
Ok thanks. how about FBX files? as you said I can't save an object as prefab but my original object is an FBX file can I change it on runtime and then save it as a new FBX file?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How can I save an object form runtime to project as a prefab?
« Reply #8 on: August 07, 2016, 06:33:36 AM »
Hi,
That will not be possible,
your best bet is to save the values that are used to change the object and use those.