godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.02k stars 21.1k forks source link

[3.6 Beta] Exported Script CANNOT be given with a default value if assigned without `= null` #76281

Open Lazy-Rabbit-2001 opened 1 year ago

Lazy-Rabbit-2001 commented 1 year ago

Godot version

3.6 beta1 ~ beta 4

System information

Windows 11, GLES3

Issue description

动画 As the gif displays, when I dragged the script resource to exported variable typed as Script without "= null" assigned, nothing happened on its inspector dock, neither did i pop the menu to add it manually. Also, it showed "null" when running; thus it was actually blocked from setting its value Problematic code:

export var custom_script: Script

Workaround code:

export var custom_script: Script = null

Steps to reproduce

  1. In an existing project, create a node and create a script for it
  2. In that script, set some exported variables and type them as Script or GDScript, without "= null" assigned to that property
  3. Write a new GDScript code, no matter what you want to write
  4. Drag the written one to the inspector dock of that exported property and you will see nothing happened

Minimal reproduction project

Test.zip (Note: Open Goomba.tscn and locate to EnemyKilled)

Lazy-Rabbit-2001 commented 1 year ago

Sometimes it would pop with this image

Lazy-Rabbit-2001 commented 1 year ago

the bug remains in beta 3