Created
September 17, 2015 17:32
-
-
Save xanathar/4680ec3e680c1ee37102 to your computer and use it in GitHub Desktop.
Instantiate Prefab By Name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class LevelCloner : MonoBehaviour | |
{ | |
// Use this for initialization | |
void Start () | |
{ | |
Debug.Log ("Enter!"); | |
// prefab must be under Assets/Resources <- important!! | |
object o = Resources.Load ("Dungeon_Kit/Prefabs/Dungeon_Floors_Walls/floor_tile_01"); | |
Debug.Log (o.ToString ()); | |
var floorPrefab = o as GameObject; | |
for (int y = 0; y < 5; y++) | |
{ | |
for (int x = 0; x < 5; x++) | |
{ | |
GameObject floor = Instantiate (floorPrefab); | |
// floor.AddComponent<Rigidbody> (); | |
floor.transform.position = new Vector3 (x, 0, y); | |
} | |
} | |
} | |
// Update is called once per frame | |
void Update () | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment