/// <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);
            }
        }
        /// <inheritdoc />
        public override void Init(GameObject host, ThemeDefinition definition)
        {
            renderer = host.GetComponent <Renderer>();
            graphic  = host.GetComponent <Graphic>();

            base.Init(host, definition);

            shaderProperties = new List <ThemeStateProperty>();
            foreach (var prop in StateProperties)
            {
                if (ThemeStateProperty.IsShaderPropertyType(prop.Type))
                {
                    shaderProperties.Add(prop);
                }
            }

            if (renderer != null)
            {
                propertyBlock = InteractableThemeShaderUtils.InitMaterialPropertyBlock(host, shaderProperties);
            }
            else if (graphic != null)
            {
                UIMaterialInstantiator.TryCreateMaterialCopy(graphic);
            }

            // Need to update reset history tracking now that property blocks are populated correctly via above code
            var keys = new List <ThemeStateProperty>(originalStateValues.Keys);

            foreach (var value in keys)
            {
                originalStateValues[value] = GetProperty(value);
            }
        }
        public static Color GetColor(GameObject host, int propId)
        {
            if (host == null)
            {
                return(Color.white);
            }

            MaterialPropertyBlock block = InteractableThemeShaderUtils.GetPropertyBlock(host);

            return(block.GetVector(propId));
        }
        public static float GetFloat(GameObject host, int propId)
        {
            if (host == null)
            {
                return(0);
            }

            MaterialPropertyBlock block = InteractableThemeShaderUtils.GetPropertyBlock(host);

            return(block.GetFloat(propId));
        }
Beispiel #5
0
        /// <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);
            }
        }
Beispiel #6
0
        /// <inheritdoc />
        public override void Init(GameObject host, ThemeDefinition definition)
        {
            base.Init(host, definition);

            renderer = Host.GetComponent <Renderer>();

            shaderProperties = new List <ThemeStateProperty>();
            foreach (var prop in StateProperties)
            {
                if (ThemeStateProperty.IsShaderPropertyType(prop.Type))
                {
                    shaderProperties.Add(prop);
                }
            }

            propertyBlock = InteractableThemeShaderUtils.InitMaterialPropertyBlock(host, shaderProperties);
        }
        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>();
        }
        /// <inheritdoc />
        public override void Init(GameObject host, ThemeDefinition definition)
        {
            base.Init(host, definition);

            shaderProperties = new List <ThemeStateProperty>();
            foreach (var prop in StateProperties)
            {
                if (ThemeStateProperty.IsShaderPropertyType(prop.Type))
                {
                    shaderProperties.Add(prop);
                }
            }
            renderer = Host.GetComponent <Renderer>();
            graphic  = Host.GetComponent <Graphic>();
            if (renderer != null)
            {
                propertyBlock = InteractableThemeShaderUtils.InitMaterialPropertyBlock(host, shaderProperties);
            }
            else if (graphic != null)
            {
                UIMaterialInstantiator.TryCreateMaterialCopy(graphic);
            }
        }
 /// <inheritdoc />
 public override void Init(GameObject host, InteractableThemePropertySettings settings)
 {
     base.Init(host, settings);
     propertyBlock = InteractableThemeShaderUtils.GetMaterialPropertyBlock(host, new ShaderProperties[0]);
     renderer      = Host.GetComponent <Renderer>();
 }