I’m testing out Structs in Unity by making a Public Struct containing 3 int variables and then try assigning a value to each in the Start method. The problem is that I am getting a CS0122 error stating “`variable’ is inaccessible due to its protection level”.
What is the problem here and how can I fix it? I’ve put the code bellow. Please Help!
Thanks!
Code:
using UnityEngine;
using System.Collections;
using System;
public class Weapons : MonoBehaviour {
public struct WeaponSelect {
int weapon;
int ammo;
int maxAmmo;
}
// Use this for initialization
void Start () {
WeaponSelect.weapon = 1;
WeaponSelect.ammo = 30;
WeaponSelect.maxAmmo = 200;
}