|
|
|
|
Reply From: |
jovansystem |
Hi, as far as I can tell, in 3.0 there is no simple way to do this, although there seems to have been some discussion about adding this functionality.
It is possible, though, as described by Bojidar Marinov in a post to this thread:
https://forum.godotengine.org/3196/how-add-subcategories-inspector-script-variables-section
Here is a slightly different implementation I use based on the same technique:
Scripts/PropertyList.gd
extends Object
var properties = {}
func add(name, type, default_value):
properties[name] = {
"hint": PROPERTY_HINT_NONE,
"usage": PROPERTY_USAGE_DEFAULT,
"name": name,
"type": type,
"value": default_value
}
func get(name):
return properties[name].value
func set(name, value):
if properties.has(name):
properties[name].value = value
func _init(list):
for prop in list:
add(prop[0], prop[1], prop[2])
And then, in your scripts you can do:
tool
extends Spatial
const PropertyList = preload("res://Scripts/PropertyList.gd")
var property_list = PropertyList.new([
["test/foo",TYPE_STRING,"allo"],
["test/bar",TYPE_INT,32],
["other/foo",TYPE_STRING,"truc"],
["other/bar",TYPE_INT,8]])
func _get(property):
return property_list.get(property)
func _set(property, value):
property_list.set(property, value)
func _get_property_list():
return property_list.properties.values()
Is it possible to set the type as Texture this way?
Like the TexturedButton groups it’s textures under Textures category?
hedin_hiervard | 2018-11-21 12:08