Prefabs : |
For Detail You Can Refer from Here
Now Lets See How to use it in Game ..
Just made one sample project in Unity3d . Like
Steps :
1) Go Into File
2) Select New Project
3) Now Create new Scene
4) Take An Empty Object
5) Now From Assets -> Create New -> Prefab ..
Now Create New C# Script name PrefabDemo.cs
Now write in that :
using UnityEngine;
using System.Collections;
public class preafabDemo : MonoBehaviour
using System.Collections;
public class preafabDemo : MonoBehaviour
{
public GameObject enemy;
Now For instantiate Object You Need to write :
// Use this for initialization
void Start ()
{
Instantiate(enemy,new Vector3(3,10,0),Quaternion.identity);
}
Instantiate(enemy,new Vector3(3,10,0),Quaternion.identity);
}
So For Continue Instantiate of Object
// Update is called once per frame
void Update ()
void Update ()
{
Instantiate(enemy,new Vector3(Random.value * 23.0f,Random.value*25.0f,Random.value * 24.0f),Quaternion.identity);
}
Instantiate(enemy,new Vector3(Random.value * 23.0f,Random.value*25.0f,Random.value * 24.0f),Quaternion.identity);
}
}
So ,From This You can instantiate Object in your game continue .
You Can Download Source Code From Here--
Vivek P Shah
Game Developer In Unity3d And Cocos2d
Skype : viveks2012
Thanks, that helped me a lot!
ReplyDeleteUnity's reference is good, but doesn't actually work.
There is also the fact that you have to assign the object to be instantiated later in the editor, something that no one seems to point.
AAb Ki Bar Modi Sarkarr..............
ReplyDelete