public override void Init(GameObject host, InteractableThemePropertySettings settings) { base.Init(host, settings); shaderProperties = new List <ShaderProperties>(); for (int i = 0; i < ThemeProperties.Count; i++) { InteractableThemeProperty prop = ThemeProperties[i]; if (prop.ShaderOptions.Count > 0) { shaderProperties.Add(prop.ShaderOptions[prop.PropId]); } } propertyBlocks = new List <BlocksAndRenderer>(); Renderer[] list = host.GetComponentsInChildren <Renderer>(); for (int i = 0; i < list.Length; i++) { MaterialPropertyBlock block = InteractableThemeShaderUtils.GetMaterialPropertyBlock(list[i].gameObject, shaderProperties.ToArray()); BlocksAndRenderer bAndR = new BlocksAndRenderer(); bAndR.Renderer = list[i]; bAndR.Block = block; propertyBlocks.Add(bAndR); } }
private void SetColor(ThemeStateProperty property, Color color) { int propId = property.GetShaderPropertyId(); for (int i = 0; i < propertyBlocks.Count; i++) { BlocksAndRenderer bAndR = propertyBlocks[i]; bAndR.Block.SetColor(propId, color); bAndR.Renderer.SetPropertyBlock(bAndR.Block); propertyBlocks[i] = bAndR; } }
/// <inheritdoc /> public override ThemePropertyValue GetProperty(ThemeStateProperty property) { ThemePropertyValue color = new ThemePropertyValue(); if (propertyBlocks.Count > 0) { int propId = property.GetShaderPropertyId(); BlocksAndRenderer bAndR = propertyBlocks[0]; color.Color = bAndR.Block.GetVector(propId); } return(color); }
public override void SetValue(InteractableThemeProperty property, int index, float percentage) { Color color = Color.Lerp(property.StartValue.Color, property.Values[index].Color, percentage); string propId = property.GetShaderPropId(); for (int i = 0; i < propertyBlocks.Count; i++) { BlocksAndRenderer bAndR = propertyBlocks[i]; bAndR.Block.SetColor(propId, color); bAndR.Renderer.SetPropertyBlock(bAndR.Block); propertyBlocks[i] = bAndR; } }
public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue color = new InteractableThemePropertyValue(); string propId = property.GetShaderPropId(); if (propertyBlocks.Count > 0) { BlocksAndRenderer bAndR = propertyBlocks[0]; color.Color = bAndR.Block.GetVector(propId); } return(color); }
/// <inheritdoc /> public override void Init(GameObject host, ThemeDefinition settings) { base.Init(host, settings); propertyBlocks = new List <BlocksAndRenderer>(); Renderer[] list = host.GetComponentsInChildren <Renderer>(); for (int i = 0; i < list.Length; i++) { MaterialPropertyBlock block = InteractableThemeShaderUtils.InitMaterialPropertyBlock(list[i].gameObject, shaderProperties); BlocksAndRenderer bAndR = new BlocksAndRenderer(); bAndR.Renderer = list[i]; bAndR.Block = block; propertyBlocks.Add(bAndR); } }