AcTools.Kn5File.Kn5.FromDirectory_Textures C# (CSharp) Method

FromDirectory_Textures() private method

private FromDirectory_Textures ( string dir ) : void
dir string
return void
        private void FromDirectory_Textures(string dir) {
            var array = JsonConvert.DeserializeObject<Kn5Texture[]>(File.ReadAllText(Path.Combine(dir, "textures.json")));

            Textures = new Dictionary<string,Kn5Texture>(array.Length);
            TexturesData = new Dictionary<string,byte[]>(array.Length);

            foreach (var texture in array) {
                var data = File.ReadAllBytes(Path.Combine(dir, "texture", texture.Name));
                texture.Length = data.Length;

                Textures[texture.Name] = texture;
                TexturesData[texture.Name] = data;
            }
        }

Usage Example

Example #1
0
        public static Kn5 FromDirectory(string dir, bool jsonMode) {
            if (!Directory.Exists(dir)) {
                throw new DirectoryNotFoundException(dir);
            }

            var kn5 = new Kn5(dir);
            
            kn5.FromDirectory_Header(dir);
            kn5.FromDirectory_Textures(dir);
            kn5.FromDirectory_Materials(dir);
            kn5.FromDirectory_Nodes(dir, jsonMode);

            return kn5;
        }
All Usage Examples Of AcTools.Kn5File.Kn5::FromDirectory_Textures