PortableMaterial GetTextureMaterial(uint texture) { if (!textureMaterials.ContainsKey(texture)) { PortableMaterial material = new PortableMaterial(); material.name = string.Format("texture_{0}", texture); material.colour = new PortableVector3(1f, 1f, 1f); material.texture = textures[(int)texture]; textureMaterials.Add(texture, material); } return(textureMaterials[texture]); }
PortableMaterial GetFlatMaterial(uint colour) { if (!flatMaterials.ContainsKey(colour)) { var r = colour >> 16 & 0xFF; var b = colour >> 8 & 0xFF; var g = colour & 0xFF; PortableMaterial material = new PortableMaterial(); material.name = string.Format("colour_{0}_{1}_{2}", r, g, b); material.colour = new PortableVector3(r / 255f, b / 255f, g / 255f); flatMaterials.Add(colour, material); } return(flatMaterials[colour]); }