protected string[][] Parse(AbstractTexture texture) { TextAsset targetFile = Resources.Load <TextAsset>("assetBundleInfo"); BundleMap map = JsonUtility.FromJson <BundleMap>(targetFile.text); string[][] textures = null; foreach (var raceInfo in map.races) { if (raceInfo.race.Equals(texture.CharacterRace)) { foreach (var textureInfo in raceInfo.textures) { if (textureInfo.type.Equals(texture.Type)) { textures = new string[textureInfo.texturePaths.Count][]; int i = 0; foreach (var textureColors in textureInfo.texturePaths) { textures[i] = new string[textureColors.colors.Count]; int j = 0; foreach (var texturePath in textureColors.colors) { textures[i][j] = texturePath.path; j++; } i++; } } } } } return(textures); }
/* * 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); }
private string[][] Parse(AbstractTexture texture, string path) { var dirPath = Path.Combine(Application.dataPath, path.Substring(7)); if (!Directory.Exists(dirPath)) { return(new string[0][]); } var folders = Directory.GetDirectories(dirPath); bool withColor = folders.Length != 0; string[][] texturePaths; if (withColor) { texturePaths = new string[folders.Length][]; for (int i = 0; i < folders.Length; i++) { var textures = AssetDatabase.FindAssets("t:texture2D", new string[] { folders[i].Substring(Application.dataPath.Length - 6) } ); texturePaths[i] = new string[textures.Length]; for (int j = 0; j < textures.Length; j++) { texturePaths[i][j] = AssetDatabase.GUIDToAssetPath(textures[j]); } } } else { var textures = AssetDatabase.FindAssets("t:texture2D", new string[] { path }); texturePaths = new string[textures.Length][]; for (int i = 0; i < textures.Length; i++) { texturePaths[i] = new string[] { AssetDatabase.GUIDToAssetPath(textures[i]) } } ; } return(texturePaths); } }
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 string[][] ParseTextures(AbstractTexture texture, string path = null) { return(Parse(texture)); }
public string[][] ParseTextures(AbstractTexture texture, string path = null) { return(Parse(texture, path ?? texture.GetFolderPath())); }