Пример #1
0
        /// <inheritdoc />
        public override void SetValue(ThemeStateProperty property, int index, float percentage)
        {
            if (renderer != null)
            {
                renderer.GetPropertyBlock(propertyBlock);

                int propId    = property.GetShaderPropertyId();
                var propValue = property.Values[index];
                switch (property.Type)
                {
                case ThemePropertyTypes.Color:
                    Color newColor = Color.Lerp(property.StartValue.Color, propValue.Color, percentage);
                    propertyBlock.SetColor(propId, newColor);
                    break;

                case ThemePropertyTypes.Texture:
                    propertyBlock.SetTexture(propId, propValue.Texture);
                    break;

                case ThemePropertyTypes.ShaderFloat:
                case ThemePropertyTypes.ShaderRange:
                    float floatValue = LerpFloat(property.StartValue.Float, propValue.Float, percentage);
                    propertyBlock.SetFloat(propId, floatValue);
                    break;

                default:
                    break;
                }

                renderer.SetPropertyBlock(propertyBlock);
            }
        }
Пример #2
0
        /// <inheritdoc />
        public override ThemePropertyValue GetProperty(ThemeStateProperty property)
        {
            if (renderer == null)
            {
                return(null);
            }

            renderer.GetPropertyBlock(propertyBlock);

            startValue.Reset();

            int propId = property.GetShaderPropertyId();

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

            case ThemePropertyTypes.Texture:
                startValue.Texture = propertyBlock.GetTexture(propId);
                break;

            case ThemePropertyTypes.ShaderFloat:
            case ThemePropertyTypes.ShaderRange:
                startValue.Float = propertyBlock.GetFloat(propId);
                break;

            default:
                break;
            }

            return(startValue);
        }
        private void SetShaderValue(ThemeStateProperty property, Color color, Texture tex, float floatValue)
        {
            int propId = property.GetShaderPropertyId();

            if (renderer != null)
            {
                renderer.GetPropertyBlock(propertyBlock);

                switch (property.Type)
                {
                case ThemePropertyTypes.Color:
                    propertyBlock.SetColor(propId, color);
                    break;

                case ThemePropertyTypes.Texture:
                    if (tex != null)
                    {
                        propertyBlock.SetTexture(propId, tex);
                    }
                    break;

                case ThemePropertyTypes.ShaderFloat:
                case ThemePropertyTypes.ShaderRange:
                    propertyBlock.SetFloat(propId, floatValue);
                    break;

                default:
                    break;
                }

                renderer.SetPropertyBlock(propertyBlock);
            }
            else if (graphic != null)
            {
                switch (property.Type)
                {
                case ThemePropertyTypes.Color:
                    graphic.material.SetColor(propId, color);
                    break;

                case ThemePropertyTypes.Texture:
                    graphic.material.SetTexture(propId, tex);
                    break;

                case ThemePropertyTypes.ShaderFloat:
                case ThemePropertyTypes.ShaderRange:
                    graphic.material.SetFloat(propId, floatValue);
                    break;

                default:
                    break;
                }
            }
        }
        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);
        }
        /// <inheritdoc />
        public override ThemePropertyValue GetProperty(ThemeStateProperty property)
        {
            var result = new ThemePropertyValue();

            int propId = property.GetShaderPropertyId();

            if (renderer != null)
            {
                renderer.GetPropertyBlock(propertyBlock);
                switch (property.Type)
                {
                case ThemePropertyTypes.Color:
                    result.Color = propertyBlock.GetVector(propId);
                    break;

                case ThemePropertyTypes.Texture:
                    result.Texture = propertyBlock.GetTexture(propId);
                    break;

                case ThemePropertyTypes.ShaderFloat:
                case ThemePropertyTypes.ShaderRange:
                    result.Float = propertyBlock.GetFloat(propId);
                    break;

                default:
                    break;
                }
            }
            else if (graphic != null)
            {
                switch (property.Type)
                {
                case ThemePropertyTypes.Color:
                    result.Color = graphic.material.GetVector(propId);
                    break;

                case ThemePropertyTypes.Texture:
                    result.Texture = graphic.material.GetTexture(propId);
                    break;

                case ThemePropertyTypes.ShaderFloat:
                case ThemePropertyTypes.ShaderRange:
                    result.Float = graphic.material.GetFloat(propId);
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
Пример #7
0
        /// <inheritdoc />
        public override void SetValue(ThemeStateProperty 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;
            }
        }