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

Override material instance parameters #39

Closed
jiamingfeng opened this issue Oct 10, 2016 · 6 comments
Closed

Override material instance parameters #39

jiamingfeng opened this issue Oct 10, 2016 · 6 comments

Comments

@jiamingfeng
Copy link
Contributor

Is there anyway to do with the current python binding?

I would like to do something like this:

myMaterialInstance.OverrideScalarParameterDefault("UseThisColor", 1.0, True)

Cheers,
Eric

@jiamingfeng
Copy link
Contributor Author

jiamingfeng commented Oct 10, 2016

As UMaterialInstanceConstant doesn't change parameters at Runtime, I have to wrap the following functions in my own UEPyMaterialInstance.h/.cpp

SetScalarParameterValueEditorOnly();
SetVectorParameterValueEditorOnly();
SetTextureParameterValueEditorOnly();
SetParentEditorOnly();
PostEditChange();

And it all works fine. I can easily create different variation of a material with a script.

@rdeioris, what is the contribution policy here? Possible to push my changes to a dev branch?

@rdeioris
Copy link
Contributor

Yes, the material interface is not exposed to the reflection system (except for very few cases).

I think a UEPyMaterial.c/.cpp api would be a better naming choise, so we can expose all of the material related features (starting from here: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Materials/UMaterialInterface/index.html)

Regarding contribution, simply make a pull request for the master branch (add your credits into the CONTRIBUTORS file)

Regarding

SetParentEditorOnly();
PostEditChange();

combine them in a single function as PostEditChange() is mandatory.

@jiamingfeng
Copy link
Contributor Author

Ok, I can call PostEditChange() right after SetParentEditorOnly(). The following functions require to call PostEditChange to populate the changes down the chain as well.

SetScalarParameterValueEditorOnly();
SetVectorParameterValueEditorOnly();
SetTextureParameterValueEditorOnly();

As you may want to set multiple parameters without triggering post edit change event for performance reason, PostEditChange() could be exposed separately.

@rdeioris
Copy link
Contributor

Ok, at this point i think it is better to expose PostEditChange as a generic UObject method and follow the C++ pattern by calling it manually.

@jiamingfeng
Copy link
Contributor Author

I didn't realized that PostEditChange is UObject method. Good call.

@rdeioris
Copy link
Contributor

Remember to make a pull request when your code is usable :) Thanks

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

No branches or pull requests

2 participants