Search Unity

Need further info on Prefabs.

Discussion in 'General Discussion' started by zumwalt, May 2, 2007.

  1. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Am I understanding this correctly, a prefab takes up less room in the compiled version of the game vs individual units? Meaning I make 1 tree, set it up, etc, then turn that into a prefab. Then place the prefab all over the board, and that takes up less room than if I did each tree individually?

    I am playing with prefabs now, rather amused by them and love the concept of 'change once, modify many', I have done it to my forest, and I did it to a building, both after I setup there initial size, material modifications, collision attributes, etc. This was very handy to do prior to making them a prefab.

    Just trying to get a feel of others as to what they have seen when they use objects as prefabs vs individual objects. Oh, and what I don't get, is when you are on scene view, you have a show prefab button, but it does nothing. Clicking it doesn't hide the prefabs, or show them or change there color from blue in the list or anything, is this a future item?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You mean the hierarchy view? If you have it pressed, and then click on a prefab in the hierarchy, it shows you where the prefab is in the project view by drawing a line.

    --Eric
     
  3. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
    Not really. Unity is already very smart about reusing assets, so each mesh, each texture, and each audio is only stored once, no matter how often it's used, and no matter if you're using it in prefabs or not.

    Prefabs are super handy. There are some sbutleties, so at some point you should read through the manual section about them:

    http://unity3d.com/Documentation/Manual/Prefabs.html

    Is this while you're playing the game? The "show prefab" is for finding out where a prefab "came from". This doesn't work while the game is playing, and doesn't work from the scene view. If this will work in the future? Maybe, but I guess we have bigger fish to fry :)

    d.
     
  4. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Thanks for the responses. Right now, prefabs are coming in very handy for my buildings and other static objects. What is so awesome about it, is that I layout my level, then when I play it, I see where I need to rescale some things, so updating the prefab scales every livid thing on the board attached to that prefab, totally sweet. Although I would like to see a 'constrain properties' so I don't have to update the x,y,z manually, but its definately not a show stopper, just 3 clicks and typing :)

    The prefab button I figured would either show or hide the prefab in the list, not draw a line to it, I'll have to look at that tonight when I get home. Maybe take a screen shot.