BC2.Util.Texture.iTexture.LoadTexture C# (CSharp) Method

LoadTexture() public static method

public static LoadTexture ( string path ) : Texture2D
path string
return UnityEngine.Texture2D
        public static Texture2D LoadTexture(string path)
        {
            var s_Data = File.ReadAllBytes(path);
            using (var s_Reader = new BinaryReader (new MemoryStream (s_Data))) {
                stream = s_Reader;
                u1 = Long ();
                u2 = Long ();
                format = Long ();
                u4 = Long ();
                sizex = Long ();
                sizey = Long ();
                u5 = Long ();
                mipmaps = Long ();

                int i = 0;
                while(i < mipmaps) {
                    int size = Long ();
                    mipmapsize += size;
                    i++;
                }
                int endPos = FTell ();
                int i2 = 0;
                Bytes (92 - endPos);
                byte[] mipmapdata = Bytes (mipmapsize);
                data = mipmapdata;

            }

            TextureFormat texFormat = TextureFormat.Alpha8;
            if (format == 0 || format == 18) {
                texFormat = TextureFormat.DXT1;
            } else if (format == 1) {
                texFormat = TextureFormat.DXT1; // should be dxt3
            } else if (format == 2 || format == 19 || format == 20) {
                texFormat = TextureFormat.DXT5;
            } else if (format == 9) {
                texFormat = TextureFormat.RGBA32;
            } else if (format == 10) {
                texFormat = TextureFormat.RGBA32;
            }
            Texture2D texture = null;
            bool useMipmaps = false;
            if(mipmaps > 1) {
                useMipmaps = true;
            }

            texture = new Texture2D (sizex, sizey, texFormat, useMipmaps);

            texture.LoadRawTextureData (data);
            texture.Apply ();
            return texture;
        }