public Type GetTypeFromAttrs(OverrideData overrideData)
    {
        Type overrideType    = null;
        bool componentExists = false;

        foreach (var t in TypeManager.GetAllTypes())
        {
            if (t.Type != null)
            {
                //TODO(andrew.theisen): this grabs the first IComponentData that matches these attributes but multiple matches can exist such as URPMaterialPropertyBaseColor
                //                and HDRPMaterialPropertyBaseColor. It actually shouldn't matter which one is used can they can work either shader.
                foreach (var attr in t.Type.GetCustomAttributes(typeof(MaterialPropertyAttribute), false))
                {
                    if (TypeManager.IsSharedComponentType(t.TypeIndex))
                    {
                        continue;
                    }

                    var propAttr = (MaterialPropertyAttribute)attr;
                    MaterialPropertyFormat propFormat = 0;
                    //TODO(andrew.theisen): So this won't use exisiting IComponentDatas always. for example:
                    //                HDRPMaterialPropertyEmissiveColor is Float3, but the ShaderPropertyType
                    //                is Color but without alpha. can fix this when we can get the DOTS
                    //                type or byte size of the property
                    if (overrideData.type == ShaderPropertyType.Vector || overrideData.type == ShaderPropertyType.Color)
                    {
                        propFormat = MaterialPropertyFormat.Float4;
                    }
                    else if (overrideData.type == ShaderPropertyType.Float || overrideData.type == ShaderPropertyType.Range)
                    {
                        propFormat = MaterialPropertyFormat.Float;
                    }
                    else
                    {
                        break;
                    }

                    if (propAttr.Name == overrideData.name && propAttr.Format == propFormat)
                    {
                        overrideType    = t.Type;
                        componentExists = true;
                        break;
                    }
                }
            }
            if (componentExists)
            {
                break;
            }
        }
        return(overrideType);
    }
 public MaterialPropertyAttribute(string materialPropertyName, MaterialPropertyFormat format, int overrideSize = -1)
 {
     Name         = materialPropertyName;
     Format       = format;
     OverrideSize = overrideSize;
 }
 public MaterialPropertyAttribute(string materialPropertyName, MaterialPropertyFormat format)
 {
     Name   = materialPropertyName;
     Format = format;
 }
Exemple #4
0
 public MaterialPropertyAttribute(string materialPropertyName, MaterialPropertyFormat format, short overrideSizeGPU = -1)
 {
     Name            = materialPropertyName;
     Format          = format;
     OverrideSizeGPU = overrideSizeGPU;
 }