private void OnPostprocessTexture(Texture2D texture) { if (!TexturePackerImporter.spriteSheets.isNormalmapSheet(assetPath)) { return; } TexturePackerImporter.createMaterialForNormalmap(assetPath, TexturePackerImporter.spriteSheets.spriteFileForNormalsFile(assetPath)); }
private void Generate(UnityEngine.Object[] objects, bool[] valids, GenState gen) { for (int i = 0; i < valids.Length; i++) { if (!valids[i]) { continue; } TextAsset atlas = objects[i] as TextAsset; if (gen.genOBJ) { Mesh[] meshes = TexturePackerImporter.GenerateMeshes(atlas); if (meshes == null) { return; } TexturePackerImporter.GenerateOBJs(atlas, meshes); } if (gen.genPrefab) { Mesh[] meshes = TexturePackerImporter.GenerateMeshes(atlas); if (meshes == null) { return; } Material mat = TexturePackerImporter.GenerateMaterial(atlas); if (mat == null) { return; } TexturePackerImporter.GeneratePrefabs(atlas, meshes, mat); } if (gen.genMesh) { TexturePackerImporter.GenerateMeshes(atlas); } if (gen.genMat) { TexturePackerImporter.GenerateMaterial(atlas); } } }
private void OnPreprocessTexture() { TextureImporter importer = assetImporter as TextureImporter; if (TexturePackerImporter.spriteSheets.isSpriteSheet(assetPath)) { // Debug.Log("Sprite "+TexturePackerImporter.spriteSheets.spriteMetaDataForSpriteFile(assetPath)); TexturePackerImporter.updateSpriteMetaData(importer, TexturePackerImporter.spriteSheets.spriteMetaDataForSpriteFile(assetPath)); } // else // Debug.Log("NO sprite?¿? " +assetPath); if (!TexturePackerImporter.spriteSheets.isNormalmapSheet(assetPath)) { return; } TexturePackerImporter.prepareNormalmapForImport(importer); }
void OnGUI() { UnityEngine.Object[] objects = Selection.objects; bool[] valids = TexturePackerImporter.ValidateAssets(objects); int numValids = 0; EditorGUI.indentLevel++; for (int i = 0; i < valids.Length; i++) { if (valids[i]) { numValids++; EditorGUILayout.LabelField(objects[i].name); } } EditorGUI.indentLevel--; if (numValids == 0) { return; } GenState gen = new GenState(); gen.genMesh = Toggle("Generate Meshes", prefGenMesh); if (!gen.genMesh && EditorPrefs.GetBool(prefGenOBJ)) { EditorPrefs.SetBool(prefGenOBJ, false); } if (!gen.genMesh && EditorPrefs.GetBool(prefGenPrefab)) { EditorPrefs.SetBool(prefGenPrefab, false); } gen.genMat = Toggle("Generate Materials", prefGenMaterial); gen.genOBJ = Toggle("Generate OBJs", prefGenOBJ); gen.genPrefab = Toggle("Generate Prefabs", prefGenPrefab); if (gen.genOBJ && !gen.genMesh) { EditorPrefs.SetBool(prefGenMesh, true); } if (gen.genPrefab && !gen.genMesh) { EditorPrefs.SetBool(prefGenMesh, true); } if (gen.genPrefab && !gen.genMat) { EditorPrefs.SetBool(prefGenMaterial, true); } if (GUILayout.Button("Generate")) { Generate(objects, valids, gen); } }