-
Notifications
You must be signed in to change notification settings - Fork 1
/
MyColorRandomizerTag.cs
31 lines (26 loc) · 1.13 KB
/
MyColorRandomizerTag.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using UnityEngine;
using UnityEngine.Perception.Randomization.Parameters;
using UnityEngine.Perception.Randomization.Randomizers;
using UnityEngine.Perception.Randomization.Samplers;
// This component should be added to any GameObject that you want to randomize.
// The class name must match the name of the .cs file it is defined in.
public class MyColorRandomizerTag : RandomizerTag { }
[Serializable]
// This attribute adds a menu entry in the Unity Editor for this randomizer.
[AddRandomizerMenu("MyColorRandomizer")]
public class MyColorRandomizer : Randomizer
{
// Parameter for controlling the RGB color.
public ColorRgbParameter colorRGB;
// Reference to the material that will have its color randomized.
public Material selectedMat;
// This method is called at the start of each randomization iteration.
protected override void OnIterationStart()
{
// Sample a random RGB color value.
Color randomizedColor = colorRGB.Sample();
// Apply the randomized color to the selected material.
selectedMat.color = randomizedColor;
}
}