playMaker

Author Topic: Prefabs not retaining settings  (Read 2734 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Prefabs not retaining settings
« on: June 21, 2011, 05:43:33 PM »
This is driving me nuts. 

I have several prefab objects with FSMs on them.  Whenever I load a different scene, the prefab has dropped half its settings.  Variable assignments, gameobject IDs, whatever.  It's worth mentioning that this is not a case of forgetting to press "Apply" or save the prefab and/or scene.  This is consistent and widespread in my project.  I'd love it if someone could please tell me what I'm doing wrong, because I'm certain it's an issue of ignorance on my part, but it's killing me. 

Here's a very specific scenario:
I have one gameobject that controls my menus, level loading, and variables used throughout the game.  It uses a series of custom events, such as "sys_startGame" which is used in the title menu to begin play.  I made this object a prefab, and it exists in multiple scenes so I can easily assign other gameobjects to its various states. 
Now, if I am editing the title screen ("scene01"), I set everything up with the prefab, hit apply, save the scene, and load the next scene I want to edit ("scene02").  In scene02, the events I assigned in Scene01 are reset to "None".  I am forced to revisit every state that sends an event and reapply the events it should be sending.  It doesn't seem to matter though, because as soon as I return to Scene01, they're reset again.

As always, thank you for any help or advice!

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Prefabs not retaining settings
« Reply #1 on: June 21, 2011, 06:32:09 PM »
In Unity prefabs cannot reference scene objects - the references will not survive save/load.

The instance of the prefab in the scene can reference scene objects as it is saved with the scene.

IOW, don't hit Apply - that should work...

If you don't want to override the prefab, then the prefab needs to "discover" the scene objects at runtime (e.g., using a naming or scene convention)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Prefabs not retaining settings
« Reply #2 on: June 21, 2011, 06:37:42 PM »
Thank you very much.  I will try this now.

Any idea about the events not staying though?
« Last Edit: June 21, 2011, 06:49:38 PM by artician »