How to create a new object prefab

Easy AR already included prefabs in the EasyAR->Prefabs folder. All these prefabs are made in a specific structure. From this section we guide you to create your own 3d object prefab.

  • Step 1 : Create a new scene named “PrefabBuilder” or desired name you need in EasyAR -> Scenes folder & load the scene.

  • Step 2 : Delete Main Camera and Directional light from hierarchy.

  • Step 3 : Add the 3d object that you wish to create a prefab from EasyAR->Meshes folder. (for example we are going to make a prefab from our pitcher model )

  • Step 4 : Create an empty game object & name it as 3D model name itself. (for example we name it “pitcher”). Reset the transform of that game object.

  • Step5 : Drag & drop the 3D model into the hierarchy window as a child of the empty game object. (For example we select the pitcher 3d model). Reset the transform of the 3d model. Sametime you can add the relevant materials to your object.

Please consider the size of the 3d object can be changed as you desire. Also if you create a vertical placement object make sure object face towards Y up direction

  • Step 6 : Select empty game object which was created before & go to inspector. Add box collider to it & set size same as game object’s (pitcher) size. Also add SpawningObjectDetails script from EasyAR->Common->Scripts to it.

  • Step 7 : Drag & drop the following game objects under the empty gameobject respectively as child objects.

    • Indicator prefab (EasyAR->Prefabs)

      • Adjust the Indicator (position, rotation and scale)

        accordingly to the object vertical or horizontal placement.

    • WorldSpaceCanvasPrefab (EasyAR->Prefabs)

    • Shadow Plane Prefab (Goto Shadow map generation to see how to generate the

      shadow plane)

  • Step 8 : Select Empty object (pitcher) & go to Inspector. Under the SpawningObjectDetails script you have to drag & drop below three prefabs accordingly.

    • For Shadow Plane, drag & drop gameobject’s shadow prefab (pitcher shadow) from hierarchy.

    • For Touch Indicator, drag & drop Indicator prefab from hierarchy.

    • For Scale Percentage Indicator, drag & drop the WorldSpaceCanvas prefab from hierarchy.

  • Step 9: Set the plane detection mode in the Spawning object details component into Vertical or Horizontal. (Do not set it as Everything)

  • Step 10: To create the prefab you can go to the Easy AR->Prefabs folder and drag and drop the Empty object (pitcher) to this folder.

You are done...Now you have created your own prefab to be spawned.

Last updated