Created
May 22, 2014 23:38
-
-
Save Naxum/e42f37e15bb503913ec5 to your computer and use it in GitHub Desktop.
How to spawn a gameobject with a component and keep track of it
This file contains 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; | |
using System.Collections.Generic; | |
public class ActorManager : MonoBehaviour | |
{ | |
public Actor actorPrefab; | |
public List<Actor> actors = new List<Actor>(); | |
void Start() | |
{ | |
Actor actor = (Instantiate(actorPrefab.gameObject, Vector3.Zero, Quaterion.Identity) as GameObject).GetComponent<Actor>(); | |
//do anything to actor | |
actors.Add(actor); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment