Issues with exporting script variables

TentaTenta Posts: 8Member

I'm encountering an issue where a perfectly working script's variables randomly decide to not show themselves in the inspector.

Does anyone know what would cause such behaviour?


Tags :

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 3,103Admin

    I’ve never had exported variables disappear randomly in the editor. Do you mind sharing an example script? Maybe something there is causing the problem.

  • TentaTenta Posts: 8Member
    edited June 2019

    @TwistedTwigleg said:
    I’ve never had exported variables disappear randomly in the editor. Do you mind sharing an example script? Maybe something there is causing the problem.

    https://github.com/TiGBS/Guul/tree/rebuild/Guul/Character

    Here is the link to the project folder.
    The issue occurs with the gul_char.gd and gul_form.gd scripts attached to the root of Guul.tscn and GuulBase.tscn respectively.

  • TwistedTwiglegTwistedTwigleg Posts: 3,103Admin

    Looking at both files, I think the reason they are not appearing in the editor is because some (all in gul_char.gd) are missing the export keyword before the function. Any variable that needs to be exposed to the editor has to have the export keyword before it, otherwise Godot doesn't know to show it in the editor.

    Another thing that might be contributing to the issue is for the variables that do have the export keyword, you do not specify which type to use. You can specify which type by using the following syntax: export (type) var variable_name = default_value. So for line 4 in gul_form.gd for example, you would want to change it to the following: export (float) var run_acceleration := 50.0

    But other than the two things I listed above, looking through the scripts I don't see anything else that could be contributing to the variables not appearing in the editor.
    Hopefully this helps!

  • TentaTenta Posts: 8Member

    @TwistedTwigleg said:
    Looking at both files, I think the reason they are not appearing in the editor is because some (all in gul_char.gd) are missing the export keyword before the function. Any variable that needs to be exposed to the editor has to have the export keyword before it, otherwise Godot doesn't know to show it in the editor.

    Another thing that might be contributing to the issue is for the variables that do have the export keyword, you do not specify which type to use. You can specify which type by using the following syntax: export (type) var variable_name = default_value. So for line 4 in gul_form.gd for example, you would want to change it to the following: export (float) var run_acceleration := 50.0

    But other than the two things I listed above, looking through the scripts I don't see anything else that could be contributing to the variables not appearing in the editor.
    Hopefully this helps!

    Thank you! My issue is now solved!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file