This package provides a component that allows easy modification/animation of material properties for Unity UI (uGUI) without the need for shader-specific custom
This package provides a component that allows easy modification/animation of material properties for Unity UI (uGUI) without the need for shader-specific custom
In Unity UI, UI elements typically do not provide an accessible MaterialPropertyBlock. To change material properties via animations, like with MeshRenderer, you usually need to create custom components, which are often shader-specific.
Custom properties for changing material properties are easy for experienced users but can be a high hurdle for beginners:
This package provides a component that allows easy modification of material properties for Unity UI (uGUI) without the need for shader-specific custom components.
Key Features:
MeshRendererGroupId.Mask component.TextMeshProUGUI and SubMeshUI components. (uGUI 2.0 ready)This package requires Unity 2019.4 or later.
openupm add com.coffee.ui-material-property-injectorWindow > Package Manager) or run the following command with @{version}:openupm add [email protected]Click Window > Package Manager to open Package Manager UI.
Click + > Add package from git URL... and input the repository URL: https://github.com/mob-sakai/UIMaterialPropertyInjector.git?path=Packages/src
To update the package, change suffix #{version} to the target version.
https://github.com/mob-sakai/UIMaterialPropertyInjector.git?path=Packages/src#1.1.0Open the Packages/manifest.json file in your project. Then add this package somewhere in the dependencies block:
{
"dependencies": {
"com.coffee.ui-material-property-injector": "https://github.com/mob-sakai/UIMaterialPropertyInjector.git?path=Packages/src",
...
}
}To update the package, change suffix #{version} to the target version.
"com.coffee.ui-material-property-injector": "https://github.com/mob-sakai/UIMaterialPropertyInjector.git?path=Packages/src#1.1.0",Packages directory.Add the UIMaterialPropertyInjector component to a graphic (Image, RawImage, Text, etc.) and mark the shader properties as injectable.
Change the properties via animation, code or tweener.
var injector = GetComponent();
injector.SetFloat("_Intensity", 0.9f);Enjoy!
Change the material properties of the CanvasRenderer.
GroupId.Reset Values to reset injector values to the material properties.A tweener to change the material properties.
UIMaterialPropertyInjector to tween.Clamp: Clamp the tween value, not loop.Loop: Loop the tween value.PingPongOnce: PingPong the tween value, not loop.PingPong: PingPong the tween value.Normal: Use Time.deltaTime.Unscaled: Use Time.unscaledDeltaTime.Manual: Not updated automatically and update manually with UpdateTime or SetTime method.Reset Values to reset injector values to the material properties.Issues are incredibly valuable to this project:
Pull requests offer a fantastic way to contribute your ideas to this repository.
Please refer to CONTRIBUTING.md
and develop branch for guidelines.
This is an open-source project developed during my spare time.
If you appreciate it, consider supporting me.
Your support allows me to dedicate more time to development.
No open issues yet, or sync has not completed.