6 namespace droid.Runtime.Prototyping.Configurables {
10 [AddComponentMenu(ConfigurableComponentMenuPath._ComponentMenuPath
12 + ConfigurableComponentMenuPath._Postfix)]
13 [RequireComponent(typeof(Renderer))]
15 [SerializeField] Texture[] _textures = null;
16 [SerializeField]
bool load_from_resources_if_empty =
true;
17 [SerializeField] Texture _texture = null;
18 [SerializeField] Renderer _renderer = null;
19 [SerializeField]
bool use_shared =
false;
21 [SerializeField]
int _last_sample;
22 [SerializeField]
string load_path =
"Textures";
23 static readonly
int _main_tex = Shader.PropertyToID(
"_MainTex");
29 this._renderer = this.GetComponent<Renderer>();
30 if (Application.isPlaying) {
31 if (this.use_shared) {
32 this._mat = this._renderer?.sharedMaterial;
34 this._mat = this._renderer?.material;
38 if (this.load_from_resources_if_empty) {
39 if (this._textures == null || this._textures.Length == 0) {
40 this._textures = Resources.LoadAll<Texture>(this.load_path);
45 public override ISpace ConfigurableValueSpace {
get; }
53 DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier);
59 this._mat.SetTexture(_main_tex,
this._texture);
66 this._texture = this._textures[
Random.Range(0, this._textures.Length)];
68 this._mat.SetTexture(_main_tex, this._texture);
76 this._last_sample =
Random.Range(0, this._textures.Length);
78 return new[] {
new Configuration(this.Identifier, this._last_sample)};
override void Randomise()
override Configuration [] SampleConfigurations()
override void ApplyConfiguration(IConfigurableConfiguration configuration)