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

You can no longer forward reverting values from ShaderMaterial to a custom inspector in Godot 4.0 #69335

Closed
Arnklit opened this issue Nov 29, 2022 · 3 comments · Fixed by #69343

Comments

@Arnklit
Copy link
Contributor

Arnklit commented Nov 29, 2022

Godot version

4.0.beta5

System information

Windows 10, GTX 980 Ti, Vulkan Forward+

Issue description

Not sure how to log this, if it should be a proposal, let me know and I'll close this and re-log it.

In my addons Waterways and ShellFur, I make custom inspectors for the materials and using ShaderMaterial.can_revert_property() and ShaderMaterial.get_revert_property() it was possible to forward the reverting to my inspectors. These functions have been removed in Godot 4.0 and there does not appear to be any alternative way of doing it.

Example of custom inspector in Godot 3.5
image

Example code of using this in 3.5:

func property_can_revert(property : String) -> bool:
	if property.begins_with("mat_"):
		var param_name = property.right(len("mat_"))
		return _material.property_can_revert(str("shader_param/", param_name))
	if not DEFAULT_PARAMETERS.has(property):
		return false
	if get(property) != DEFAULT_PARAMETERS[property]:
		return true
	return false


func property_get_revert(property : String):
	if property.begins_with("mat_"):
		var param_name = property.right(len("mat_"))
		var revert_value = _material.property_get_revert(str("shader_param/", param_name))
		return revert_value

Steps to reproduce

NA

Minimal reproduction project

NA

@akien-mga
Copy link
Member

akien-mga commented Nov 29, 2022

Those functions still exist, they were renamed to _property_can_revert and _property_get_revert to properly match the convention for virtual methods: #64334.

They're also exposed in the Object docs properly now :)

https://docs.godotengine.org/en/latest/classes/class_object.html#class-object-method-property-can-revert

@Arnklit
Copy link
Contributor Author

Arnklit commented Nov 29, 2022

@akien-mga I know property_can_revert and _property_can_revert have been renamed. But you cannot call them to get the values like you could with the ShaderMaterial ones.

image

@YuriSizov
Copy link
Contributor

YuriSizov commented Nov 29, 2022

@akien-mga I missed it too at first, but the issue is not with the methods that we can override, but with the methods that we would call. Kasper implements a higher order method that calls into a method of the material. Override works, but the inner call doesn't, because I think we still need to expose a public counterpart of the virtual method (e.g. you implement _set, but you call set externally).

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

Successfully merging a pull request may close this issue.

3 participants