8 namespace droid.Runtime.Prototyping.Configurables {
12 [AddComponentMenu(ConfigurableComponentMenuPath._ComponentMenuPath
13 +
"StandardShaderMaterial" 14 + ConfigurableComponentMenuPath._Postfix)]
15 [RequireComponent(typeof(Renderer))]
40 [SerializeField]
bool _use_shared =
false;
41 [SerializeField]
Space4 _configurable_value_space;
43 static readonly
int _glossiness = Shader.PropertyToID(
"_Glossiness");
44 static readonly
int _glossy_reflections = Shader.PropertyToID(
"_GlossyReflections");
45 static readonly
int _main_tex = Shader.PropertyToID(
"_MainTex");
51 this._r = this.Identifier +
"R";
52 this._g = this.Identifier +
"G";
53 this._b = this.Identifier +
"B";
54 this._a = this.Identifier +
"A";
55 this._reflection = this.Identifier +
"Reflection";
56 this._smoothness = this.Identifier +
"Smoothness";
57 this._tiling_x = this.Identifier +
"TilingX";
58 this._tiling_y = this.Identifier +
"TilingY";
59 this._offset_x = this.Identifier +
"OffsetX";
60 this._offset_y = this.Identifier +
"OffsetY";
62 this._renderer = this.GetComponent<Renderer>();
69 this.ParentEnvironment =
70 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._r);
71 this.ParentEnvironment =
72 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._g);
73 this.ParentEnvironment =
74 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._b);
75 this.ParentEnvironment =
76 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._a);
77 this.ParentEnvironment =
78 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._reflection);
79 this.ParentEnvironment =
80 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._smoothness);
81 this.ParentEnvironment =
82 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._offset_x);
83 this.ParentEnvironment =
84 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._offset_y);
85 this.ParentEnvironment =
86 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._tiling_x);
87 this.ParentEnvironment =
88 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._tiling_y);
95 if (this.ParentEnvironment == null) {
99 this.ParentEnvironment.UnRegister(
this, this._r);
100 this.ParentEnvironment.UnRegister(
this, this._g);
101 this.ParentEnvironment.UnRegister(
this, this._b);
102 this.ParentEnvironment.UnRegister(
this, this._a);
103 this.ParentEnvironment.UnRegister(
this, this._reflection);
104 this.ParentEnvironment.UnRegister(
this, this._smoothness);
105 this.ParentEnvironment.UnRegister(
this, this._offset_x);
106 this.ParentEnvironment.UnRegister(
this, this._offset_y);
107 this.ParentEnvironment.UnRegister(
this, this._tiling_x);
108 this.ParentEnvironment.UnRegister(
this, this._tiling_y);
114 public override ISpace ConfigurableValueSpace {
get {
return this._configurable_value_space; } }
121 if (this.Debugging) {
122 DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier);
126 if (!this._use_shared) {
127 foreach (var mat
in this._renderer.materials) {
130 if (configuration.
ConfigurableName.Equals(
this._r, StringComparison.Ordinal)) {
132 }
else if (
string.Equals(configuration.
ConfigurableName,
this._g, StringComparison.Ordinal)) {
134 }
else if (
string.Equals(configuration.
ConfigurableName,
this._b, StringComparison.Ordinal)) {
136 }
else if (
string.Equals(configuration.
ConfigurableName,
this._a, StringComparison.Ordinal)) {
140 StringComparison.Ordinal)) {
144 StringComparison.Ordinal)) {
148 StringComparison.Ordinal)) {
149 var a = mat.GetTextureOffset(_main_tex);
151 mat.SetTextureOffset(_main_tex, a);
154 StringComparison.Ordinal)) {
155 var a = mat.GetTextureOffset(_main_tex);
157 mat.SetTextureOffset(_main_tex, a);
160 StringComparison.Ordinal)) {
161 var a = mat.GetTextureScale(_main_tex);
163 mat.SetTextureScale(_main_tex, a);
166 StringComparison.Ordinal)) {
167 var a = mat.GetTextureScale(_main_tex);
169 mat.SetTextureScale(_main_tex, a);
175 foreach (var mat
in this._renderer.sharedMaterials) {
178 if (
string.Equals(configuration.
ConfigurableName,
this._r, StringComparison.Ordinal)) {
180 }
else if (
string.Equals(configuration.
ConfigurableName,
this._g, StringComparison.Ordinal)) {
182 }
else if (
string.Equals(configuration.
ConfigurableName,
this._b, StringComparison.Ordinal)) {
184 }
else if (
string.Equals(configuration.
ConfigurableName,
this._a, StringComparison.Ordinal)) {
188 StringComparison.Ordinal)) {
192 StringComparison.Ordinal)) {
196 StringComparison.Ordinal)) {
197 var a = mat.GetTextureOffset(_main_tex);
199 mat.SetTextureOffset(_main_tex, a);
202 StringComparison.Ordinal)) {
203 var a = mat.GetTextureOffset(_main_tex);
205 mat.SetTextureOffset(_main_tex, a);
208 StringComparison.Ordinal)) {
209 var a = mat.GetTextureScale(_main_tex);
211 mat.SetTextureScale(_main_tex, a);
214 StringComparison.Ordinal)) {
215 var a = mat.GetTextureScale(_main_tex);
217 mat.SetTextureScale(_main_tex, a);
230 var cs1 = this._color_space.
Sample();
231 var tl1 = this._tiling_space.
Sample();
232 var os1 = this._offset_space.
Sample();
251 Material[] materials;
252 if (this._use_shared) {
253 materials = this._renderer.sharedMaterials;
255 materials = this._renderer.materials;
258 foreach (var mat
in materials) {
259 mat.color = this._color_space.
Sample();
260 mat.SetTextureScale(_main_tex, this._tiling_space.
Sample());
261 mat.SetTextureOffset(_main_tex, this._offset_space.
Sample());
262 mat.SetFloat(_glossiness, this._smoothness_space.
Sample());
263 mat.SetFloat(_glossy_reflections, this._reflection_space.
Sample());
270 public dynamic[] ObservationArray {
get {
return new dynamic[] { }; } }
static Space1 TwentyEighty
static Space2 TwentyEighty
override void Randomise()
override Configuration [] SampleConfigurations()
override void RegisterComponent()
override void UnRegisterComponent()
override void ApplyConfiguration(IConfigurableConfiguration configuration)
static Space4 TwentyEighty