GQ_Communicate/GQ_TongXin/Assets/script/FbxToPrefabInEditor.cs

54 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using System;
public class FbxToPrefabInEditor
{
[MenuItem("Tools/ CreatPrefab")]
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<TaKeUp>())
//{
// 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/" + 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++;
// }
}
}
}