Пример #1
0
    //handles drawing components used to examine and alter tiles
    private void DrawInfoPanel()
    {
        //set up vars to change tile values if valid
        GameObject   dummyTile   = new GameObject();
        TileBehavior createdTile = dummyTile.AddComponent <TileBehavior>();

        //define area
        infoPanel = new Rect(position.width * (sidePanelSizeRatio + centerPanelSizeRatio), 0, position.width * sidePanelSizeRatio, position.height * 0.5f);
        GUILayout.BeginArea(infoPanel);
        GUILayout.Label("Info");
        //labels for which tile is currently being viewed
        GUILayout.BeginHorizontal();
        GUILayout.Label("X: " + tileXText);
        GUILayout.Label("Y: " + tileYText);
        GUILayout.EndHorizontal();
        //create fields needed to display tilebehavior
        createdTile.position.xPos = EditorGUILayout.DelayedIntField("X pos: ", tile.position.xPos);
        createdTile.position.yPos = EditorGUILayout.DelayedIntField("Y pos: ", tile.position.yPos);
        //if map exists
        if (map)
        {
            //after change in ui, check if new tile is valid
            if (!map.CheckForSameInBoard(createdTile, 0))
            {
                tile.position.xPos = createdTile.position.xPos;
                tile.position.yPos = createdTile.position.yPos;
            }
        }
        tile.value.type = (TileBehavior.TileType)EditorGUILayout.EnumPopup("Tile type", tile.value.type);
        //button to remove tile
        if (GUILayout.Button("Remove this tile", GUILayout.Height(buttonHeight)))
        {
            RemoveTileButtonLogic();
        }
        //end area
        GUILayout.EndArea();
        //once done destroy the dummy
        DestroyImmediate(dummyTile);
    }