playMaker

Author Topic: Prefabs messing up my project!  (Read 2816 times)

Slater

  • Full Member
  • ***
  • Posts: 123
Prefabs messing up my project!
« on: August 19, 2014, 11:33:00 PM »
So I finally took the step and created a prefab for my menu system. In all my scenes I have a menu, where you can press a button on the side and a menu slides into view. There is also another button in that menu that pulls down another panel from the top, where you can choose to jump between chapters/scenes. I had to update some stuff now in it and up until now I have had only made a copy of it and pasted it into all the scenes. It was a hassle doing manually updates for all the scenes so I figured I would try out prefabs so I made the whole menu into one with all subparts.

The first problem was that in the cover scene and another scene, I needed it to be a bit different. So I did changes to it that I didn't apply. But for some changes still was put through to everything.

Then I noticed that when I had made the menu that a FSM I had for changing font size (font+ and font-) had target objects outside of the prefab that it applied the font size changes to. The game objects with the gui text objects on them. When I created the prefab it lost the linking to those object. I then clicked on change prefab in the FSM for the fonts, but it didn't let me add the gui text game objects outside of the prefab. So then I was forced to drag them into the menu and in order for it to stick to the prefab I dragged the menu to the prefab in my project folder. Then all seamed to be working and I did some other sizing changes to some images within the menu and applied it.

I then built for iOS and saved and closed down Unity, was going to bed. I then tried the app and noticed that everything had changed and there was no longer any subtitles at all in the app. So I checked Unity and now the text objects are totally missing from the project all together. Poof, disappeared with all their settings.

What the hell. What is going on?
« Last Edit: August 19, 2014, 11:43:26 PM by Slater »

Slater

  • Full Member
  • ***
  • Posts: 123
Re: Prefabs messing up my project!
« Reply #1 on: August 20, 2014, 12:20:10 AM »
Also even though I had them within the prefab I couldn't just add the font objects to the FSM target object. I had to do something in order for the menu to break away from being a prefab and then I could add them and then I updated the prefab with the new things.

Slater

  • Full Member
  • ***
  • Posts: 123
Re: Prefabs messing up my project!
« Reply #2 on: August 21, 2014, 11:01:07 AM »
What is wrong? Why isn't it possible to add a game object to an object variable when it is a prefab?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Prefabs messing up my project!
« Reply #3 on: August 21, 2014, 11:31:36 AM »
Hmm, not super sure what is happening but with the way Unity does prefabs it can be frustrating sometimes, yeah... Here's some general stuff I've come across over time...

  • You can't have a Prefab linked to a scene object. Unity might still let you magically link it but the link will be removed either when you press play or when you restart Unity.
  • You can happily link Prefabs to Prefabs, for instance for spawning projectiles you could have a prefab Gun setup to create the Bullet prefab. That won't break. However...
  • Prefabs cannot be nested or derived. You cannot have a 'Gui Gfx' prefab and a separate 'Gui Text' prefab and then try to make a 'Gui Menu' which is both of those prefabs put together. It will take all of the individual parts and create a unique prefab and won't have any link back to the original prefabs.

There's a big official thread about Prefabs, what they are, what they should be, etc.. over on the Unity forums, maybe reading up on that will give you some ideas about how prefabs can work in practical application since a lot of devs have game published and have posted feedback on the Prefab setup in Unity.

Hopefully that helps a bit, I couldn't really tell what exactly might be wrong but it sounds like prefabs being mishandled.

Prefabs documentation
Unity Prefab Feedback Thread
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D