Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

godot

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+.
like image 499
DragonAero Avatar asked Feb 03 '26 09:02

DragonAero


2 Answers

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.

like image 200
DragonAero Avatar answered Feb 05 '26 23:02

DragonAero


For others having this issue, I solved my issue by changing the renderer from Mobile to Compatibility. So that might be worth a shot.

like image 36
shweshipu Avatar answered Feb 05 '26 23:02

shweshipu