I'm trying to add to a public list from a script on another object. Eventually I want to have spawned units to be entered into a list so I can store which units are spawned in what order. This seems really simple, can anyone help?
**This is the public list:**
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ExampleLister : MonoBehaviour
{
public List FriendlyUnitsOrder;
void Start ()
{
FriendlyUnitsOrder= new List();
}
}
**This is the the script on the object I will eventually turn into a unit:**
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Unit_Default_Friendly : MonoBehaviour
{
void Start ()
{
gameObject.GetComponent().FriendlyUnitsOrder.Add(this.gameObject);
}
}
Thanks in advance for any help.
↧