How to Activate A Single GameObject In An Array In C#

Guys My Problem Is Really Annoying Please Can Any One Give Me An Idea About How to Activate A Single
GameObject Depending On Value For Example When The Value Is One The First Element Is Activated And The Rest Is Deactivated Is There Is Any Way?? Please Quickly I’am Developing A Game!

You can access it by index? I’m not sure I understand the question fully. For example you have an array called gameObjectArray and you want to activate the 7th GameObject. You simple would write gameObjectArray[7].SetActive(true); I hope this helps. Perhaps next time you can provide some code snippets :slight_smile:

My Friend I Know My Questions Are Weird But I Meant To Active A gameObject When A Var Is The Same As It’s Element Number For Example If :-

public GameObject Weapons = new GameObject[0];
public int m_weapon_list;

void Update () {

if ( Input.GetKeyDown(“myKey”) ) {
m_weapon_list += 1;



my Problem is When The Weapons Is Switched The Other Weapons Keeps Active

What I Want To Do Is Activate The Corresponding Element In The Array And Disable The Others Any Idea? If Yes Thanks Very Much! If Not Thanks Too!