Tetra/Minesweeper/Assets/Scripts/WebGLMaterialSwitcher.cs
2025-05-01 01:48:08 -07:00

23 lines
676 B
C#

using UnityEngine;
using UnityEngine.UI;
public class WebGLMaterialSwitcher : MonoBehaviour
{
// Reference to the default material for WebGL
public Material webGLDefaultMaterial;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
#if !UNITY_EDITOR && UNITY_WEBGL
if (webGLDefaultMaterial != null)
{
if (GetComponent<SpriteRenderer>() != null)
GetComponent<SpriteRenderer>().material = webGLDefaultMaterial;
if (GetComponent<Image>() != null)
GetComponent<Image>().material = webGLDefaultMaterial;
}
#endif
}
}