Impossible access to C# struct elements

So I have this piece of code here, and I’m getting an error accessing to this struct vars because of its level of protection.
I want to avoid making anything public if it is not completely necessary, and tried making these vars internal without success.
I’m not an expert in C#, so I come here to ask for help. Any idea of how making this work?

public class Clock : MonoBehaviour
{
    [System.Serializable]
    private struct GameTime
    {
        private static int day = 0;
        private static int hour = 0;
    }

    [SerializeField] private GameTime gameTime;

    public void SetDay(int day)
    {
        gameTime.day = day;
    }
  1. day and hour are private. That means only members of ‘GameTime’ can access it. Make them public and then Clock can access it. Keep the GameTime struct private if you want to keep only Clock accessing it.

  2. day and hour are static. I’m going to fare a guess that they shouldn’t necessarily be static.

1 Like

True, they didn’t need to be static, and thanks it’s now working :slight_smile: