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

Allow to filter properties inside inspector with plugins #24637

Closed
wants to merge 1 commit into from
Closed

Allow to filter properties inside inspector with plugins #24637

wants to merge 1 commit into from

Conversation

Shinryuuji
Copy link
Contributor

This PR adds EditorInspectorPlugin::filter_property_list(...) which allows a plugin to modify property infos before inspector shows them.

This can be used in different use cases. One of those is if you inherit a core resource like ShaderMaterial, set all shader parameters through code and do not want the user to edit them.

extends EditorInspectorPlugin

func can_handle(object):
	if object is MyShaderMaterial:
		return true;
	return false

func filter_property_list(object, list):
	for p in list:
		if p.name.to_lower().begins_with("shader_param/"):
			p.usage &= ~PROPERTY_USAGE_EDITOR;
	
	return false

This PR might fix #23891, #17122 and #5988.

@groud
Copy link
Member

groud commented Aug 6, 2019

On IRC, @reduz pointed out the fact this has the exact same function as returning false in the parse_property function. See the documentation.

Is there something that differs from this or not ?

@Zylann
Copy link
Contributor

Zylann commented Aug 6, 2019

I'm not sure it fixes #5988 in the way I thought, because it involves writing a plugin just to hide a property. It gives the expected result but with more difficulty than overriding get_property_list.

Also, why copy the property list to a script that will likely do the same to remove some of them? Can't it just call a script function returning false so it can just remove elements from the list of properties? In that sense, it's the same as parse_property returning false.

@akien-mga
Copy link
Member

As per above comments, it seems that it's more convoluted than the existing possibility to return false in parse_property, and it's not clear whether it solves the referenced issues. Since there are no updates from OP, closing.

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

Successfully merging this pull request may close these issues.

Hiding categories from inspector via EditorInspectorPlugin
6 participants