Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

untiy instanciate prefab


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InstantiateObjectExample : MonoBehaviour
{
    public GameObject objectToInstantiate;

    private GameObject instantiatedObject;

    private void Awake()
    {
        CreateInstanceOfObject();
    }

    private void CreateInstanceOfObject()
    {
        instantiatedObject = Instantiate(objectToInstantiate, transform.position, Quaternion.identity);

        instantiatedObject.transform.localScale = new Vector3(2f, 2f, 1f);
    }
}

Source by codefantasy.org #
 
PREVIOUS NEXT
Tagged: #untiy #instanciate #prefab
ADD COMMENT
Topic
Name
3+3 =