In my script, i have declared an array of GameObjects like this:
public GameObject[] go;ld object name. `String temp;`
Also, i have a temporary variable to ho Then, i assigned objects to elements in Inspector.
I'm using Raycasting to find which object was clicked. Block of code for handling Raycast:
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit2D hit = Physics2D.Raycast (ray.origin, ray.direction, Mathf.Infinity,layerMask);
if (hit) {
temp=hit.collider.gameObject.name;
index=ArrayList.IndexOf(go,GameObject.Find (temp));
}
Ray casting works well. It will print object name if i insert a Debug.Log. However, what i want to do is, find the GameObject's index in the array "go". I need this index because i have another boolean array isSelect[] which, has a property that needs to be set to true when the corresponding GameObject is selected.
With the IndexOf code above, i get the following error:
An object reference is required to access non-static member `System.Collections.ArrayList.IndexOf(object)
What changes do i need to make to this code?