private void Start() { this.GetComponent <Importer>().ReadScene(); ImportDataTypes.Scene scene = this.GetComponent <Importer>().scene; for (int i = 0; i < scene.header.transformCount; i++) { CreateTransform(scene.body.transforms[i]); } for (int i = 0; i < scene.header.meshCount; i++) { ImportDataTypes.Mesh mesh = scene.body.meshes[i]; CreateMesh(mesh); } }
public void ReadScene() { string finalPath = System.IO.Path.Combine(Application.streamingAssetsPath, resourceFileName); if (System.IO.File.Exists(finalPath)) { FileStream fs = new FileStream(finalPath, FileMode.Open); try { if (fs.CanRead && fs.CanSeek) { fs.Seek(0, SeekOrigin.Begin); BinaryReader br = new BinaryReader(fs); scene = new ImportDataTypes.Scene(); scene.Read(ref br); } else { print("Couldn't read file: " + finalPath); } } catch(Exception e) { print("Couldn't read file: " + finalPath); print(e.Message); print(e.Source); } fs.Close(); } else { print("Couldn't find file: " + finalPath); } }