//Dado que los Scripts de editor no se pueden referenciar en los scripts que no estan dentro de Editor, al menos no se como, pasaremos como parametro la funcion de recogida del prefab por //ShowGUI, asi podremos obtener el prefab cuando se pulse, sin perder la estructura que tenemos, #if UNITY_EDITOR public void ShowGUI(PrefabCollectionWindow window) { GUILayout.Label(string.Format(Style.LABLE_DATABASE_TITLE, dataBaseName)); window.showPrefabs = EditorGUILayout.Foldout(window.showPrefabs, Style.LAYOUT_PREFABS); if (window.showPrefabs) { DrawCollection(prefabList, window); } window.showWalls = EditorGUILayout.Foldout(window.showWalls, Style.LAYOUT_WALLS); if (window.showWalls) { DrawCollection(Walls, window); } window.showRegions = EditorGUILayout.Foldout(window.showRegions, Style.LABLE_REGION_FIELD); if (window.showRegions) { //window.canUseRegions = EditorGUILayout.Toggle(window.canUseRegions); if (window.canUseRegions) { DrawCollection(regions, window); } else { EditorGUILayout.LabelField(Style.LABEL_CANT_USE_REGIONS, Style.centerText); } } DoAddButtons(window); }
public override void ShowGUI(PrefabCollectionWindow window) { EditorGUILayout.BeginVertical(); if (GUILayout.Button(preview, maxW, maxH)) { window.SelectPrefab(this); } EditorGUILayout.BeginHorizontal(maxW, maxHButton); GUIStyle style = new GUIStyle(GUI.skin.button); if (GUILayout.Button(Style.ICON_EDIT, style, maxWButton, maxHButton)) { window.Edit(this); } if (GUILayout.Button(Style.ICON_RELOAD, style, maxWButton, maxHButton)) { window.Reload(this); } if (GUILayout.Button(Style.ICON_CLOSE, style, maxWButton, maxHButton)) { window.DeletePrefab(this); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
private void DrawCollection <T>(List <T> collection, PrefabCollectionWindow window) where T : Container { EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(window.minSize.x), GUILayout.MinWidth(50)); int number = 0; try { foreach (var prefab in collection) { number++; prefab.ShowGUI(window); if (number > 2) { EditorGUILayout.EndHorizontal(); number = 0; EditorGUILayout.BeginVertical(); Rect rect = EditorGUILayout.GetControlRect(false, 1); rect.height = 1; EditorGUI.DrawRect(rect, new Color(0.5f, 0.5f, 0.5f, 1)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(window.minSize.x), GUILayout.MinWidth(50)); } } } catch { } EditorGUILayout.EndHorizontal(); }