Exemplo n.º 1
0
 public MaterialPropertyBlock GetMaterialPropertyBlock(
     Material mat,
     Vector3 pos,
     Vector3 scale)
 {
     if (this.properties == null)
     {
         this.properties = new MaterialPropertyBlock();
     }
     this.properties.Clear();
     for (int index = 0; index < this.Floats.Length; ++index)
     {
         MaterialConfig.ShaderParametersFloat shaderParametersFloat = this.Floats[index];
         float src;
         float dst;
         float blendParameters = shaderParametersFloat.FindBlendParameters(pos, out src, out dst);
         this.properties.SetFloat(shaderParametersFloat.Name, Mathf.Lerp(src, dst, blendParameters));
     }
     for (int index = 0; index < this.Colors.Length; ++index)
     {
         MaterialConfig.ShaderParametersColor color = this.Colors[index];
         Color src;
         Color dst;
         float blendParameters = color.FindBlendParameters(pos, out src, out dst);
         this.properties.SetColor(color.Name, Color.Lerp(src, dst, blendParameters));
     }
     for (int index = 0; index < this.Textures.Length; ++index)
     {
         MaterialConfig.ShaderParametersTexture texture = this.Textures[index];
         Texture blendParameters = texture.FindBlendParameters(pos);
         if (Object.op_Implicit((Object)blendParameters))
         {
             this.properties.SetTexture(texture.Name, blendParameters);
         }
     }
     for (int index = 0; index < this.ScaleUV.Length; ++index)
     {
         Vector4 vector = mat.GetVector(this.ScaleUV[index]);
         ((Vector4) ref vector).\u002Ector((float)(vector.x * scale.y), (float)(vector.y * scale.y), (float)vector.z, (float)vector.w);
         this.properties.SetVector(this.ScaleUV[index], vector);
     }
     return(this.properties);
 }
Exemplo n.º 2
0
    public MaterialPropertyBlock GetMaterialPropertyBlock(Material mat, Vector3 pos, Vector3 scale)
    {
        float single;
        float single1;
        Color color;
        Color color1;

        if (this.properties == null)
        {
            this.properties = new MaterialPropertyBlock();
        }
        this.properties.Clear();
        for (int i = 0; i < (int)this.Floats.Length; i++)
        {
            MaterialConfig.ShaderParametersFloat floats = this.Floats[i];
            float single2 = floats.FindBlendParameters(pos, out single, out single1);
            this.properties.SetFloat(floats.Name, Mathf.Lerp(single, single1, single2));
        }
        for (int j = 0; j < (int)this.Colors.Length; j++)
        {
            MaterialConfig.ShaderParametersColor colors = this.Colors[j];
            float single3 = colors.FindBlendParameters(pos, out color, out color1);
            this.properties.SetColor(colors.Name, Color.Lerp(color, color1, single3));
        }
        for (int k = 0; k < (int)this.Textures.Length; k++)
        {
            MaterialConfig.ShaderParametersTexture textures = this.Textures[k];
            Texture texture = textures.FindBlendParameters(pos);
            if (texture)
            {
                this.properties.SetTexture(textures.Name, texture);
            }
        }
        for (int l = 0; l < (int)this.ScaleUV.Length; l++)
        {
            Vector4 vector = mat.GetVector(this.ScaleUV[l]);
            vector = new Vector4(vector.x * scale.y, vector.y * scale.y, vector.z, vector.w);
            this.properties.SetVector(this.ScaleUV[l], vector);
        }
        return(this.properties);
    }