百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
U

UIMaterialPropertyInjector

> 包管理
开源

此包提供了一个组件,可让用户轻松修改/动画 Unity UI (uGUI) 的材质属性,无需针对着色器进行特定的自定义。

181 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

此包提供了一个组件,可让用户轻松修改/动画 Unity UI (uGUI) 的材质属性,无需针对着色器进行特定的自定义。

UI Material Property Injector

Description

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:

  • Are material assets being changed directly?
  • Are material instances leaking?
  • Is it allocating unnecessarily every time the property changes?
  • Does it support masks?
  • Does it support animations?
  • And so on.

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:

  • Change UI material properties without shader-specific custom components.
  • Modify material properties:
    • via animation, similar to MeshRenderer
    • via tweener component
    • via code
    • via the inspector
  • Automatic creation and deletion of material instances.
  • Instead of creating material assets with slight differences, you can create material instances and change properties.
  • Share material instances by specifying a GroupId.
  • Automatic detection of shader properties.
  • Supports the Mask component.
  • Supports TextMeshProUGUI and SubMeshUI components. (uGUI 2.0 ready)
  • Good performance.

Demo

WebGL Demo

⚙ Installation

This package requires Unity 2019.4 or later.

Install via OpenUPM

  • This package is available on OpenUPM package registry.
  • This is the preferred method of installation, as you can easily receive updates as they're released.
  • If you have openupm-cli installed, then run the following command in your project's directory:
    openupm add com.coffee.ui-material-property-injector
  • To update the package, use Package Manager UI (Window > Package Manager) or run the following command with @{version}:
    openupm add [email protected]

Install via UPM (with Package Manager UI)

  • 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.

    • e.g. https://github.com/mob-sakai/UIMaterialPropertyInjector.git?path=Packages/src#1.1.0

Install via UPM (Manually)

  • Open the Packages/manifest.json file in your project. Then add this package somewhere in the dependencies block:

    json
    {
      "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.

    • e.g. "com.coffee.ui-material-property-injector": "https://github.com/mob-sakai/UIMaterialPropertyInjector.git?path=Packages/src#1.1.0",

Install as Embedded Package

  1. Download a source code zip file from Releases and extract it.
  2. Place it in your project's Packages directory.
  • If you want to fix bugs or add features, install it as an embedded package.
  • To update the package, you need to re-download it and replace the contents.

Usage

  1. Add the UIMaterialPropertyInjector component to a graphic (Image, RawImage, Text, etc.) and mark the shader properties as injectable.

  2. Change the properties via animation, code or tweener.

    csharp
    var injector = GetComponent();
    injector.SetFloat("_Intensity", 0.9f);
  3. Enjoy!

UI Material Property Injector

Change the material properties of the CanvasRenderer.

  • Reset Values On Enable: Reset injector values with the material properties when the component is enabled.
  • Animatable: Makes it animatable in the Animation view.
  • Shared Group Id: Share material instances by specifying a GroupId.
    • NOTE: The material instances cannot be shared if the mask depth is different.
  • Properties: Shader properties to inject.
    • Click Reset Values to reset injector values to the material properties.

UI Material Property Tweener

A tweener to change the material properties.

  • Target: The target UIMaterialPropertyInjector to tween.
  • Curve: The curve to tween the properties.
  • Delay: The delay in seconds before the tween starts.
  • Duration: The duration in seconds of the tween.
  • Interval: The interval in seconds between each loop.
  • Restart On Enable: Whether to restart the tween when enabled.
  • Wrap Mode: The wrap mode of the 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.
  • Update Mode: Specifies how to get delta time.
    • Normal: Use Time.deltaTime.
    • Unscaled: Use Time.unscaledDeltaTime.
    • Manual: Not updated automatically and update manually with UpdateTime or SetTime method.
  • Properties: Shader properties to inject. The tweener interpolates two values with an animation curve.
    • Click Reset Values to reset injector values to the material properties.

Contributing

Issues

Issues are incredibly valuable to this project:

  • Ideas provide a valuable source of contributions that others can make.
  • Problems help identify areas where this project needs improvement.
  • Questions indicate where contributors can enhance the user experience.

Pull Requests

Pull requests offer a fantastic way to contribute your ideas to this repository.
Please refer to CONTRIBUTING.md and develop branch for guidelines.

Support

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.

License

  • MIT

Author

  • mob-sakai

See Also

  • GitHub page : https://github.com/mob-sakai/UIMaterialPropertyInjector
  • Releases : https://github.com/mob-sakai/UIMaterialPropertyInjector/releases
  • Issue tracker : https://github.com/mob-sakai/UIMaterialPropertyInjector/issues
  • Change log : https://github.com/mob-sakai/UIMaterialPropertyInjector/blob/main/Packages/src/CHANGELOG.md

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#animatablecomponentmaterialugui

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类包管理
定价开源

> 相关工具

N
npm
Node.js 默认包管理器
P
pnpm
高效节省磁盘的 Node 包管理器
I
is-gif
Check if a Buffer/Uint8Array is a GIF image