Search Unity

Prefab feature suggestion

Discussion in 'Prefabs' started by TheCelt, Dec 20, 2020.

  1. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    742
    Hello I want to make a suggestion about prefabs but do not know where to post it. There is no suggestion website that i can find and i think this is a simple and great quality of life improvement for the prefab system.


    My Idea:
    -----------------------------------------------


    I would like a feature where we can create Prefab Templates. This would basically be a prefab as a base but cannot be placed in the scene, only variants of it can be. This would be similar to the idea of abstract classes in C# that prevent you from creating instances of the base class.

    That way you can make changes to the template and it will change all variants from it - but the template itself does not get instantiated, it is just a developers tool (you cannot reference to it in the inspector either).

    The asset folder would show it like this, this makes it very easy to understand with little explanation required:

    Code (csharp):

    1. Prefab Template¬ // this cannot be added to scene
    2. Prefab Variant 1¬
    3. Prefab Template (of Prefab Variant 1)¬ //this cannot be added to scene
    4. Prefab Variant 1.1
    5. Prefab Variant 2
    6. Prefab Variant 3
    The rule of prefab layouts would then go like this:

    1) All prefabs must be in a Prefab Template

    2)
    Prefab templates can be empty if you have no base requirement

    3)
    A prefab variant that has its own variants, must have a prefab template in its hierarchy with the variants in the respective template. (see prefab variant 1 in the above example).

    4)
    Templates do not act as game objects or have transform components (since all variants by default must have these components), they only have the components you want the variants to have (think like a C# interface). Only the variants of templates have the GO behaviour and Transform component added as required. So the template basically contains scripts/components as a reference to what the variants will inherit when created including serialized data in the inspector etc etc.

    5) Right clicking on the prefab template -> Create Variant will create a prefab with all the components of the all parent templates, right up to the root template, with the most immediate parent templates overruling the other templates for components where two templates have the same component but different values.

    This makes it very clear from a user experience and readability perspective of using prefabs.

    Currently its not quick and easy to tell which prefabs are variants of which prefabs unless i am careful with the naming or have folders and sub folders etc in the asset folder which is just a hassle and unnecessary. Additionally i make base prefabs which i don't use in the scene to make it easier to modify all variants but i have to consciously remember not to include it in the scene... in big teams this mistake could easily happen.
     
    gillemp likes this.
  2. Marc-Saubion

    Marc-Saubion

    Joined:
    Jul 6, 2011
    Posts:
    655
    I think a simpler and broader feature would be the ability to hide certain assets from search results Things like materials and icons from a plugin for example tends to clog them with unnecessary data that we won't ever use.

    This way you could hide these base prefabs and team members wouldn't be tempted to use them.
     
    JesOb likes this.
  3. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    742
    Thats just more clutter and things to remember.

    Plus the point isn't just that, the point was the prefabs inherit in the same fashion classes inherit from base classes, its intuitive because people understand it in a hierarchical sense.