コード例 #1
0
        public static Texture2D GetTextureFromImg(string name, out DFPosition offset, TextureFormat format = TextureFormat.ARGB32)
        {
            offset = new DFPosition();

            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

            if (!dfUnity.IsReady)
            {
                return(null);
            }

            ImgFile   imgFile = new ImgFile(Path.Combine(dfUnity.Arena2Path, name), FileUsage.UseMemory, true);
            Texture2D texture = null;

            // Custom texture
            if (TextureReplacement.CustomImageExist(name))
            {
                texture = TextureReplacement.LoadCustomImage(name);
            }
            // Daggerfall texture
            else
            {
                imgFile.LoadPalette(Path.Combine(dfUnity.Arena2Path, imgFile.PaletteName));
                texture = GetTextureFromImg(imgFile, format);
            }

            texture.filterMode = DaggerfallUI.Instance.GlobalFilterMode;
            offset             = imgFile.ImageOffset;

            return(texture);
        }