-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Ability to export a variable without showing it in the inspector #5988
Comments
You can override Example: func _get_property_list():
return [
{
"name": "Prop1",
"type": TYPE_STRING,
"usage": PROPERTY_USAGE_STORAGE
},
{
"name": "Prop2",
"type": TYPE_VECTOR2,
"usage": PROPERTY_USAGE_STORAGE
},
{
"name": "Prop3",
"type": TYPE_INT,
"usage": PROPERTY_USAGE_STORAGE
}
] |
Thanks for the solution :) Also, how do I specify a Material type? |
AFAIK You don't have to rewrite your variables if the property name is the same as the variable. About specifying it as a Material type you use Example: var my_material
func _get_property_list():
return [
{
"name": "my_material",
"type": TYPE_OBJECT,
"usage": PROPERTY_USAGE_STORAGE,
# Here we specify it's a resource type
"hint": PROPERTY_HINT_RESOURCE_TYPE,
# Now we specify the concrete type (which is "Resource" by default IINW)
"string_hint": "CanvasItemMaterial"
}
] |
If you want to make this possible with the |
I think there should be someting like |
|
@Zylann Why not put them the other way around? Also, here are a few more variations (only some of them involve a new token): hidden export(int) var whatever = 0 # New token - hidden
export(hidden, int) var whatever = 0
export(storage, int) var whatever = 0
export(PROPERTY_USAGE_STORAGE, int) var whatever = 0 # @neikeq
storage(int) var whatever = 0 # new token - storage
export(int) var _whatever = 0 # notice the underscore -- backward compatible?
property my_material(CanvasItemMaterial, PROPERTY_USAGE_STORAGE) # new token - property |
Yes, hidden or invisible or whatever. Just some keyword before or after export |
I think we need to pass another argument to export the variable. In my case I want to show a variable only if a condition fits, if not, the variable is hidden. |
IINW, @reduz had plans to modify the |
@henriiquecampos In Unity this is done easily due to the inspector being shown through immediate mode GUI (actual code, then). If it were to be possible to hide or show a variable dynamically in Godot, you would either expose it from another panel, or show/hide it dynamically with custom script code (if that's possible). a I'm curious about what @reduz plans are :) |
It would be really useful to have some way to hide an export variable. When working with script inheritance there are some export variables that make sense on parent scripts but automatically handled by sub-scripts. Both intended to be used by the user. Another work around is for all parent scripts to be abstract classes and only subclasses to export variables, but well... |
Bugsquad note: This issue still seems to be relevant as of commit d87307d. There is a workaround available, but the proposed |
Souns like a candidate for annotations (#20318) |
Is anyone on this feature? If not, I'll try to make time and make a pull request |
Stupid question: Does not |
meta has a different purpose. There is no point relying on it with a script you already know, the point is, you can |
This seems to have been reported in 2016 and i want to add that it's still very much wanted. Now that c# is there and _GetPropertyList is bugged for it, the workaround mentioned above can not be applied. Being able to hide but serialize properties is a not so uncommon requirement. |
A proposal was created that basically covers this issue: godotengine/godot-proposals#1056 |
I am making a custom node and an editor plugin to edit it. This involves a few variables in the node that I need to export so the data is saved. But some of them make little sense in the editor, are too hard to be edited this way, or are impossible to be checked for changes (array/dict). So I need to hide them... but if I remove
export
, the data is lost.If it doesn't exists already, could we have a way to hide exported variables in the inspector?
Note: the Unity equivalent is [HideInInspector].
The text was updated successfully, but these errors were encountered: