instantiate prefabs unity code example

Example 1: Unity C# instantiate prefab

Instantiate(myPrefab, new Vector3(0, 0, 0), Quaternion.identity);

Example 2: instantiate prefab

Instantiate(tree, new Vector3(0, 0, 0), Quaternion.identity);

Example 3: unity C# instantiate prefab

GameObject prefab = reference_to_your_prefab_asset;
Vector3 position = Vector3.zero;
Quaternion rotation = Quaternion.identity;
Transform parent = parent_of_instantiated_prefab;

Instantiate(prefab, position, rotation, parent);