public override void SetValue(InteractableThemeProperty property, int index, float percentage) { if (Host == null) { return; } string propId = property.GetShaderPropId(); float newValue; switch (property.Type) { case InteractableThemePropertyValueTypes.Color: Color newColor = Color.Lerp(property.StartValue.Color, property.Values[index].Color, percentage); propertyBlock = SetColor(propertyBlock, newColor, propId); break; case InteractableThemePropertyValueTypes.ShaderFloat: newValue = LerpFloat(property.StartValue.Float, property.Values[index].Float, percentage); propertyBlock = SetFloat(propertyBlock, newValue, propId); break; case InteractableThemePropertyValueTypes.shaderRange: newValue = LerpFloat(property.StartValue.Float, property.Values[index].Float, percentage); propertyBlock = SetFloat(propertyBlock, newValue, propId); break; default: break; } renderer.SetPropertyBlock(propertyBlock); }
/// <inheritdoc /> public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue start = new InteractableThemePropertyValue(); start.Vector3 = hostTransform.localPosition; return(start); }
public virtual void Init(GameObject host, InteractableThemePropertySettings settings) { Host = host; for (int i = 0; i < settings.Properties.Count; i++) { InteractableThemeProperty prop = ThemeProperties[i]; prop.ShaderOptionNames = settings.Properties[i].ShaderOptionNames; prop.ShaderOptions = settings.Properties[i].ShaderOptions; prop.PropId = settings.Properties[i].PropId; prop.Values = settings.Properties[i].Values; ThemeProperties[i] = prop; } for (int i = 0; i < settings.CustomSettings.Count; i++) { InteractableCustomSetting setting = CustomSettings[i]; setting.Name = settings.CustomSettings[i].Name; setting.Type = settings.CustomSettings[i].Type; setting.Value = settings.CustomSettings[i].Value; CustomSettings[i] = setting; } Ease = CopyEase(settings.Easing); Ease.Stop(); Loaded = true; }
/// <inheritdoc /> public override void SetValue(InteractableThemeProperty property, int index, float percentage) { Host.SetActive(property.Values[index].Bool); material = property.Values[index].Material; renderer.material = material; }
/// <inheritdoc /> public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue start = new InteractableThemePropertyValue(); start.String = property.Values[lastIndex].String; return(start); }
/// <inheritdoc /> public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue start = new InteractableThemePropertyValue(); start.Texture = propertyBlock.GetTexture("_MainTex"); return(start); }
public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue start = new InteractableThemePropertyValue(); start.Vector3 = hostTransform.eulerAngles; return(start); }
/// <inheritdoc /> 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); } }
public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { if (Host == null) { return(emptyValue); } startValue.Reset(); string propId = property.GetShaderPropId(); switch (property.Type) { case InteractableThemePropertyValueTypes.Color: startValue.Color = propertyBlock.GetVector(propId); break; case InteractableThemePropertyValueTypes.ShaderFloat: startValue.Float = propertyBlock.GetFloat(propId); break; case InteractableThemePropertyValueTypes.shaderRange: startValue.Float = propertyBlock.GetFloat(propId); break; default: break; } return(startValue); }
public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue start = new InteractableThemePropertyValue(); start.Bool = Host.activeSelf; return(start); }
/// <inheritdoc /> public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue start = new InteractableThemePropertyValue(); material = renderer.material; start.Material = material; return(start); }
public override void SetValue(InteractableThemeProperty property, int index, float percentage) { if (audioSource == null) { audioSource = Host.AddComponent <AudioSource>(); } audioSource.clip = property.Values[index].AudioClip; audioSource.Play(); }
/// <inheritdoc /> public override void SetValue(InteractableThemeProperty property, int index, float percentage) { if (lastIndex != index) { if (controller != null) { controller.SetTrigger(property.Values[index].String); } lastIndex = index; } }
public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue start = new InteractableThemePropertyValue(); AudioSource audioSource = Host.GetComponentInChildren <AudioSource>(); if (audioSource != null) { start.AudioClip = audioSource.clip; } return(start); }
/// <summary> /// Try to set color on TextMesh /// If false, no TextMesh was found /// </summary> protected bool TrySetTextMeshColor(Color colour, InteractableThemeProperty property, int index, float percentage) { TextMesh mesh = Host.GetComponent <TextMesh>(); if (mesh != null) { mesh.color = colour; return(true); } return(false); }
/// <summary> /// Try to set color on UI Text /// If false, no UI Text was found /// </summary> protected bool TrySetTextColor(Color colour, InteractableThemeProperty property, int index, float percentage) { Text text = Host.GetComponent <Text>(); if (text != null) { text.color = colour; return(true); } return(false); }
/// <inheritdoc /> public override void SetValue(InteractableThemeProperty property, int index, float percentage) { if (!hasGrab && Host != null) { Host.transform.localScale = Vector3.Lerp(property.StartValue.Vector3, Vector3.Scale(startScaleValue.Vector3, property.Values[index].Vector3), percentage); } else { // there is near interaction grab so make sure Ease is not running Ease.Stop(); } }
public override void SetValue(InteractableThemeProperty property, int index, float percentage) { if (mesh != null) { mesh.text = property.Values[index].String; return; } if (mesh != null) { text.text = property.Values[index].String; } }
/// <summary> /// Try to set color on TextMeshProUGUI /// If false, no TextMeshProUGUI was found /// </summary> protected bool TrySetTextMeshProUGUIColor(Color colour, InteractableThemeProperty property, int index, float percentage) { TextMeshProUGUI tmp = Host.GetComponent <TextMeshProUGUI>(); if (tmp) { tmp.color = colour; return(true); } return(false); }
/// <summary> /// Try to get color from TextMesh /// If no color is found, not TextMesh on this object /// </summary> protected bool TryGetTextMeshColor(InteractableThemeProperty property, out Color color) { Color colour = Color.white; TextMesh mesh = Host.GetComponent <TextMesh>(); if (mesh != null) { color = mesh.color; return(true); } color = colour; return(false); }
/// <summary> /// Try to get a color from UI Text /// if no color is found, a text component does not exist on this object /// </summary> protected bool TryGetTextColor(InteractableThemeProperty property, out Color color) { Color colour = Color.white; Text text = Host.GetComponent <Text>(); if (text != null) { color = text.color; return(true); } color = colour; return(false); }
/// <inheritdoc /> public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { if (Host == null) { return(startScaleValue); } InteractableThemePropertyValue prop = new InteractableThemePropertyValue(); prop.Vector3 = Host.transform.localScale; return(prop); }
/// <summary> /// Try to get color from TextMeshPro /// If no color is found, TextMeshPro is not on the object /// </summary> protected bool TryGetTextMeshProColor(InteractableThemeProperty property, out Color color) { Color colour = Color.white; TextMeshPro tmp = Host.GetComponent <TextMeshPro>(); if (tmp) { color = tmp.color; return(true); } color = colour; return(false); }
/// <inheritdoc /> public override void SetValue(InteractableThemeProperty property, int index, float percentage) { Color color = Color.Lerp(property.StartValue.Color, property.Values[index].Color, percentage); 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 InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue color = new InteractableThemePropertyValue(); int propId = property.GetShaderPropertyId(); if (propertyBlocks.Count > 0) { BlocksAndRenderer bAndR = propertyBlocks[0]; color.Color = bAndR.Block.GetVector(propId); } return(color); }
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]); } } propertyBlock = InteractableThemeShaderUtils.GetMaterialPropertyBlock(host, shaderProperties.ToArray()); renderer = Host.GetComponent <Renderer>(); }
public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue color = new InteractableThemePropertyValue(); if (mesh != null) { color.Color = mesh.color; return(color); } if (text != null) { color.Color = text.color; return(color); } return(base.GetProperty(property)); }
public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue start = new InteractableThemePropertyValue(); start.String = ""; if (mesh != null) { start.String = mesh.text; return(start); } if (mesh != null) { start.String = text.text; } return(start); }
public override void SetValue(InteractableThemeProperty property, int index, float percentage) { Color color = Color.Lerp(property.StartValue.Color, property.Values[index].Color, percentage); if (mesh != null) { mesh.color = color; return; } if (text != null) { text.color = color; return; } base.SetValue(property, index, percentage); }
/// <inheritdoc /> public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property) { InteractableThemePropertyValue color = new InteractableThemePropertyValue(); // check if a text object exists and get the color, // set the delegate to bypass these checks in the future. // if no text objects exists then fall back to renderer based color getting. if (GetColorValue != null) { GetColorValue(property, out color.Color); return(color); } else { if (TryGetTextMeshProColor(property, out color.Color)) { GetColorValue = TryGetTextMeshProColor; return(color); } if (TryGetTextMeshProUGUIColor(property, out color.Color)) { GetColorValue = TryGetTextMeshProUGUIColor; return(color); } if (TryGetTextMeshColor(property, out color.Color)) { GetColorValue = TryGetTextMeshColor; return(color); } if (TryGetTextColor(property, out color.Color)) { GetColorValue = TryGetTextColor; return(color); } // no text components exist, fallback to renderer TryGetRendererColor(property, out color.Color); GetColorValue = TryGetRendererColor; return(color); } }