playMaker

Author Topic: Prefab variables (I searched, I swear) [SOLVED]  (Read 8401 times)

sourcerer

  • Playmaker Newbie
  • *
  • Posts: 3
Prefab variables (I searched, I swear) [SOLVED]
« on: March 23, 2012, 12:57:21 AM »
Hmmm, am evaluating PlayMaker to see if after the odd 20 years I can drop the 'code everything from scratch habit' and just found this out and can't believe it to be the case, but....

When I create a variable on a FSM, pack the gameobject with FSM in a prefab and then create multiple instances of the prefab and change variables that are exposed to the inspector on those instances, they are reverted to the prefab values at startup. Is this expected behaviour?

I searched the forum for "variable", "inspector", "prefab" and results point to a few threads that seem to imply this is indeed the case, but I refuse to believe it. How would you make a button prefab that sends a different message for each prefab?

Are FSM variables indeed shared between all instances of the FSM? That would seem odd and would pretty much defeat the purpose of prefabs. I certainly must be missing something as this is the core strength of the prefab system, that you can have custom overrides?

« Last Edit: March 23, 2012, 01:17:05 AM by jeanfabre »

sourcerer

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Prefab variables (I searched, I swear) - solved too
« Reply #1 on: March 23, 2012, 01:13:58 AM »
Oh wow, I think I found the answer to that. First off, thank God, it can be done.

It is kinda confusing that I have to change a setting in the FSM window to have values in the inspector actually apply, but okay, I guess after the first 500 times I'll get used to that - time will tell.

An editor setting to have it behave the way default unity does would be nice - old dogs and new tricks tend to clash.

Anyhoo, nothing to see here, move along.




jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Prefab variables (I searched, I swear)
« Reply #2 on: March 23, 2012, 01:16:12 AM »
Hi

Yes, I think you might have a problem on your end. I tested here to make sure, and it is indeed working.

 I created a prefab with a fsm variable, made that gameObject as a prefab, instantiated several, and changed that variable value on each of the instantiated prefabs and they do behave as expected.

 note: be careful with the unity set of buttons for prefabs ( Select | revert | apply), playmaker has his own menu for this ins the editor ( next the lock button of the fsm view ). For example if you want to revert, you'll see in the fsm editor "PRefab instance (modified)", click on it and select "revert to prefab", if you click on the unity button "revert" in the inspector it will not work very well...

Make sure you have the latest version from the app store as well.


Bye,

 Jean

sourcerer

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Prefab variables (I searched, I swear) [SOLVED]
« Reply #3 on: March 23, 2012, 01:59:26 AM »
Jean,

Do you not have to change the option (in the FSM editor) from 'Prefab instance' to 'select gameobject' manually after selecting the gameobject you're about to edit a setting on? Because that's what made it work for me, but would seem the opposite of Unity's default behaviour (where you edit the instance unless you select the prefab)

Thanks,
Kaj

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Prefab variables (I searched, I swear) [SOLVED]
« Reply #4 on: March 23, 2012, 03:40:12 AM »
Hi,

 no, I just dragged the prefab onto the scene, then edit the variables directly, and it worked.

If you edit the prefab, Fsm editor will warn you with an overlay tho.

when I select an instance from the scene, it does properly select the fsm of that instance, not the prefab. Odd.

Bye,

 Jean

jayhfd

  • Junior Playmaker
  • **
  • Posts: 71
Re: Prefab variables (I searched, I swear) [SOLVED]
« Reply #5 on: April 19, 2012, 07:28:30 PM »
I'm confused with this as well. I've only just needed a prefab now so haven't touched them.

I've made a prefab in the project tab and created an instance, and something seems to be messed up. Ie, the prefab I've just instantiated is immediately different to the prefab itself. I'm not sure if there's a bug with undo or the way I was trying to use Unity's Select/Revert/Apply instead of Playmaker's? (PS, where IS Playmakers Apply feature? I've changed things on an instance and wanted to apply it to the prefab, but how?)

So my prefab is in the Project, I drag into Hierachy, and I look at the action of the prefab instance. Prefab instance has different actions. I tried changing the FSM name and instancing, which works, but the actions within the FSM are still not matching the prefab.

After deleting that prefab and 'redoing it' it seems fine. However I also tested a change where I changed a variable in an action, hit revert, and it didn't actually revert that variable. If I add an extra action, change the variable and then revert, then the new action vanishes and the variable reverts! Odd!

Thanks,
Jay

jayhfd

  • Junior Playmaker
  • **
  • Posts: 71
Re: Prefab variables (I searched, I swear) [SOLVED]
« Reply #6 on: April 19, 2012, 07:39:05 PM »
I've also made an instance of a prefab, changed the prefab itself, and then looked at the instance, which is unchanged. Surely this should be auto updating? Hopefully I'm not missing something wildly obvious (I have ZERO prefab experience)

Not only that, I now have the problem again from my 1st post above. I deleted the instance, created a new instance from my new modified prefab, and the instance is still the same old one!

Cheers,
Jay