Skip to content

Use 3D related nodes in editor causes runtime issue with disable_3d = true export template #103315

@Delsin-Yu

Description

@Delsin-Yu

Tested versions

Current master [01545c9]

System information

Godot v4.4.rc.mono (01545c9) - Windows 10 (build 19044) - Multi-window, 4 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (NVIDIA; 32.0.15.7242) - AMD Ryzen 9 5900X 12-Core Processor (24 threads)

Issue description

As disable_3d won't work with editor builds, developers, must use an editor with 3d enabled (for generating C# bindings and development), leading to usability problems for GDScript and C#.

For GDScript, scripts that directly reference 3D nodes or nodes' 3D related properties will cause runtime Parse Error:

Details
func _ready() -> void:
	var node3d = Node3D.new();
	add_child(node3d);
SCRIPT ERROR: Parse Error: Identifier "Node3D" not declared in the current scope.
          at: GDScript::reload (res://rotategd.gd:4)
ERROR: Failed to load script "res://rotategd.gd" with error "Parse error".
   at: ResourceFormatLoaderGDScript::load (modules\gdscript\gdscript.cpp:3022)

For C#, scripts that directly instantiates or loads the 3D related binding types will cause TypeInitializationException:

Details
public override void _Ready()
{
    var viewport = GetViewport();
    GD.Print(viewport.OwnWorld3D);
}
ERROR: System.TypeInitializationException: The type initializer for 'Godot.Viewport' threw an exception.
 ---> Godot.GodotObject+NativeMethodBindNotFoundException: Unable to find the native method bind. (Method 'Viewport.set_world_3d')
   at Godot.GodotObject.ClassDB_get_method_with_compatibility(StringName type, StringName method, UInt64 hash)
   at Godot.Viewport..cctor()
   --- End of inner exception stack trace ---
   at Godot.Viewport.IsUsingOwnWorld3D()
   at Godot.Viewport.get_OwnWorld3D()
   at Rotate._Ready()
   at Godot.Node.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret)
   at Godot.CanvasItem.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret)
   at Godot.Node2D.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret)
   at Rotate.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret)
   at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** args, Int32 argCount, godot_variant_call_error* refCallError, godot_variant* ret)
   at: void Godot.NativeInterop.ExceptionUtils.LogException(System.Exception) (:0)

Steps to reproduce

  1. Compilte the Godot Editor with mono_enabled:
    scons p=windows module_mono_enabled=yes compiledb=yes debug_symbols=yes
  2. Generate the mono glue:
    .\bin\godot.windows.editor.x86_64.mono.console.exe --headless --generate-mono-glue modules\mono\glue
  3. Build the C# SDK:
    python .\modules\mono\build_scripts\build_assemblies.py --godot-output-dir=.\bin
  4. Build the export template with mono_enabled & disable_3d
    scons p=windows module_mono_enabled=yes debug_symbols=yes target=template_release arch=x86_64 disable_3d=yes
  5. Reproduction:
    a. For GDScript, create a project with GDScript that directly references 3D types (Node3D, etc.).
    b. For C#, create a project with C# script that directly or indirectly references 3D types (Node3D, Viewport, etc.).
    c. Alternatively, open the MRP Project.
  6. Export the project with the built export template.
  7. Run the exported project and observe the issue.

Minimal reproduction project (MRP)

Test2dProject.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions