I’m essentially trying to create a simple inventory type list using unity’s GUI. However I receive this error when trying to run my script. I believe the problem is caused by the variable different items not being constant. If anyone could show me how I should call differentItems as a constant (if that truly is where the error is occurring) that would be extremely helpful.
using UnityEngine;
using System.Collections;
public class Inventory : MonoBehaviour
{
int differentItems = 200;
int[] itemCount = new int[200];
int fifthWidth = Screen.width/5;
string[] itemName = new string[differentItems];
public Vector2 scrollPosition = Vector2.zero;
void OnGUI ()
{
scrollPosition = GUI.BeginScrollView(new Rect(Screen.width - fifthWidth, 0, fifthWidth, Screen.height), scrollPosition, new Rect(Screen.width - fifthWidth, 0, fifthWidth, (Screen.height/20) * differentItems));
for(int i = 0; i < differentItems; i++)
{
GUI.Button(new rect(0,(Screen.height/20 * i), fifthWidth * (4/5), Screen.height/20), itemName*);*
_ GUI.Label(new rect(fifthWidth * (4/5),(Screen.height/20 * i), fifthWidth * (1/5), Screen.height/20), itemCount*);_
_ }_
_ GUI.EndScrollView();_
_ }_
_}*_