Files
Continentis/Assets/OtherPlugins/Sprite Shaders Ultimate/Scripts/MaterialInstancerSSU.cs

29 lines
913 B
C#
Raw Normal View History

2025-11-25 21:49:03 -05:00
using UnityEngine;
using UnityEngine.UI;
namespace SpriteShadersUltimate
{
[AddComponentMenu("Sprite Shaders Ultimate/Utility/Material Instancer SSU")]
public class MaterialInstancerSSU : InstancerSSU
{
2026-03-20 11:56:50 -04:00
private void Awake()
2025-11-25 21:49:03 -05:00
{
2026-03-20 11:56:50 -04:00
var graphic = GetComponent<Graphic>();
if (graphic != null)
2025-11-25 21:49:03 -05:00
{
graphic.material = Instantiate(graphic.material);
runtimeMaterial = graphic.materialForRendering;
}
2026-03-20 11:56:50 -04:00
var renderer = GetComponent<Renderer>();
if (renderer != null)
2025-11-25 21:49:03 -05:00
{
2026-03-20 11:56:50 -04:00
var materials = renderer.sharedMaterials;
for (var n = 0; n < materials.Length; n++) materials[n] = Instantiate(materials[n]);
2025-11-25 21:49:03 -05:00
renderer.materials = renderer.sharedMaterials = materials;
runtimeMaterial = materials[0];
}
}
}
2026-03-20 11:56:50 -04:00
}