static public void ExportBlockGroup(object obj) { var root = obj as GameObject; if (root.transform.childCount > 0) { var path = EditorUtility.SaveFolderPanel("Please select export folder", Application.dataPath, "Rescources"); if (!string.IsNullOrEmpty(path)) { if (path.Contains(Application.dataPath)) { var assetPath = ""; foreach (var go in FormatUtility.FormatGameObjectsName(root.transform)) { var asset = CreateBlock(go); if (asset.ToDictionary().Count > 0) { assetPath = path.Replace(Application.dataPath, "Assets"); assetPath += "/" + go.name + ".asset"; ScriptableObjectUtility.CreateAsset(asset, assetPath); } } ProjectWindowUtil.ShowCreatedAsset(AssetDatabase.LoadAssetAtPath <Object>(assetPath)); } else { Debug.LogError("Sorry, we cannot export file out of 'Assets' folder!"); } } } }
private void OnControlGUI(int index) { EditorGUILayout.LabelField(ControlPanelStr, EditorStyles.boldLabel); if (index == 0) { if (GUILayout.Button(FormatSelectedGameObjectsNameStr)) { FormatUtility.FormatGameObjectsName(Selection.gameObjects); } if (GUILayout.Button(OrderSelectedGameObjectsStr)) { FormatUtility.OrderSelectedGameObjects(); } } else if (index == 1) { prefabObject = EditorGUILayout.ObjectField(PrefabForReplaceStr, prefabObject, typeof(GameObject), false); #if UNITY_2018_3_OR_NEWER EditorGUI.BeginDisabledGroup(prefabObject == null || !PrefabUtility.IsPartOfPrefabAsset(prefabObject)); #else EditorGUI.BeginDisabledGroup(prefabObject == null || PrefabUtility.GetPrefabType(prefabObject) != PrefabType.Prefab); #endif if (GUILayout.Button(ReplaceGameObjectsWithPrefabStr)) { PrefabsUtility.ReplacingGameObjectsWithPrefab(prefabObject as GameObject, Selection.objects.Select(obj => obj as GameObject).Where(go => go != null).ToArray()); } EditorGUI.EndDisabledGroup(); } else if (index == 2) { if (HasMatchedAssets()) { OnControlMatchedAssetsGUI(); } else { OnControlAnalysisAssetGUI(); } } else if (index == 3) { OnControlRenderQueueGUI(); } else if (index == 4) { if (HasFoundAssets()) { OnControlFoundAssetsGUI(); } else { OnControlFindReferencesGUI(); } } }