static void CreatToPrefab(MenuCommand menuCommand) { if (menuCommand.context != null) { CreatDirectory(); GameObject selectGameObject = menuCommand.context as GameObject; //判断有没有源头对象 if (IsTemplatePrefab_Only_InHierarchy(selectGameObject)) { UITemplateEditorWindow.AddWindow(UITemplateEditorWindow.TemplateWindowType.type1, selectGameObject); } else { string createPath = AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabParent(selectGameObject)); CreatePrefab(selectGameObject, createPath); } } else { EditorUtility.DisplayDialog("错误!", "请选择一个GameObject", "OK"); } }
static public void AddWindow(TemplateWindowType type = TemplateWindowType.type0, GameObject tmpObj = null) { _type = type; _source = tmpObj; //创建窗口 Rect wr = new Rect(0, 0, 500, 500); UITemplateEditorWindow window = (UITemplateEditorWindow)EditorWindow.GetWindowWithRect(typeof(UITemplateEditorWindow), wr, true, "模板生成窗口"); window.Show(); }