Atavism Prefab Creation
Folder Structure
You will need to create many prefabs for your game, so it’s a great idea to create a folder structure that will allow you to quickly identify the items. In our example here, we have created the HNGamers folder with a Resources folder under that. We have two folder structures, one for our parent prefabs and one for the variants we will create from the parent items.
Note: Unity merges folders during the build process. Any folder that is named Resources get’s merged into a single folder structure and is where Unity loads it’s prefabs from. You can store prefabs outside of this location, but it’s required that any prefab that is loaded be stored in this folder structure to operate properly.
Prefab
There are two types of prefabs in the system, standard prefabs and prefab variants. Each of these are templates for storing specific information about how that item is created, viewed and stores values associated with scripts attached to the object.
Original Prefab
This is the original prefab that you create or receive from the asset store when you purchase a package. These prefabs are the originals and any time you update a package from the asset store, it will overwrite these prefabs with the updated version. This is why it is highly important to create your own prefabs from the original and then work with those items. This is the process we will cover in this tutorial.
Parent Prefab
This is the basic prefab that is used in Unity, create a new prefab from an original model and this is what you will create. This would be considered the original or parent prefab for your game item. On this you will add scripts, add animators and adjust functionality. Unity will make instances of this prefab when it is loaded and they will be exact clones of these items. Prefabs made from Prefabs will be unique items and will not change when you update the original prefabs. The recommended process would be to create a prefab variant below of your parent prefab and make any changes on those items. If you use the Atavism Toolbox, it will create your Parent and Variant prefabs for you.
See the Unity Manual: https://docs.unity3d.com/Manual/Prefabs.html
Variant Prefab
Prefab variants are useful when you want to have a set of predefined variations on your models, where you maye color shift an item, add additional scripts, change model display items. Exactly like Parent prefabs above, Unity will make instances of this prefab when it is loaded and they will be exact clones of these items. Prefabs made from Variants will be cloned from the parent and will adjust any settings you are not overriding when you update the original prefabs. The recommended process would be to create a prefab variant of your parent prefab above and make any changes on these items. If you use the Atavism Toolbox, it will create your Parent and Variant prefabs for you.
See the Unity Manual: https://docs.unity3d.com/Manual/PrefabVariants.html
Nested Prefabs
Nest prefabs are part of the Unity system and is how Atavism handles building out a mob and various items in game. When you are creating mobs you will create two items, a MobAsset which is the prefab you are generating above and a Mob Loader. The loader will contain a set of scripts which will define the mob and then target the prefab shown above and load it. During play, Atavism loads these two files and creates a nested prefab during runtime that contains all of the items above.
You can add any number of prefabs to another prefab, while your in prefab mode. You can apply overrides from prefab mode to the parent prefabs.
See the Unity Manual: https://docs.unity3d.com/Manual/NestedPrefabs.html
Parent Prefab Creation
Dragging the item that is in the scene view and then into the folder structure we created for this character earlier. This will pop up a dialogue box which will ask you to select between Original Prefab or Variant. For this one, we will choose the Original Prefab. We can make any number of variants from this prefab and any changes we make will be to this item will be applied to all variants, except where we override those on the variant.
Variant Prefab Creation
Dragging the Original (parent) prefab back into the scene and then dragging the item that is in the scene view and then into the folder structure we created for this characters variants earlier. This will pop up a dialogue box which will ask you to select between Original Prefab or Variant. For this one, we will choose the Variant Prefab. We can make any number of variants from the parent prefab. Any changes made to these variants, only apply to these variants.