Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity create 3d object in script

//You need to create the object you whant to spawn and then drag it to your assets. This will create a prefab.
//to the script part
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawn : MonoBehaviour
{
//here we declare a variable wich in it is stored our prefab (you need to drag it there in the inspection menu in unity)
    public GameObject prefabtospawn;
    void Start(){
        //now we will spawn our prefab and store it in a variable caled clone
        Clone = Instantiate(prefabtospawn, gameObject.transform.localPosition, Quaternion.identity) as GameObject;
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: trim c# 
Csharp :: unity how to destroy child 
Csharp :: .net mvc return a specific View 
Csharp :: c# change language version to 9.0 
Csharp :: hwo to prevent rotation after hitting an object in unity 
Csharp :: c# file watcher 
Csharp :: c# new list of objects 
Csharp :: c# add element to array 
Csharp :: datetime month name 
Csharp :: how to change dictionary value in c# 
Csharp :: c# array max 
Csharp :: c# mongodb get all documents 
Csharp :: how to read a text file C# 
Csharp :: trygetvalue dictionary c# example 
Csharp :: how to get unique list in c# 
Csharp :: c# remove duplicates from list 
Csharp :: unity yield return 
Csharp :: c# get classes which inherits 
Csharp :: select random from enum c# 
Csharp :: returning multiple values in C# 
Csharp :: vb.net read text file line by line 
Csharp :: linked list revrse 
Csharp :: c# Dictionary contains key case insensitive 
Csharp :: linq find object from id 
Csharp :: c# how to compare 2 dates without time 
Csharp :: unity set parent canvas 
Csharp :: get quaternion from vector unity 
Csharp :: unity c# move transform 
Csharp :: c# gettype 
Csharp :: hide numericUpDown arrows 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =