Accessing enum from inherited class

Started by
0 comments, last by SeanMiddleditch 10 years, 2 months ago

In C# in my base class Weapon I have declared a enum Firestate like:


enum Firestate
{
    Fire
};
 
public class Weapon : MonoBehaviour
{
    public Firestate firestate;
};

And in a inherited class Gun I use that enum. But I get error CS0052: Inconsistent accessibility: field type 'Firestate' is less accessible than field 'Weapon.firestate'.
When I remove public from firestate there is no error but then I cant use it in Gun since it is private.

Advertisement
The error is pretty descriptive. Your class Weapon has a public enum field, but the enum itself is not public. How could anyone actually use the firestate field if they can't access the values in the Firestate enum? Make the Firestate enum public.

Sean Middleditch – Game Systems Engineer – Join my team!

This topic is closed to new replies.

Advertisement