Generic Prefab Constructor

Initially, this script should not be attached to any gameobject as it is the base of all different type of constructors.

It contains selections (and functions) for the developer that are going to be found in any type of prefab constructor:

Variable Name

Type

Description

Prefab Perform Action

Destroy, Remain

Select if the prefab after action completion should remain in the scene or if it should be destroyed.

RigidBody Type

Kinematic, Gravity

Select if the prefab is Kinematic or if it has Gravity. For interactable prefab that always have physics properties this selection counts ONLY for when they are spawned, and it lasts till they are grabbed from the user. Upon user’s release they automatically turn back to gravity.

Different Layer

Default, GrabbablePrefabs, TriggerColliderLesson, NoTriggerColliderLesson

Also these layers can be selected: cloth, AllBones, ModelSkin. They are not required to be created from the developer. As told before, each prefab depending on the attached constructor, is going to have a corresponding layer. If the developers need some parts of the prefab to be in another layer, then in this variable they should select the desired layer and in the next variable drag ‘n’ drop the parts of the prefab that this different layer is going to be applied.

Children Different Layer

Prefab’s Children

Insert here all the prefab’s children that need to be in a different layer. Leave empty if no child is desired to be changed.

Function Name

Description

public virtual void ResetPrefab()

Resets the prefab to its starting position and rotation.

public virtual void SetNewPrefabStartingTransform()

Changes the prefabs starting position and rotation from the values the gameobject had on spawn to the values the gameobject has on the time this function is called.

public virtual void FinalizePrefabAction()

Internal function called on Action end to finalize prefabs behavior. Can be overridden to add to the prefab functionalities.