Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

IndexOutOfRangeException: tanks index is invalid , i was trying to add new Tank in Tanks!!! game but get this error , iam new in coding

$
0
0
//Returns whether a tank for a given index is unlocked. public bool IsTankUnlocked(int index) { if (m_Data.unlockedTanks.Length > index && index >= 0) { return m_Data.unlockedTanks[index]; } return false; } //Allows a tank index's unlocked status to be set. Defaults to unlocking the tank. public void SetTankUnlocked(int index, bool setUnlocked = true) { if (m_Data.unlockedTanks.Length > index && index >= 0) { m_Data.unlockedTanks[index] = setUnlocked; } else { throw new IndexOutOfRangeException("Tank index invalid"); } SaveData(); } //Returns whether a decoration for a given index is unlocked. public bool IsDecorationUnlocked(int index) { if (m_Data.decorations.Length > index && index >= 0) { return m_Data.decorations[index].unlocked; } return false; } //Allows a decoration index's unlocked status to be set. Defaults to unlocking the decoration. public void SetDecorationUnlocked(int index, bool setUnlocked = true) { if (m_Data.decorations.Length > index && index >= 0) { m_Data.decorations[index].unlocked = setUnlocked; } else { throw new IndexOutOfRangeException("Tank index invalid"); } SaveData(); }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>