void TagsAndResetOptions(float height) { GUI.Label(new Rect(5, 25 + height, 200, 200), "Select Tag: "); indexT = EditorGUI.Popup(new Rect(180, 27 + height, 100, 15), indexT, tagNames); GUI.Label(new Rect(5, 45 + height, 200, 200), "Add/Edit/Remove Tag: "); tn = tn2; tn2 = EditorGUI.TextField(new Rect(180, 47 + height, 100, 15), tn); if (GUI.Button(new Rect(13, 67 + height, 80, 20), "Add")) { tagNames = layersandtags.addTags(tn2); } if (GUI.Button(new Rect(103, 67 + height, 80, 20), "Edit")) { tagNames = layersandtags.editTag(tagNames, tn2, indexT); } if (GUI.Button(new Rect(193, 67 + height, 80, 20), "Remove")) { tagNames = layersandtags.removeTag(tn2); } if (GUI.Button(new Rect(13, 92 + height, 260, 20), "Reset Tags and Layers")) { bool resposta = EditorUtility.DisplayDialog(Constants.warningString, "Do you really want to delete all of your layers and tags?", "Just do it!", "OH GOD, NO!"); if (resposta) { layersandtags.resetLayersAndTags(); } } }
void OnGUI() { windowRect = new Rect(this.position.x, this.position.y, this.position.width, this.position.height); //Pega um Rect do tamanho da janela scrollPos = GUI.BeginScrollView(new Rect(0, 0, windowRect.width, windowRect.height - 10), scrollPos, new Rect(0, 0, maxScroll.x, maxScroll.y), false, false); Event e = Event.current; int _scrollDifference; if (isScrollView) { _scrollDifference = scrollDifference - 10; } else { _scrollDifference = scrollDifference; } #region Layer Options for (int i = 0; i < editableLayerNames.Length; i++) //Preenche o vedor de Layers Editáveis { editableLayerNames[i] = allLayerNames[i + 8]; } GUI.Box(new Rect(0, 0, windowRect.width, windowRect.height), ""); GUI.Label(new Rect(5, 3, 200, 200), "Layer Options", EditorStyles.boldLabel); GUI.Label(new Rect(5, 20, 200, 200), "Select Layer: "); indexLayer = EditorGUI.Popup(new Rect(180, 19, windowRect.width - _scrollDifference, 15), indexLayer, editableLayerNames); GUI.Label(new Rect(5, 38, 200, 200), "Edit Layer Name: "); ln = allLayerNames[indexLayer + 8]; ln2 = EditorGUI.TextField(new Rect(180, 38, windowRect.width - _scrollDifference, 15), ln); indexLayers = 8 + indexLayer; allLayerNames = layersandtags.editLayers(allLayerNames, ln2, indexLayers); #endregion #region Tag Options GUI.Label(new Rect(5, 65, 200, 200), "Tag Options", EditorStyles.boldLabel); GUI.Label(new Rect(5, 82, 200, 200), "Select Tag: "); indexT = EditorGUI.Popup(new Rect(180, 81, windowRect.width - _scrollDifference, 15), indexT, tagNames); GUI.Label(new Rect(5, 100, 200, 200), "Add/Edit/Remove Tag: "); tn = tn2; tn2 = EditorGUI.TextField(new Rect(180, 100, windowRect.width - _scrollDifference, 15), tn); if (GUI.Button(new Rect(5, 118, (windowRect.width) / 3 - 17, 20), "Add")) { tagNames = layersandtags.addTags(tn2); } if (GUI.Button(new Rect(106 + ((windowRect.width - Constants.minWindowWidth) / 3), 118, (windowRect.width) / 3 - 17, 20), "Edit")) { tagNames = layersandtags.editTag(tagNames, tn2, indexT); } if (GUI.Button(new Rect(205 + (2 * (windowRect.width - Constants.minWindowWidth) / 3), 118, (windowRect.width) / 3 - 17, 20), "Remove")) { tagNames = layersandtags.removeTag(tn2); } #endregion #region Tile Set Options GUI.Label(new Rect(5, 153, 200, 200), "Tile Set Options", EditorStyles.boldLabel); GUI.Label(new Rect(5, 170, 200, 200), "Select Tile Set: "); indexTileSet = EditorGUI.Popup(new Rect(180, 169, windowRect.width - _scrollDifference, 15), indexTileSet, loadFromAssets.tileSetNames); string[] prefabNames = new string[loadFromAssets.tileSet[indexTileSet].prefabs.Length]; TileSet ts = loadFromAssets.tileSet[indexTileSet]; GUI.Label(new Rect(5, 187, 200, 200), "View: "); tileList = GUI.Toggle(new Rect(180, 186, 40, 15), tileList, "List"); if (tileList == tileIcons) { if (!tileList) { tileList = true; } tileIcons = !tileList; } tileIcons = GUI.Toggle(new Rect(233, 186, 55, 15), tileIcons, "Icons"); if (tileList == tileIcons) { if (!tileIcons) { tileIcons = true; } tileList = !tileIcons; } GUI.Label(new Rect(5, 204, 100, 15), "Tiles: "); if (tileList) { if (indexTileList > prefabNames.Length) { indexTileList = prefabNames.Length; } GetPrefabNamesInTileSet(indexTileSet, ref prefabNames); int _indexTileList = indexTileList; indexTileList = EditorGUI.Popup(new Rect(180, 204, windowRect.width - _scrollDifference, 15), indexTileList, prefabNames); if (indexTileList != _indexTileList) { isTileSelected = false; } else if (ts.prefabs.Length != 0) { _gTile = ts.prefabs[indexTileList]; isTileSelected = true; } if (EditorWindow.focusedWindow != this && EditorWindow.focusedWindow != EditorWindow.GetWindow <SceneView>()) { isTileSelected = false; } switch (e.type) { case EventType.keyDown: { if (e.keyCode == KeyCode.Escape) { isTileSelected = false; } e.Use(); } break; } } else { } #endregion maxScroll = new Vector2(270, 357); //MUDAR ISSO AQUI DEPOIS GUI.EndScrollView(); #region DESCARTADO #region Abas //currentTab = GUILayout.Toolbar(currentTab, layerTab); //Cria a toolbar com as 3 abas //switch (currentTab) //{ // case 0: #endregion // LayersOptions(ref indexLayer, editableLayerNames, 8,_scrollDifference); // break; // case 1: // GUI.Box(new Rect(0, 0, windowRect.width, 119), ""); // GUI.Label(new Rect(5, 5, 200, 200), "Main Layer Selected", EditorStyles.boldLabel); // GUI.TextField(new Rect(180, 7, 100, 15), "Main Layer"); // break; // case 2: // LayersOptions("Front", ref indexF, frontLayerNames, 21); // break; //} // if (currentTab == 1) //Se for Main Layer // TagsAndResetOptions(0); // else // TagsOptions(_scrollDifference); #region Grid Configuration /* * if (currentTab == 1) //MainLayer * GridOptions(0); * else * GridOptions(Constants.mainLayerHeightDifference); */ #endregion #region Tile Set Configuration // if (currentTab == 1) // TileSetOptions(0); // else //TileSetOptions(_scrollDifference); #endregion #endregion }