Cat-Lips / GodotSharp.SourceGenerators

C# source generators for the Godot Game Engine
MIT License
125 stars 13 forks source link

[SceneTree] generated weird type `_SceneTree.__0_Area3D` #75

Closed valkyrienyanko closed 1 month ago

valkyrienyanko commented 1 month ago

Steps to Reproduce

  1. Clone https://github.com/ValksGodotTools/Template

  2. Switch to spaceship-3d branch

  3. Make sure you are using Redot v4.4.dev.mono.gh [1c7d7fa8d] (their latest beta release at the time of writing this)

  4. Delete the CSharpFolder from Redots release folder and replace it with the CSharpFolder from the latest Godot 4.4 release folder (needed because CSharpFolder not built properly on Redot for some reason)

  5. Make sure you are on this commit in case I change the code the future

Untitled Commit SHA: 7723cdc2949d4373bbce971cc68b6ca18a6bbd84

  1. Open up the SpaceShip.cs script located in res://Genres/3D FPS/Scenes/SpaceShip.cs
  2. Notice the weird type name

Remarks

Have not tested on Godot, don't know if this is a Redot specific bug.

I recently switched from VS2022 to VSCode if that matters.

Screenshots

Untitled

Untitled

Untitled

Cat-Lips commented 1 month ago

Hi Valk.

All those weirdly named types in _SceneTree are wrappers around the actual Godot type to implement the scene tree navigation (not required by leaf nodes). They do have implicit operators that allow them to passed around and used or cast to the Godot type or can be retrieved using a Get() method, eg:

var t = _.Area3D.Get();
var t = (Area3D)_.Area3D;
var t = _.Area3D as Area3D;
var t = Area3D; // where you define property: private Area3D Area3D => _.Area3D;
var t = Area3D; // where generator defines property from unique_name_in_owner = true
valkyrienyanko commented 1 month ago

Thank you