Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assigning a bool to modulate.a (color alpha) works in debug if declared but not in release. #62307

Open
svendixon opened this issue Jun 22, 2022 · 2 comments

Comments

@svendixon
Copy link

Godot version

3.4.4.stable.official

System information

Windows 10

Issue description

The title pretty much explains it.

This works is debug but not in release:

extends Node2D

onready var icon = $Icon as Sprite

func _ready() -> void:
    icon.modulate.a = false

However if you don't declare and simply assign it, you do get the error of assign type bool to an alpha color.

extends Node2D

func _ready() -> void:
    $Icon.modulate.a = false

I don't know what is intended, if this should fail or not, but it should at least be consistent in both debug and release.

Steps to reproduce

  1. Drop the icon.png into a 2D scene
  2. Assign a script to the scene and declare the icon
  3. In _ready set the icon's modulate alpha to false
  4. Export a release build and compare

I have attached a simple project .zip with a windows release build in its project folder.

Minimal reproduction project

modulate_alpha_with_bool

ModulateAlphaWithBool.zip

@Calinou
Copy link
Member

Calinou commented Jun 22, 2022

Can you reproduce this on 3.5.rc4? Type information is now included in release builds, so this kind of typing discrepancy between release_debug (editor) and release builds should be gone now.

@svendixon
Copy link
Author

Yes it works in 3.5.rc4. Thanks!

However, it highlights a difference when writing gdscript in general, should it throw an error when you don't declare it and work fine if you do?

onready var icon = $Icon as Sprite

func _ready() -> void:
   # Works
   icon.modulate.a = false

   # Gives error
   $Icon.modulate.a = false

Or should we just convert the type in script int(false), and avoid these little things? Just incase Godot under the hood doesn't just do it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants