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 OnViewRenderQueueGUI() { var mats = FormatUtility.GetOrderedMaterialsFromActivatedScenes(); var labels = renderQueueLabels.OrderBy(kvp => kvp.Value).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); foreach (var kvp in mats) { if (!renderQueueFoldouts.ContainsKey(kvp.Key)) { renderQueueFoldouts.Add(kvp.Key, false); } DrawRenderQueueLabel(labels, kvp.Key.renderQueue); EditorGUILayout.BeginHorizontal(); Rect position; renderQueueFoldouts[kvp.Key] = EasyGUILayout.Foldout(renderQueueFoldouts[kvp.Key], GUIContent.none, 25, out position); EditorGUI.ObjectField(position, kvp.Key, typeof(Material), false); EditorGUILayout.EndHorizontal(); if (renderQueueFoldouts[kvp.Key]) { EditorGUI.indentLevel += 2; for (int i = 0; i < kvp.Value.Count; i++) { EditorGUILayout.ObjectField(string.Format(ElementStr, i), kvp.Value[i], typeof(GameObject), false); } EditorGUI.indentLevel -= 2; } } }
private void OnControlRenderQueueGUI() { var mats = FormatUtility.GetOrderedMaterialsFromActivatedScenes(); var labels = renderQueueLabels.OrderBy(kvp => kvp.Value).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); foreach (var kvp in mats) { DrawRenderQueueLabel(labels, kvp.Key.renderQueue, EmptyStr); EditorGUI.BeginChangeCheck(); var renderQueue = EditorGUILayout.DelayedIntField(RenderQueueStr, kvp.Key.renderQueue); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(kvp.Key, ChangeRenderQueueStr); kvp.Key.renderQueue = renderQueue; EditorUtility.SetDirty(kvp.Key); break; } if (renderQueueFoldouts.ContainsKey(kvp.Key) && renderQueueFoldouts[kvp.Key]) { for (int i = 0; i < kvp.Value.Count; i++) { EditorGUILayout.LabelField(EmptyStr); } } } }
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(); } } }