void OnGUI() { Init(); if (grid) { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Layer: " + grid.currentLayer.ToString(), GUILayout.Width(80)); if (GUILayout.Button(new GUIContent(LeftIcon))) { SwitchLayer(true); } if (GUILayout.Button(new GUIContent(RightIcon))) { SwitchLayer(false); } if (GUILayout.Button(new GUIContent(AdIconB))) { AddLayer(); } if (GUILayout.Button(new GUIContent(BinIcon))) { DeleteLayer(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (grid.gridEnabled) { if (GUILayout.Button((new GUIContent(PauseIcon)))) { HideLayerHelper(false); grid.gridEnabled = false; } } else { if (GUILayout.Button((new GUIContent(ForwardIcon)))) { grid.gridEnabled = true; } } if (grid.mode == 0) { if (GUILayout.Button(BrushIcon)) { grid.mode = 1; grid.hideOtherLayer = true; HideLayerHelper(true); } } else { if (GUILayout.Button(EraserIcon)) { grid.mode = 0; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (grid.showGrid) { if (GUILayout.Button("Hide Grid")) { grid.showGrid = false; } } else { if (GUILayout.Button("Show Grid")) { grid.showGrid = true; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); switch (grid.snapToGrid) { case 0: if (GUILayout.Button("Snap to Grid")) { grid.snapToGrid = 1; } break; case 1: if (GUILayout.Button("Free Hand")) { grid.snapToGrid = 0; } break; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (!grid.hideOtherLayer) { if (GUILayout.Button("Hide other Layers")) { HideLayerHelper(true); } } else { if (GUILayout.Button("Show other Layers")) { HideLayerHelper(false); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent(LeftIcon))) { MoveLast(0); } if (GUILayout.Button(new GUIContent(RightIcon))) { MoveLast(1); } if (GUILayout.Button(new GUIContent(UpIcon))) { MoveLast(2); } if (GUILayout.Button(new GUIContent(DownIcon))) { MoveLast(3); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Grid Settings")) { GridSettings window = (GridSettings)EditorWindow.GetWindow(typeof(GridSettings)); window.Init(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (grid.complexView) { if (GUILayout.Button("ComplexView")) { grid.complexView = false; } } else { if (GUILayout.Button("Simple View")) { grid.complexView = true; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(350), GUILayout.ExpandWidth(true)); int prefCounter = 0; if (grid.complexView) { foreach (GameObject obj in grid.prefabs) { if (obj) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(obj.name, GUILayout.Width(130)); EditorGUILayout.BeginHorizontal(); if (grid.selectedObj == obj) { if (GUILayout.Button(new GUIContent(FlagIcon, "Select Prefab"), GUILayout.Width(64))) { Select(obj); } } else { if (GUILayout.Button(new GUIContent(CheckIcon, "Select Prefab"), GUILayout.Width(64))) { Select(obj); } } if (GUILayout.Button(new GUIContent(BinIcon, "Delete Prefab from list"), GUILayout.Width(64))) { Delete(obj); break; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); Texture2D prefabIcon = AssetPreview.GetAssetPreview(obj); if (prefabIcon == null) { if (GUILayout.Button(EmptyIcon, GUILayout.Height(50), GUILayout.Width(50))) { Select(obj); } } else { if (GUILayout.Button(prefabIcon, GUILayout.Height(50), GUILayout.Width(50))) { Select(obj); } } EditorGUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(UpIcon), GUILayout.Width(25), GUILayout.Height(25))) { MovePrefab(true, prefCounter); break; } if (GUILayout.Button(new GUIContent(DownIcon), GUILayout.Width(25), GUILayout.Height(25))) { MovePrefab(false, prefCounter); break; } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); prefCounter++; } } } else { int ticker = 0; foreach (GameObject obj in grid.prefabs) { if (obj) { if (ticker == 0) { EditorGUILayout.BeginHorizontal(); } Texture2D prefabIcon = AssetPreview.GetAssetPreview(obj); if (prefabIcon == null) { if (GUILayout.Button(EmptyIcon, GUILayout.Height(50), GUILayout.Width(50))) { Select(obj); } } else { if (GUILayout.Button(prefabIcon, GUILayout.Height(50), GUILayout.Width(50))) { Select(obj); } } if (ticker == 3) { EditorGUILayout.EndHorizontal(); ticker = 0; } else { ticker++; } prefCounter++; } } if (ticker != 0) { EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (grid.selectedObj != null) { EditorGUILayout.LabelField(grid.selectedObj.name); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (grid.selectedObj != null) { Texture2D prefabIcon2 = AssetPreview.GetAssetPreview(grid.selectedObj); if (prefabIcon2 == null) { GUILayout.Button(EmptyIcon, GUILayout.Height(80)); } else { GUILayout.Button(prefabIcon2, GUILayout.Height(80)); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent(AdIcon, "Select the prefabs in the project view and then hit the button."))) { CreateNewPrefab(); } if (GUILayout.Button(new GUIContent(BinIconB))) { RemovePrefabs(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(""); EditorGUILayout.EndHorizontal(); EditorUtility.SetDirty(grid); } else { if (GUILayout.Button("Create Grit")) { string path = AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(this)); path = path.Substring(0, path.LastIndexOf('/')); path = path.Substring(0, path.LastIndexOf('/')); path = path.Substring(0, path.LastIndexOf('/') + 1); GameObject obj = (GameObject)PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath(path + "BurnnerGames/Grid.prefab", typeof(GameObject))); obj.transform.position = new Vector3(0, 0, 0); } } }