标签:tool prefab resources public sel ons active ref void
2016-12-20
using UnityEngine; using System.Collections; using UnityEditor; public class ToolsCreatPrefab { [MenuItem("Tools/Creat All Children Prefab")] public static void BatchPrefab() { //选中的物体 Transform tParent = ((GameObject)Selection.activeObject).transform; Object tempPrefab; int i = 0; foreach (Transform item in tParent) { //现在指定的位置创建一个空的预制物 然后查找你点击物体下的所有子物体 名字还是用子物体的名字 tempPrefab = PrefabUtility.CreateEmptyPrefab("Assets/Resources/Prefabs/Model/" + item.name + ".prefab"); tempPrefab = PrefabUtility.ReplacePrefab(item.gameObject, tempPrefab); i++; } } }
标签:tool prefab resources public sel ons active ref void
原文地址:http://www.cnblogs.com/zhangjieforshanghai/p/6203534.html