Question by
adambarakat3 · Oct 02, 2020 at 08:47 PM ·
gameobjectlistsindexof
Trying to get the index of a gameObject in a list
I'm trying to get the index of the element attached to the script in a list but it keeps telling me : "No overload for method 'IndexOf' takes 1 arguments"
public class TaskInfo : MonoBehaviour
{
public GameObject[] allTaskSpots;
public int DayOfTask;
public int TaskNumber;
public Vector2 StartTime;
public Vector2 EndTime;
public string Task;
public bool LastTask;
public bool rightlane;
// Start is called before the first frame update
void Start()
{
string oname = gameObject.name;
allTaskSpots = GameObject.FindGameObjectsWithTag("Task");
TaskNumber = allTaskSpots.IndexOf(gameObject);
Vector2[] TaskTime = {StartTime, EndTime};
DayOfTask = (int)DateTime.Now.DayOfWeek;
}
}
Comment