using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; using System.IO; using System; public class FbxToPrefabInEditor { [MenuItem("工具/ 批量生成预制体")] public static void CreatPrefab() { Transform[] aaaa = Selection.transforms; // 只能在 Hierarchy 面板下多选,在其他面板 下 只能 选一个 Debug.Log(aaaa.Length); if (aaaa.Length == 0) { return; } // UnityEngine.Object tempPrefab; //if (aaaa[0].transform.GetComponent()) //{ // Debug.Log("aaaaaaaa"); //} Debug.Log(Application.dataPath + " lujing"); for (int i = 0; i < aaaa.Length; i++) { //tempPrefab = PrefabUtility.CreateEmptyPrefab(Application.dataPath+"/0222"+ aaaa[i].name+".prefab"); //tempPrefab = PrefabUtility.ReplacePrefab(aaaa[i].gameObject, tempPrefab); //Debug.Log(aaaa[i].name); PrefabUtility.CreatePrefab("Assets/Resources/"+ "古泉站机房模型90个型号/" + aaaa[i].name + ".prefab" + "", aaaa[i].gameObject); //foreach (var item in aaaa) //{ //} // Transform tParent = ((GameObject)Selection.activeObject).transform; //UnityEngine.Object tempPrefab; // int i = 0; // foreach (Transform t in tParent) // { // tempPrefab = PrefabUtility.CreateEmptyPrefab("Assets/Editor" + t.name + ".prefab"); // tempPrefab = PrefabUtility.ReplacePrefab(t.gameObject, tempPrefab); // i++; // } } } }