You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB
C#

using UnityEngine;
using UnityEngine.UI;
namespace AllIn1SpriteShader
{
public class RandomSeed : MonoBehaviour
{
//If you want to randomize UI Images, you'll need to create different materials
void Start()
{
Renderer sr = GetComponent<Renderer>();
if (sr != null)
{
if (sr.material != null)
{
sr.material.SetFloat("_RandomSeed", Random.Range(0, 1000f));
}
else Debug.LogError("Missing Renderer or Material: " + gameObject.name);
}
else
{
Image i = GetComponent<Image>();
if (i != null)
{
if (i.material != null)
{
i.material.SetFloat("_RandomSeed", Random.Range(0, 1000f));
}
else Debug.LogError("Missing Material on UI Image: " + gameObject.name);
}
else Debug.LogError("Missing Renderer or UI Image on: " + gameObject.name);
}
}
}
}