Exemple #1
0
        public Material GetTextureMaterial(string textureName, bool transparent)
        {
            if (!_materials.ContainsKey(textureName))
            {
                Texture2D texture;
                if (VirtualFilesystem.Instance.FileExists(textureName + ".vqm"))
                {
                    texture = TextureParser.ReadVqmTexture(textureName + ".vqm", Palette);
                }
                else if (VirtualFilesystem.Instance.FileExists(textureName + ".map"))
                {
                    texture = TextureParser.ReadMapTexture(textureName + ".map", Palette);
                }
                else
                {
                    throw new Exception("Texture not found: " + textureName);
                }
                var material = Instantiate(transparent ? TransparentMaterialPrefab : TextureMaterialPrefab);
                material.mainTexture    = texture;
                material.name           = textureName;
                _materials[textureName] = material;
            }

            return(_materials[textureName]);
        }
Exemple #2
0
        public Texture2D GetTexture(string textureName)
        {
            string    filename = Path.GetFileNameWithoutExtension(textureName);
            Texture2D texture  = null;

            if (VirtualFilesystem.Instance.FileExists(filename + ".vqm"))
            {
                texture = TextureParser.ReadVqmTexture(filename + ".vqm", Palette);
            }
            else if (VirtualFilesystem.Instance.FileExists(filename + ".map"))
            {
                texture = TextureParser.ReadMapTexture(filename + ".map", Palette);
            }
            else
            {
                Debug.LogWarning("Texture not found: " + textureName);
            }
            return(texture);
        }