C# public parameter with custom get/set doesnt shown in the Inspector

private bool _showFps;
public bool ShowFps
{
get { return _showFps; }
set
{
_showFps = value;
GameObject.FindGameObjectWithTag(“EnvironmentFps”).GetComponent().FpsEnabled = value;
}
}

_showFps configured in the Start() from correct Object/component.

Why this Parameter doesn’t show in the Inspector?

The easiest way is to mark the private backing field “_showFps” as serializable, so it can be saved:

[SerializeField]
private bool _showFps;
 public bool ShowFps
         {
             get { return _showFps; }
             set
             {
                 _showFps = value;
                 GameObject.FindGameObjectWithTag("EnvironmentFps").GetComponent<fps>().FpsEnabled = value;
             }
     }

To elaborate: Properties can’t show up, because they are methods, not data. Only their backing fields, the regular “variables” store information. This data must also be understood by Unity’s serialization system. Unity serializes public variables by default. To tell it to also save private fields, you can use the [SerializeField] attribute.

If you want to have Properties Show up in the inspector, you’ll need to dabble a bit in Editor Scripting.

Since Properties can behave in several different ways, my guess is that having Unity generically show them by default might be a little tricky. Some properties could be “publicly get” but “privately set”, or vice versa, which creates all sorts of rendering conditions that would have to be accounted for.

But since you know the context which your properties can be viewed you can easily create a special OnInspectorGUI to properly render your properties

C# properties don’t show up in the inspector, for some reason. Make it a public field instead:

public bool showFps;

Did anyone figure out how to make these properties properly serializable / settable through the animator?