/* * Parse Armor and weapon meshes from AssetBundle */ private IEnumerator Parse(AbstractMesh mesh, Action <GameObject[], AbstractTexture[]> callback) { TextAsset targetFile = Resources.Load <TextAsset>("assetBundleInfo"); GameObject[] meshObjects = null; AbstractTexture[] textures = null; var textureLoader = new TextureLoader(); BundleMap map = JsonUtility.FromJson <BundleMap>(targetFile.text); foreach (var raceInfo in map.races) { if (raceInfo.race.Equals(mesh.CharacterRace)) { foreach (var meshInfo in raceInfo.meshes) { if (meshInfo.type.Equals(mesh.MeshType)) { meshObjects = new GameObject[meshInfo.meshPaths.Count]; textures = new AbstractTexture[meshInfo.meshPaths.Count]; int i = 0; foreach (var meshPathInfo in meshInfo.meshPaths) { yield return(LoadMeshCoroutine(meshPathInfo.modelPath, (GameObject meshGameObject) => { meshObjects[i] = meshGameObject; })); var texturePaths = new string[meshPathInfo.textures.Count][]; int j = 0; foreach (var texture in meshPathInfo.textures) { texturePaths[j] = new string[texture.colors.Count]; int k = 0; foreach (var color in texture.colors) { texturePaths[j][k] = color.path; k++; } j++; } textures[i] = new MeshTexture(textureLoader, mesh.CharacterRace, texturePaths); i++; } } } } } callback.Invoke(meshObjects, textures); }
public override void Load() { Entity cam = EntityFactory.CreateEntity(); cam.name = "cam"; cam.AddComponent(new Camera()); Entity ent = EntityFactory.CreateEntity(); ent.AddComponent(new Move()); ent.AddComponent(new MeshRenderer()); MeshTexture texture = MeshTexture.LoadTexture("Res/Images/bobross.png"); ent.GetComponent <MeshRenderer>().texturedMesh = new TexturedMesh(RawMesh.LoadToVao(v1, textureCoords, indices), texture); base.Load(); }
public void ParseMeshes(AbstractMesh mesh, Action <GameObject[], AbstractTexture[]> callback) { var textureLoader = new TextureLoader(); var folders = Directory.GetDirectories(Path.Combine(Application.dataPath, mesh.GetFolderPath().Substring(7))); var meshObjects = new GameObject[folders.Length]; var textures = new AbstractTexture[folders.Length]; var modelType = meshAtlasType == MeshAtlasType.Static ? "StaticModel" : "Model"; for (int i = 0; i < folders.Length; i++) { string path = folders[i].Substring(Application.dataPath.Length - 6); var meshGUIDs = AssetDatabase.FindAssets("t:GameObject", new string[] { path + "/" + modelType } ); meshObjects[i] = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(meshGUIDs[0]), typeof(GameObject)) as GameObject; textures[i] = new MeshTexture(textureLoader, mesh.CharacterRace, path + "/Textures"); } callback.Invoke(meshObjects, textures); }
public TexturedMesh(RawMesh _mesh, MeshTexture _texture) { this.rawMesh = _mesh; this.texture = _texture; }