private Material OnAssignMaterialModel(Material defaultMaterial, Renderer renderer) { if (!UseThisImporter()) { return(null); } // This is the only reliable place to assign materials in the import chain. // It kind of sucks because we have to go about making the mesh/material association in a roundabout way. // Note: This seems dangerous, but getting to the name of the base gameObject appears to be take some work. // The root gameObject, at this point, seems to have "_root" appeneded to it. // Once the model if finished being imported it drops this postifx // This is something that could change without our knowledge string rootName = renderer.transform.root.gameObject.name; int rootIndex = rootName.LastIndexOf("_root"); if (rootIndex != -1) { rootName = rootName.Remove(rootIndex); } #if !UNITY_WEBPLAYER ImportTiled2Unity importer = new ImportTiled2Unity(this.assetPath); return(importer.FixMaterialForMeshRenderer(rootName, renderer)); #else return(null); #endif }
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath) { foreach (string imported in importedAssets) { if (UseThisImporter(imported)) { //Debug.Log(string.Format("Imported: {0}", imported)); } else { continue; } #if !UNITY_WEBPLAYER using (ImportTiled2Unity t2uImporter = new ImportTiled2Unity(imported)) { if (t2uImporter.IsTiled2UnityFile()) { // Start the import process. This will trigger textures and meshes to be imported as well. t2uImporter.ImportBegin(imported, t2uImporter); } else if (t2uImporter.IsTiled2UnityTexture()) { // A texture was imported. Once all textures are imported then we'll import materials. t2uImporter.TextureImported(imported); } else if (t2uImporter.IsTiled2UnityMaterial()) { // A material was imported. Once all materials are imported then we'll import meshes. t2uImporter.MaterialImported(imported); } else if (t2uImporter.IsTiled2UnityWavefrontObj()) { // A mesh was imported. Once all meshes are imported we'll import the prefabs. t2uImporter.MeshImported(imported); } else if (t2uImporter.IsTiled2UnityPrefab()) { // A prefab was imported. Once all prefabs are imported then the import is complete. t2uImporter.PrefabImported(imported); } else if (t2uImporter.IsTiled2UnityTmx()) { // A TMX - let's kick off an autobuild t2uImporter.TmxImported(imported); } else if (t2uImporter.IsTiled2UnityTsx()) { // A tileset - let's make that available for terrain lookups t2uImporter.TsxImported(imported); } } #endif } }
private UnityEngine.Material OnAssignMaterialModel(Material defaultMaterial, Renderer renderer) { if (!UseThisImporter()) { return(null); } // What is the parent mesh name? string rootName = System.IO.Path.GetFileNameWithoutExtension(this.assetPath); #if !UNITY_WEBPLAYER ImportTiled2Unity importer = new ImportTiled2Unity(this.assetPath); return(importer.FixMaterialForMeshRenderer(rootName, renderer)); #else return(null); #endif }
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath) { foreach (string imported in importedAssets) { if (UseThisImporter(imported)) { //Debug.Log(string.Format("Imported: {0}", imported)); } else { continue; } #if !UNITY_WEBPLAYER using (ImportTiled2Unity t2uImporter = new ImportTiled2Unity(imported)) { if (t2uImporter.IsTiled2UnityFile()) { // Start the import process. This will trigger textures and meshes to be imported as well. t2uImporter.ImportBegin(imported); } else if (t2uImporter.IsTiled2UnityTexture()) { // A texture was imported and the material assigned to it may need to be fixed t2uImporter.TextureImported(imported); } else if (t2uImporter.IsTiled2UnityWavefrontObj()) { // Now that the mesh has been imported we will build the prefab t2uImporter.MeshImported(imported); } else if (t2uImporter.IsTiled2UnityPrefab()) { // Now the the prefab is built and imported we are done t2uImporter.ImportFinished(imported); Debug.Log(string.Format("Imported prefab from Tiled map editor: {0}", imported)); } } #endif } }
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath) { foreach (string imported in importedAssets) { if (UseThisImporter(imported)) { //Debug.Log(string.Format("Imported: {0}", imported)); } else { continue; } #if !UNITY_WEBPLAYER using (ImportTiled2Unity t2uImporter = new ImportTiled2Unity(imported)) { if (t2uImporter.IsTiled2UnityFile()) { // Start the import process. This will trigger textures and meshes to be imported as well. t2uImporter.ImportBegin(imported); } else if (t2uImporter.IsTiled2UnityTexture()) { // A texture was imported and the material assigned to it may need to be fixed t2uImporter.TextureImported(imported); } else if (t2uImporter.IsTiled2UnityWavefrontObj()) { // Now that the mesh has been imported we will build the prefab t2uImporter.MeshImported(imported); } else if (t2uImporter.IsTiled2UnityPrefab()) { // Now the the prefab is built and imported we are done t2uImporter.ImportFinished(imported); Debug.Log(string.Format("Imported prefab from Tiled map editor: {0}", imported)); } } #endif } }
private Material OnAssignMaterialModel(Material defaultMaterial, Renderer renderer) { if (!UseThisImporter()) return null; // This is the only reliable place to assign materials in the import chain. // It kind of sucks because we have to go about making the mesh/material association in a roundabout way. // Note: This seems dangerous, but getting to the name of the base gameObject appears to be take some work. // The root gameObject, at this point, seems to have "_root" appeneded to it. // Once the model if finished being imported it drops this postifx // This is something that could change without our knowledge string rootName = renderer.transform.root.gameObject.name; int rootIndex = rootName.LastIndexOf("_root"); if (rootIndex != -1) { rootName = rootName.Remove(rootIndex); } ImportTiled2Unity importer = new ImportTiled2Unity(this.assetPath); return importer.FixMaterialForMeshRenderer(rootName, renderer); }
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath) { foreach (string imported in importedAssets) { if (UseThisImporter(imported)) { //Debug.Log(string.Format("Imported: {0}", imported)); } else { continue; } using (ImportTiled2Unity t2uImporter = new ImportTiled2Unity(imported)) { if (t2uImporter.IsTiled2UnityFile()) { // Start the import process by importing our textures and meshes t2uImporter.XmlImported(imported); } else if (t2uImporter.IsTiled2UnityTexture()) { // A texture was imported and the material assigned to it may need to be fixed t2uImporter.TextureImported(imported); } else if (t2uImporter.IsTiled2UnityWavefrontObj()) { t2uImporter.MeshImported(imported); } else if (t2uImporter.IsTiled2UnityPrefab()) { Debug.Log(string.Format("Imported prefab from Tiled map editor: {0}", imported)); } } } }
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath) { foreach (string imported in importedAssets) { if (UseThisImporter(imported)) { //Debug.Log(string.Format("Imported: {0}", imported)); } else { continue; } using (ImportTiled2Unity t2uImporter = new ImportTiled2Unity(imported)) { if (t2uImporter.IsTiled2UnityFile()) { // Start the import process by importing our textures and meshes t2uImporter.XmlImported(imported); } else if (t2uImporter.IsTiled2UnityTexture()) { // A texture was imported and the material assigned to it may need to be fixed t2uImporter.TextureImported(imported); } else if (t2uImporter.IsTiled2UnityWavefrontObj()) { t2uImporter.MeshImported(imported); } else if (t2uImporter.IsTiled2UnityPrefab()) { Debug.Log(string.Format("Imported prefab from Tiled map editor: {0}", imported)); } } } }