Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MPB Tuning Preset Tool

A Unity workflow for authoring reusable ScriptableObject presets and applying them through MaterialPropertyBlock to keep visual variation while preserving batching.

Demo

Walkthrough

MPB Walkthrough

Batching Profiler Result

MPB Profiler Result

Profiler summary from your test setup:

  • MPB + different textures and properties on 5 cubes: 1 batch call.
  • Different materials on 5 cubes: 5 batch calls.

Overview

This tool separates visual tuning data from scene objects. You define color intensity, UV tiling/offset, and scale in a TuningPreset asset, then apply that preset to any renderer through TuningPresetApplier.

Because values are pushed through MaterialPropertyBlock instead of creating duplicated material instances, this setup helps reduce draw calls and improves render performance for repeated objects.

Setup

  1. Copy Scripts/TuningPreset.cs and Scripts/TuningPresetApplier.cs into your Unity project.
  2. Copy Editor/TuningPresetApplierEditor.cs into an Editor/ folder in your Unity project.
  3. In Unity, create a preset via Create > Material Property Block > Tuning Preset.
  4. Add TuningPresetApplier to a GameObject with a Renderer.
  5. Assign the preset and click Apply in the custom inspector.

Features

  • Preset Authoring: Create reusable TuningPreset assets from the Unity Create menu.
  • MPB-Based Rendering: Applies color and UV values using MaterialPropertyBlock.
  • Transform Tuning: Applies per-preset local scale values.
  • Custom Inspector Tools: One-click Apply, Reset, and Validate Preset buttons.
  • Edit Mode Support: Works in edit mode via [ExecuteAlways].
  • Data Safety: OnValidate() clamps invalid intensity, UV tiling, and scale values.

Script Reference

Scripts/TuningPreset.cs

  • TuningPreset: ScriptableObject containing color, intensity, metallic, tiling/offset, and scale tuning data.
  • OnValidate(): Enforces safe ranges for intensity, UV tiling, and scale.

Scripts/TuningPresetApplier.cs

  • ApplyPreset(): Applies scale + MPB data (_BaseColor, _Tiling_and_Offset) to the renderer.
  • ResetToDefault(): Clears property block and restores scale to Vector3.one.

Editor/TuningPresetApplierEditor.cs

  • Custom inspector with Apply, Reset, and Validate Preset utilities.

License

This project is licensed under the MIT License - see the LICENSE file for details. Copyright (c) 2025 ARGUS

About

Unity ScriptableObject and MaterialPropertyBlock workflow for reusable tuning presets that preserve visual variety while keeping batching efficient.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages