Example #1
0
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            if (Host == null)
            {
                return(new InteractableThemePropertyValue());
            }

            InteractableThemePropertyValue start = new InteractableThemePropertyValue();
            string propId = property.GetShaderPropId();

            switch (property.Type)
            {
            case InteractableThemePropertyValueTypes.Color:
                start.Color = propertyBlock.GetVector(propId);
                break;

            case InteractableThemePropertyValueTypes.ShaderFloat:
                start.Float = propertyBlock.GetFloat(propId);
                break;

            case InteractableThemePropertyValueTypes.shaderRange:
                start.Float = propertyBlock.GetFloat(propId);
                break;

            default:
                break;
            }

            return(start);
        }
Example #2
0
        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;
            }

            SetPropertyBlock(Host, propertyBlock);
        }
Example #3
0
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            InteractableThemePropertyValue start = new InteractableThemePropertyValue();

            start.Vector3 = Host.transform.localPosition;
            return(start);
        }
Example #4
0
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            InteractableThemePropertyValue start = new InteractableThemePropertyValue();

            start.Vector3 = Host.transform.eulerAngles;
            return(start);
        }
        public override void SetValue(InteractableThemeProperty property, int index, float percentage)
        {
            Host.SetActive(property.Values[index].Bool);

            material          = property.Values[index].Material;
            renderer.material = material;
        }
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            InteractableThemePropertyValue start = new InteractableThemePropertyValue();

            start.Vector3 = hostTransform.localScale;
            return(start);
        }
Example #7
0
        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)
        {
            InteractableThemePropertyValue start = new InteractableThemePropertyValue();

            start.Bool = Host.activeSelf;
            return(start);
        }
Example #9
0
        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.String = property.Values[lastIndex].String;
            return(start);
        }
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            InteractableThemePropertyValue start = new InteractableThemePropertyValue();

            material       = renderer.material;
            start.Material = material;
            return(start);
        }
Example #12
0
        public override void SetValue(InteractableThemeProperty property, int index, float percentage)
        {
            propertyBlock.SetTexture("_MainTex", property.Values[index].Texture);

            Renderer renderer = Host.GetComponent <Renderer>();

            renderer.SetPropertyBlock(propertyBlock);
        }
        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();
        }
 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);
        }
 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;
     }
 }
Example #17
0
        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;
            }
        }
Example #18
0
        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);
        }
Example #19
0
        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());
        }
Example #20
0
        public override void SetValue(InteractableThemeProperty property, int index, float percentage)
        {
            TextMesh mesh = Host.GetComponentInChildren <TextMesh>();

            if (mesh != null)
            {
                mesh.text = property.Values[index].String;
                return;
            }

            Text text = Host.GetComponentInChildren <Text>();

            if (mesh != null)
            {
                text.text = property.Values[index].String;
            }
        }
Example #21
0
        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));
        }
Example #22
0
        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);
        }
        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);
        }
Example #24
0
        public override void SetValue(InteractableThemeProperty property, int index, float percentage)
        {
            switch (property.Name)
            {
            case "Scale":
                hostTransform.localScale = Vector3.Lerp(property.StartValue.Vector3, Vector3.Scale(startScale, property.Values[index].Vector3), percentage);
                break;

            case "Offset":
                hostTransform.localPosition = Vector3.Lerp(property.StartValue.Vector3, startPosition + property.Values[index].Vector3, percentage);
                break;

            case "Color":
                base.SetValue(property, index, percentage);
                break;

            default:
                break;
            }
        }
        public virtual void OnUpdate(int state, bool force = false)
        {
            if (state != lastState || force)
            {
                int themePropCount = ThemeProperties.Count;
                for (int i = 0; i < themePropCount; i++)
                {
                    InteractableThemeProperty current = ThemeProperties[i];
                    current.StartValue = GetProperty(current);
                    if (hasFirstState || force)
                    {
                        Ease.Start();
                        SetValue(current, state, Ease.GetCurved());
                        hasFirstState = true;
                    }
                    else
                    {
                        SetValue(current, state, 1);
                        if (i >= themePropCount - 1)
                        {
                            hasFirstState = true;
                        }
                    }
                    ThemeProperties[i] = current;
                }

                lastState = state;
            }
            else if (Ease.Enabled && Ease.IsPlaying())
            {
                Ease.OnUpdate();
                int themePropCount = ThemeProperties.Count;
                for (int i = 0; i < themePropCount; i++)
                {
                    InteractableThemeProperty current = ThemeProperties[i];
                    SetValue(current, state, Ease.GetCurved());
                }
            }

            lastState = state;
        }
Example #26
0
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            InteractableThemePropertyValue color = new InteractableThemePropertyValue();
            TextMesh mesh = Host.GetComponent <TextMesh>();

            if (mesh != null)
            {
                color.Color = mesh.color;
                return(color);
            }

            Text text = Host.GetComponent <Text>();

            if (text != null)
            {
                color.Color = text.color;
                return(color);
            }

            return(base.GetProperty(property));
        }
Example #27
0
        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;
            }

            Ease = CopyEase(settings.Easing);
            Ease.Stop();

            Loaded = true;
        }
Example #28
0
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            InteractableThemePropertyValue start = new InteractableThemePropertyValue();

            start.String = "";
            TextMesh mesh = Host.GetComponentInChildren <TextMesh>();

            if (mesh != null)
            {
                start.String = mesh.text;
                return(start);
            }

            Text text = Host.GetComponentInChildren <Text>();

            if (mesh != null)
            {
                start.String = text.text;
            }
            return(start);
        }
Example #29
0
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            InteractableThemePropertyValue start = new InteractableThemePropertyValue();

            switch (property.Name)
            {
            case "Scale":
                start.Vector3 = hostTransform.localScale;
                break;

            case "Offset":
                start.Vector3 = hostTransform.localPosition;
                break;

            case "Color":
                start = base.GetProperty(property);
                break;

            default:
                break;
            }
            return(start);
        }
Example #30
0
 public abstract InteractableThemePropertyValue GetProperty(InteractableThemeProperty property);