Search code examples
c#godot

How do I have exported C# variables appear in the Godot inspector?


So basically, I'm trying to learn C# and Godot by following a tutorial. During the section where you code the player, I need to have an exported variable (Speed) show up in the Inspector; unfortunately, the variable does not show up. I asked the same question in the official Godot forums but have not recieved a response there yet.

This is an image of the Inspector for my player node:

The Inspector for my player node.

I tried two things to fix my problem:

  1. I copied the code directly from the docs. Here's the code:
using Godot;

public partial class Player : Area2D
{
    [Export]
    public int Speed { get; set; } = 400; // How fast the player will move (pixels/sec).

    public Vector2 ScreenSize; // Size of the game window.
}
  1. I changed the renderer from Compatibility to Forward+.

Solution

  • nvm i figured it out

    it was capitalization.

    EDIT: My fault for not answering properly! I don't code in C# anymore (I use GDScript now), so apologies if my attempts to further explain this still aren't clear.

    Basically, if you don't capitalize your exported variable like camel case but with the first letter capitalized as well (VeryCoolVariable, for example), the variable won't show. Sorry for any headaches that might've been caused by me being dumb a year ago.