Exemplo n.º 1
0
        private static MaterialProperty GetFakeAnimatedProperty(string propName)
        {
            // Horrible reflection hack, currently the only way to instantiate a new MaterialProperty and set its name, which is what the optimizer checks for.
            var materialProperty = new MaterialProperty();
            var nameField        = materialProperty.GetType().GetField("m_Name", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            nameField.SetValue(materialProperty, propName + AnimatedSuffix);
            var typeField = materialProperty.GetType().GetField("m_Type", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            typeField.SetValue(materialProperty, MaterialProperty.PropType.Float);
            var valueField = materialProperty.GetType().GetField("m_Value", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            valueField.SetValue(materialProperty, 1.0f);

            return(materialProperty);
        }
Exemplo n.º 2
0
 public MaterialPropertyWrapper(MaterialProperty materialProperty)
 {
     if (materialProperty.GetType().Equals(typeof(MaterialFloatProperty)))
     {
         typeIndex     = 0;
         floatProperty = (MaterialFloatProperty)materialProperty;
     }
     else if (materialProperty.GetType().Equals(typeof(MaterialColorProperty)))
     {
         typeIndex     = 1;
         colorProperty = (MaterialColorProperty)materialProperty;
     }
     else if (materialProperty.GetType().Equals(typeof(MaterialVectorProperty)))
     {
         typeIndex      = 2;
         vectorProperty = (MaterialVectorProperty)materialProperty;
     }
     else if (materialProperty.GetType().Equals(typeof(MaterialTextureProperty)))
     {
         typeIndex       = 3;
         textureProperty = (MaterialTextureProperty)materialProperty;
     }
 }