// Update is called once per frame void OnGUI() { // Do autoresizing of GUI layer GUIResizer.AutoResize(); // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting GUI.Box(new Rect(0, 0, 135, 200), ""); bool prev = enableClearFogOnClick; enableClearFogOnClick = GUI.Toggle(new Rect(10, 20, 150, 30), enableClearFogOnClick, "Toggle Clear Fog"); if (enableClearFogOnClick != prev && enableClearFogOnClick) { enableClearFogCountryOnClick = false; } prev = enableClearFogCountryOnClick; enableClearFogCountryOnClick = GUI.Toggle(new Rect(10, 50, 150, 30), enableClearFogCountryOnClick, "Toggle Country Fog"); if (enableClearFogCountryOnClick != prev && enableClearFogCountryOnClick) { enableClearFogOnClick = false; } // buttons background color GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); // Add button to toggle Earth texture if (GUI.Button(new Rect(10, 90, 160, 30), " Reset Fog of War", buttonStyle)) { map.FogOfWarClear(true); } }
/// <summary> /// UI Buttons /// </summary> void OnGUI() { // Do autoresizing of GUI layer GUIResizer.AutoResize(); bool prev = enableToggleOwnership; enableToggleOwnership = GUI.Toggle(new Rect(10, 20, 200, 30), enableToggleOwnership, "Change Ownership on Click"); if (enableToggleOwnership && prev != enableToggleOwnership) { enableClickToMoveTank = false; } prev = enableClickToMoveTank; enableClickToMoveTank = GUI.Toggle(new Rect(230, 20, 200, 30), enableClickToMoveTank, "Move Tank On Click"); if (enableClickToMoveTank && prev != enableClickToMoveTank) { enableToggleOwnership = false; } }
/// <summary> /// UI Buttons /// </summary> void OnGUI() { // Do autoresizing of GUI layer GUIResizer.AutoResize(); GUI.Box(new Rect(0, 0, 160, 160), ""); // Path line controls GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.Button(new Rect(10, 50, 150, 30), " Time of Day", buttonStyle); GUI.backgroundColor = Color.white; timeOfDay = GUI.HorizontalSlider(new Rect(10, 85, 150, 35), timeOfDay, 0, 24f, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); timeOfDay += 0.01f; if (timeOfDay >= 24) { timeOfDay = 0; } map.timeOfDay = timeOfDay; }
/// <summary> /// UI Buttons /// </summary> void OnGUI() { // Do autoresizing of GUI layer GUIResizer.AutoResize(); // buttons background color GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); // Add button to toggle Earth texture if (GUI.Button(new Rect(10, 10, 160, 30), " Open Mini Map", buttonStyle)) { float left = 0.8f; float top = 0.8f; float width = 0.2f; float height = 0.2f; Vector4 normalizedScreenRect = new Vector4(left, top, width, height); WMSKMiniMap minimap = WMSKMiniMap.Show(normalizedScreenRect); minimap.duration = 2f; minimap.zoomLevel = 0.1f; } if (WMSKMiniMap.IsVisible()) { if (GUI.Button(new Rect(10, 50, 160, 30), " Random Position", buttonStyle)) { float left = Random.value; float top = Random.value; float width = 0.2f; float height = 0.2f; Vector4 normalizedScreenRect = new Vector4(left, top, width, height); WMSKMiniMap.RepositionAt(normalizedScreenRect); } if (GUI.Button(new Rect(10, 90, 160, 30), " Hide Mini Map", buttonStyle)) { WMSKMiniMap.Hide(); } } }
/// <summary> /// UI Buttons /// </summary> void OnGUI() { // Do autoresizing of GUI layer GUIResizer.AutoResize(); GUI.Box(new Rect(0, 0, 160, 160), ""); bool prev = showLinearPath; showLinearPath = GUI.Toggle(new Rect(10, 20, 150, 30), showLinearPath, "Show Linear Path"); if (showLinearPath != prev && showLinearPath) { showRoutePath = false; } prev = showRoutePath; showRoutePath = GUI.Toggle(new Rect(180, 20, 150, 30), showRoutePath, "Show Route Path"); if (showRoutePath != prev && showRoutePath) { showLinearPath = false; pathArcElevation = 0; } enableClickToMoveTank = GUI.Toggle(new Rect(350, 20, 200, 30), enableClickToMoveTank, "Enable Move Tank On Click"); enableClickToMoveTank = GUI.Toggle(new Rect(570, 20, 200, 30), enableClickToMoveTank, "Show Circle"); // Path line controls GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.Button(new Rect(10, 50, 150, 30), " Drawing Duration", buttonStyle); GUI.backgroundColor = Color.white; pathDrawingDuration = GUI.HorizontalSlider(new Rect(10, 85, 150, 35), pathDrawingDuration, 0, 3f, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.Button(new Rect(10, 120, 150, 30), " Arc Elevation", buttonStyle); GUI.backgroundColor = Color.white; pathArcElevation = GUI.HorizontalSlider(new Rect(10, 155, 150, 35), pathArcElevation, 0, 10f, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.Button(new Rect(10, 190, 150, 30), " Line Width", buttonStyle); GUI.backgroundColor = Color.white; pathLineWidth = GUI.HorizontalSlider(new Rect(10, 225, 150, 35), pathLineWidth, 0.05f, 1f, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.Button(new Rect(10, 260, 150, 30), " Dash Size", buttonStyle); GUI.backgroundColor = Color.white; pathDashInterval = GUI.HorizontalSlider(new Rect(10, 295, 150, 35), pathDashInterval, 0, 0.01f, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.Button(new Rect(10, 330, 150, 30), " Dash Speed", buttonStyle); GUI.backgroundColor = Color.white; pathDashAnimationDuration = GUI.HorizontalSlider(new Rect(10, 365, 150, 35), pathDashAnimationDuration, 0, 2f, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 50, 150, 30), " Circle Radius", buttonStyle); GUI.backgroundColor = Color.white; circleRadius = GUI.HorizontalSlider(new Rect(GUIResizer.authoredScreenWidth - 190, 85, 150, 35), circleRadius, 0, 10f, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 120, 150, 30), " Circle Ring Start", buttonStyle); GUI.backgroundColor = Color.white; circleRingStart = GUI.HorizontalSlider(new Rect(GUIResizer.authoredScreenWidth - 190, 155, 150, 35), circleRingStart, 0, 1f, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 190, 150, 30), " Circle Ring End", buttonStyle); GUI.backgroundColor = Color.white; circleRingEnd = GUI.HorizontalSlider(new Rect(GUIResizer.authoredScreenWidth - 190, 225, 150, 35), circleRingEnd, 0, 1f, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); }
// Update is called once per frame void OnGUI () { // Do autoresizing of GUI layer GUIResizer.AutoResize (); // Check whether a country or city is selected, then show a label with the entity name and its neighbours (new in V4.1!) if (map.cellHighlighted != null) { int cellIndex = map.cellHighlightedIndex; string text = "Cell index = " + cellIndex + ", row = " + map.cells[cellIndex].row + ", col = " + map.cells[cellIndex].column + ", center = " + map.cells[cellIndex].center; // shadow float x, y; x = Screen.width / 2.0f; y = Screen.height - 40; GUI.Label (new Rect (x - 1, y - 1, 0, 10), text, labelStyleShadow); GUI.Label (new Rect (x + 1, y + 2, 0, 10), text, labelStyleShadow); GUI.Label (new Rect (x + 2, y + 3, 0, 10), text, labelStyleShadow); GUI.Label (new Rect (x + 3, y + 4, 0, 10), text, labelStyleShadow); // texst face GUI.Label (new Rect (x, y, 0, 10), text, labelStyle); } // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting GUI.Box (new Rect (5, 0, 175, 180), ""); map.showGrid = GUI.Toggle (new Rect (10, 20, 170, 30), map.showGrid, "Toggle Grid"); map.enableCellHighlight = GUI.Toggle (new Rect (10, 50, 170, 30), map.enableCellHighlight, "Enable Cell Highlighting"); enableFadeOut = GUI.Toggle (new Rect (10, 80, 170, 30), enableFadeOut, "Toggle Fade Circle"); if (enableFadeOut) { enablePaint = false; enablePaintCountry = false; } enablePaint = GUI.Toggle (new Rect (10, 110, 170, 30), enablePaint, "Toggle Colorize Cell"); if (enablePaint) { enableFadeOut = false; enablePaintCountry = false; } enablePaintCountry = GUI.Toggle (new Rect (10, 140, 170, 30), enablePaintCountry, "Toggle Fade Country"); if (enablePaintCountry) { enableFadeOut = false; enablePaint = false; } // buttons background color GUI.backgroundColor = new Color (0.1f, 0.1f, 0.3f, 0.95f); // Clear painted cells if (GUI.Button (new Rect (10, 200, 160, 30), " Clear Cells", buttonStyle)) { map.HideCellSurfaces(); } // Add buttons to show the color picker and change colors for the cells if (GUI.Button (new Rect (10, 235, 160, 30), " Change Grid Color", buttonStyle)) { colorPicker.showPicker = true; } if (colorPicker.showPicker) { map.gridColor = colorPicker.setColor; } // Slider to show the new set zoom level API in V4.1 GUI.Button (new Rect (10, 270, 85, 30), " Cells", buttonStyle); GUI.backgroundColor = Color.white; int prevCellsCount = (int)cellsCount; cellsCount= (int)GUI.HorizontalSlider (new Rect (100, 285, 80, 30), cellsCount, 32, 512, sliderStyle, sliderThumbStyle); if ( (int)cellsCount != prevCellsCount) { map.gridColumns = (int)cellsCount; map.gridRows = map.gridColumns / 2; cellsCount = map.gridColumns; } GUI.backgroundColor = new Color (0.1f, 0.1f, 0.3f, 0.95f); // Slider to show the new set zoom level API in V4.1 GUI.Button (new Rect (10, 305, 85, 30), " Zoom Level", buttonStyle); float prevZoomLevel = zoomLevel; GUI.backgroundColor = Color.white; zoomLevel = GUI.HorizontalSlider (new Rect (100, 320, 80, 30), zoomLevel, 0, 1, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color (0.1f, 0.1f, 0.3f, 0.95f); if (zoomLevel != prevZoomLevel) { prevZoomLevel = zoomLevel; map.SetZoomLevel (zoomLevel); } if (Input.GetMouseButtonDown(0)) { if (enablePaint) { PaintCurrentCell(); } else if (enablePaintCountry) { PaintCurrentCountry(); } } }
void OnGUI() { if (avoidGUI) { return; } // Do autoresizing of GUI layer GUIResizer.AutoResize(); // Check whether a country or city is selected, then show a label with the entity name and its neighbours (new in V4.1!) if (map.countryHighlighted != null || map.cityHighlighted != null || map.provinceHighlighted != null) { string text; if (map.cityHighlighted != null) { if (!map.cityHighlighted.name.Equals(map.cityHighlighted.province)) // show city name + province & country name { text = "City: " + map.cityHighlighted.name + " (" + map.cityHighlighted.province + ", " + map.countries[map.cityHighlighted.countryIndex].name + ")"; } else // show city name + country name (city is a capital with same name as province) { text = "City: " + map.cityHighlighted.name + " (" + map.countries[map.cityHighlighted.countryIndex].name + ")"; } } else if (map.provinceHighlighted != null) { text = map.provinceHighlighted.name + ", " + map.countryHighlighted.name; List <Province> neighbours = map.ProvinceNeighboursOfCurrentRegion(); if (neighbours.Count > 0) { text += "\n" + EntityListToString <Province>(neighbours); } } else if (map.countryHighlighted != null) { text = map.countryHighlighted.name + " (" + map.countryHighlightedIndex.ToString() + ", " + map.countryHighlighted.continent + ")"; List <Country> neighbours = map.CountryNeighboursOfCurrentRegion(); if (neighbours.Count > 0) { text += "\n" + EntityListToString <Country>(neighbours); } } else { text = ""; } float x, y; if (minimizeState) { x = Screen.width - 130; y = Screen.height - 140; } else { x = Screen.width / 2.0f; y = Screen.height - 40; } // shadow GUI.Label(new Rect(x - 1, y - 1, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 1, y + 2, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 2, y + 3, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 3, y + 4, 0, 10), text, labelStyleShadow); // texst face GUI.Label(new Rect(x, y, 0, 10), text, labelStyle); } // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting GUI.Box(new Rect(0, 0, 150, 200), ""); map.showFrontiers = GUI.Toggle(new Rect(10, 20, 150, 30), map.showFrontiers, "Toggle Frontiers"); map.showEarth = GUI.Toggle(new Rect(10, 50, 150, 30), map.showEarth, "Toggle Earth"); //MAX! //map.showCities = GUI.Toggle (new Rect (10, 80, 150, 30), map.showCities, "Toggle Cities"); map.showCountryNames = GUI.Toggle(new Rect(10, 110, 150, 30), map.showCountryNames, "Toggle Labels"); map.enableCountryHighlight = GUI.Toggle(new Rect(10, 140, 170, 30), map.enableCountryHighlight, "Enable Highlight"); // buttons background color GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); // Viewport mode sample: Stop button if (viewportDemoStarted) { if (GUI.Button(new Rect(10, 170, 160, 30), " Stop Viewport Demo", buttonStyle)) { ViewportModeStop(); } else { ViewportModeRun(); } return; } // Add button to toggle Earth texture if (GUI.Button(new Rect(10, 170, 160, 30), " Change Earth style", buttonStyle)) { map.earthStyle = (EARTH_STYLE)(((int)map.earthStyle + 1) % 4); } // Add buttons to show the color picker and change colors for the frontiers or fill if (GUI.Button(new Rect(10, 210, 160, 30), " Change Frontiers Color", buttonStyle)) { colorPicker.showPicker = true; changingFrontiersColor = true; } if (GUI.Button(new Rect(10, 250, 160, 30), " Change Fill Color", buttonStyle)) { colorPicker.showPicker = true; changingFrontiersColor = false; } if (colorPicker.showPicker) { if (changingFrontiersColor) { map.frontiersColor = colorPicker.setColor; } else { map.fillColor = colorPicker.setColor; } } // Add a button which demonstrates the navigateTo functionality -- pass the name of a country // For a list of countries and their names, check map.Countries collection. if (GUI.Button(new Rect(10, 290, 180, 30), " Fly to Australia (Country)", buttonStyle)) { FlyToCountry("Australia"); } if (GUI.Button(new Rect(10, 325, 180, 30), " Fly to Mexico (Country)", buttonStyle)) { FlyToCountry("Mexico"); } if (GUI.Button(new Rect(10, 360, 180, 30), " Fly to New York (City)", buttonStyle)) { FlyToCity("New York"); } if (GUI.Button(new Rect(10, 395, 180, 30), " Fly to Madrid (City)", buttonStyle)) { FlyToCity("Madrid"); } // Slider to show the new set zoom level API in V4.1 GUI.Button(new Rect(10, 430, 85, 30), " Zoom Level", buttonStyle); float prevZoomLevel = zoomLevel; GUI.backgroundColor = Color.white; zoomLevel = GUI.HorizontalSlider(new Rect(100, 445, 80, 85), zoomLevel, 0, 1, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); if (zoomLevel != prevZoomLevel) { prevZoomLevel = zoomLevel; map.SetZoomLevel(zoomLevel); } // Add a button to colorize countries if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 20, 180, 30), " Colorize Europe", buttonStyle)) { for (int colorizeIndex = 0; colorizeIndex < map.countries.Length; colorizeIndex++) { if (map.countries [colorizeIndex].continent.Equals("Europe")) { Color color = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f)); map.ToggleCountrySurface(map.countries [colorizeIndex].name, true, color); } } } // Colorize random country and fly to it if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 60, 180, 30), " Colorize Random", buttonStyle)) { int countryIndex = Random.Range(0, map.countries.Length); Color color = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f)); map.ToggleCountrySurface(countryIndex, true, color); map.BlinkCountry(countryIndex, Color.green, Color.black, 0.8f, 0.2f); } // Button to clear colorized countries if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 100, 180, 30), " Reset countries", buttonStyle)) { map.HideCountrySurfaces(); } // Tickers sample if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 140, 180, 30), " Tickers Sample", buttonStyle)) { TickerSample(); } // Decorator sample if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 180, 180, 30), " Texture Sample", buttonStyle)) { TextureSample(); } // Moving the Earth sample if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 220, 180, 30), " Toggle Minimize", buttonStyle)) { ToggleMinimize(); } // Moving the Earth sample if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 260, 180, 30), " Viewport Demo", buttonStyle)) { ViewportModeStart(); } // Add marker sample if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 300, 180, 30), " Add Marker", buttonStyle)) { AddMarkerOnRandomCity(); } if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 340, 180, 30), " Add Trajectories", buttonStyle)) { AddTrajectories(); } if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 380, 180, 30), " Show States Names", buttonStyle)) { ShowStatesNames(); } }
/// <summary> /// UI Buttons /// </summary> void OnGUI() { // Do autoresizing of GUI layer GUIResizer.AutoResize(); GUI.Box(new Rect(0, 0, 160, 160), ""); bool prev = enableAddTowerOnClick; enableAddTowerOnClick = GUI.Toggle(new Rect(10, 20, 150, 30), enableAddTowerOnClick, "Enable Tower On Click"); if (enableAddTowerOnClick && prev != enableAddTowerOnClick) { enableClickToMoveTank = false; enableClickToMoveShip = false; } prev = enableClickToMoveTank; enableClickToMoveTank = GUI.Toggle(new Rect(180, 20, 200, 30), enableClickToMoveTank, "Enable Move Tank On Click"); if (enableClickToMoveTank && prev != enableClickToMoveTank) { enableAddTowerOnClick = false; enableClickToMoveShip = false; } prev = enableClickToMoveShip; enableClickToMoveShip = GUI.Toggle(new Rect(390, 20, 200, 30), enableClickToMoveShip, "Enable Move Ship On Click"); if (enableClickToMoveShip && prev != enableClickToMoveShip) { enableAddTowerOnClick = false; enableClickToMoveTank = false; } // buttons background color GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); if (GUI.Button(new Rect(10, 50, 150, 30), " Add Random Tower", buttonStyle)) { AddRandomTower(); } if (GUI.Button(new Rect(10, 90, 150, 30), " Add Random Sprite", buttonStyle)) { AddRandomSprite(); } if (GUI.Button(new Rect(10, 130, 150, 30), " Drop Tank on Paris", buttonStyle)) { DropTankOnCity(); } if (GUI.Button(new Rect(10, 170, 150, 30), " Move Tank & Follow", buttonStyle)) { MoveTankAndFollow(); } if (GUI.Button(new Rect(10, 210, 150, 30), " Launch Ship", buttonStyle)) { LaunchShip(); } if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 50, 180, 30), " Mass Create", buttonStyle)) { MassCreate(); } if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 90, 180, 30), " Find Coast", buttonStyle)) { FindCoast(); } if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 130, 180, 30), " Add Sphere", buttonStyle)) { AddSphere(); } }
// Update is called once per frame void OnGUI() { // Do autoresizing of GUI layer GUIResizer.AutoResize(); // Check whether a country or city is selected, then show a label if (map.countryHighlighted != null || map.cityHighlighted != null) { // Vector3 mousePos = Input.mousePosition; string text; if (map.cityHighlighted != null) { text = "City: " + map.cityHighlighted.name + " (" + map.cityHighlighted.country + ")"; } else if (map.countryHighlighted != null) { text = map.countryHighlighted.name + " (" + map.countryHighlighted.continent + ")"; } else { text = ""; } float x, y; if (minimizeState) { x = Screen.width - 130; y = Screen.height - 140; } else { x = Screen.width / 2.0f; y = Screen.height - 40; } GUI.Label(new Rect(x - 1, y - 1, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 1, y + 2, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 2, y + 3, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 3, y + 4, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x, y, 0, 10), text, labelStyle); } /* * // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting * GUI.Box (new Rect(0,0,150,200), ""); * map.showFrontiers = GUI.Toggle (new Rect (10, 20, 150, 30), map.showFrontiers, "Toggle Frontiers"); * map.showEarth = GUI.Toggle (new Rect (10, 50, 150, 30), map.showEarth, "Toggle Earth"); * map.showCities = GUI.Toggle (new Rect (10, 80, 150, 30), map.showCities, "Toggle Cities"); * map.showCountryNames = GUI.Toggle (new Rect (10, 110, 150, 30), map.showCountryNames, "Toggle Labels"); * map.enableCountryHighlight = GUI.Toggle (new Rect (10, 140, 170, 30), map.enableCountryHighlight, "Enable Highlight"); */ GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); /* * // Add buttons to show the color picker and change colors for the frontiers or fill * if (GUI.Button (new Rect (10, 210, 160, 30), " Change Frontiers Color", buttonStyle)) { * colorPicker.showPicker = true; * changingFrontiersColor = true; * } * if (GUI.Button (new Rect (10, 250, 160, 30), " Change Fill Color", buttonStyle)) { * colorPicker.showPicker = true; * changingFrontiersColor = false; * } * if (colorPicker.showPicker) { * if (changingFrontiersColor) { * map.frontiersColor = colorPicker.setColor; * } else { * map.fillColor = colorPicker.setColor; * } * } * * // Add a button which demonstrates the navigateTo functionality -- pass the name of a country * // For a list of countries and their names, check map.Countries collection. * if (GUI.Button (new Rect (10, 290, 180, 30), " Fly to Australia (Country)", buttonStyle)) { * FlyToCountry ("Australia"); * } * if (GUI.Button (new Rect (10, 325, 180, 30), " Fly to Mexico (Country)", buttonStyle)) { * FlyToCountry ("Mexico"); * } * if (GUI.Button (new Rect (10, 360, 180, 30), " Fly to San Francisco (City)", buttonStyle)) { * FlyToCity ("San Francisco"); * } * if (GUI.Button (new Rect (10, 395, 180, 30), " Fly to Madrid (City)", buttonStyle)) { * FlyToCity ("Madrid"); * } * * // Add a button to colorize countries * if (GUI.Button (new Rect (GUIResizer.authoredScreenWidth - 190, 20, 180, 30), " Colorize Europe", buttonStyle)) { * for (int colorizeIndex =0; colorizeIndex < map.countries.Length; colorizeIndex++) { * if (map.countries [colorizeIndex].continent.Equals ("Europe")) { * Color color = new Color (Random.Range (0.0f, 1.0f), Random.Range (0.0f, 1.0f), Random.Range (0.0f, 1.0f)); * map.ToggleCountrySurface (map.countries [colorizeIndex].name, true, color); * } * } * } * * // Colorize random country and fly to it * if (GUI.Button (new Rect (GUIResizer.authoredScreenWidth - 190, 60, 180, 30), " Colorize Random", buttonStyle)) { * int countryIndex = Random.Range (0, map.countries.Length); * Color color = new Color (Random.Range (0.0f, 1.0f), Random.Range (0.0f, 1.0f), Random.Range (0.0f, 1.0f)); * map.ToggleCountrySurface (countryIndex, true, color); * map.BlinkCountry(countryIndex, Color.green, Color.black, 0.8f, 0.2f); * } * * // Button to clear colorized countries * if (GUI.Button (new Rect (GUIResizer.authoredScreenWidth - 190, 100, 180, 30), " Reset countries", buttonStyle)) { * map.HideCountrySurfaces (); * } * * // Moving the Earth sample * if (GUI.Button (new Rect (GUIResizer.authoredScreenWidth - 190, 220, 180, 30), " Toggle Minimize", buttonStyle)) { * ToggleMinimize (); * }*/ }
// Update is called once per frame void OnGUI() { // Do autoresizing of GUI layer GUIResizer.AutoResize(); // Check whether a country or city is selected, then show a label with the entity name and its neighbours (new in V4.1!) if (map.countryHighlighted != null || map.cityHighlighted != null || map.provinceHighlighted != null) { string text; if (map.cityHighlighted != null) { if (!map.cityHighlighted.name.Equals(map.cityHighlighted.province)) // show city name + province & country name { text = "City: " + map.cityHighlighted.name + " (" + map.cityHighlighted.province + ", " + map.countries [map.cityHighlighted.countryIndex].name + ")"; } else // show city name + country name (city is a capital with same name as province) { text = "City: " + map.cityHighlighted.name + " (" + map.countries [map.cityHighlighted.countryIndex].name + ")"; } } else if (map.provinceHighlighted != null) { text = map.provinceHighlighted.name + ", " + map.countryHighlighted.name; List <Province> neighbours = map.ProvinceNeighboursOfCurrentRegion(); if (neighbours.Count > 0) { text += "\n" + EntityListToString <Province> (neighbours); } } else { text = ""; } float x, y; x = Screen.width / 2.0f; y = Screen.height - 40; // shadow GUI.Label(new Rect(x - 1, y - 1, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 1, y + 2, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 2, y + 3, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 3, y + 4, 0, 10), text, labelStyleShadow); // texst face GUI.Label(new Rect(x, y, 0, 10), text, labelStyle); } // buttons background color GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); // Add a button to colorize countries if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 20, 180, 30), " (F) Colorize France", buttonStyle)) { ColorizeFrance(); } if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 60, 180, 30), " (W) Colorize World", buttonStyle)) { ColorizeProvinces(true); } if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 100, 180, 30), " (R) Reset Provinces", buttonStyle)) { ColorizeProvinces(false); } }
// Update is called once per frame void OnGUI() { // Animates the camera field of view (just a cool effect at the begining) if (animatingField) { if (Camera.main.fieldOfView > 60) { Camera.main.fieldOfView -= (181.0f - Camera.main.fieldOfView) / (220.0f - Camera.main.fieldOfView); } else { Camera.main.fieldOfView = 60; animatingField = false; } } // Do autoresizing of GUI layer GUIResizer.AutoResize(); // Check whether a country or city is selected, then show a label if (map.mouseIsOver) { string text; Vector3 mousePos = Input.mousePosition; float x, y; if (map.countryHighlighted != null || map.cityHighlighted != null || map.provinceHighlighted != null) { if (map.cityHighlighted != null) { text = "City: " + map.cityHighlighted.name + " (" + map.countries [map.cityHighlighted.countryIndex].name + ")"; } else if (map.provinceHighlighted != null) { text = map.provinceHighlighted.name + ", " + map.countryHighlighted.name; List <Province> neighbours = map.ProvinceNeighboursOfCurrentRegion(); if (neighbours.Count > 0) { text += "\n" + EntityListToString <Province> (neighbours); } } else if (map.countryHighlighted != null) { text = map.countryHighlighted.name + " (" + map.countryHighlighted.continent + ")"; List <Country> neighbours = map.CountryNeighboursOfCurrentRegion(); if (neighbours.Count > 0) { text += "\n" + EntityListToString <Country> (neighbours); } } else { text = ""; } x = GUIResizer.authoredScreenWidth * (mousePos.x / Screen.width); y = GUIResizer.authoredScreenHeight - GUIResizer.authoredScreenHeight * (mousePos.y / Screen.height) - 20 * (Input.touchSupported ? 3 : 1); // slightly up for touch devices GUI.Label(new Rect(x - 1, y - 1, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 1, y + 2, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 2, y + 3, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 3, y + 4, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x, y, 0, 10), text, labelStyle); } text = map.calc.prettyCurrentLatLon; x = GUIResizer.authoredScreenWidth / 2.0f; y = GUIResizer.authoredScreenHeight - 20; GUI.Label(new Rect(x, y, 0, 10), text, labelStyle); } float prevZoomLevel = zoomLevel; if (showOptionsGUI) { // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting map.showFrontiers = GUI.Toggle(new Rect(10, 20, 150, 30), map.showFrontiers, "Toggle Frontiers"); map.showEarth = GUI.Toggle(new Rect(10, 50, 150, 30), map.showEarth, "Toggle Earth"); map.showCities = GUI.Toggle(new Rect(10, 80, 150, 30), map.showCities, "Toggle Cities"); map.showCountryNames = GUI.Toggle(new Rect(10, 110, 150, 30), map.showCountryNames, "Toggle Labels"); map.showProvinces = GUI.Toggle(new Rect(10, 140, 170, 30), map.showProvinces, "Toggle Provinces"); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.5f); // Add button to toggle Earth texture if (GUI.Button(new Rect(10, 170, 160, 30), " Change Earth style", buttonStyle)) { map.earthStyle = (EARTH_STYLE)(((int)map.earthStyle + 1) % 8); } // Add buttons to show the color picker and change colors for the frontiers or fill if (GUI.Button(new Rect(10, 210, 160, 30), " Change Frontiers Color", buttonStyle)) { colorPicker.showPicker = true; changingFrontiersColor = true; } if (GUI.Button(new Rect(10, 250, 160, 30), " Change Fill Color", buttonStyle)) { colorPicker.showPicker = true; changingFrontiersColor = false; } if (colorPicker.showPicker) { if (changingFrontiersColor) { map.frontiersColor = colorPicker.setColor; } else { map.fillColor = colorPicker.setColor; } } // Add a button which demonstrates the navigateTo functionality -- pass the name of a country // For a list of countries and their names, check map.Countries collection. if (GUI.Button(new Rect(10, 290, 180, 30), " Fly to Australia (Country)", buttonStyle)) { FlyToCountry("Australia"); } if (GUI.Button(new Rect(10, 325, 180, 30), " Fly to Mexico (Country)", buttonStyle)) { FlyToCountry("Mexico"); } if (GUI.Button(new Rect(10, 360, 180, 30), " Fly to New York (City)", buttonStyle)) { FlyToCity("New York"); } if (GUI.Button(new Rect(10, 395, 180, 30), " Fly to Oakland (City)", buttonStyle)) { FlyToCity("Oakland"); } // Slider to show the new set zoom level API in V4.1 GUI.Button(new Rect(10, 430, 85, 30), " Zoom Level", buttonStyle); GUI.backgroundColor = Color.white; zoomLevel = GUI.HorizontalSlider(new Rect(100, 445, 80, 85), zoomLevel, 0, 1, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); if (zoomLevel != prevZoomLevel) { prevZoomLevel = zoomLevel; map.SetZoomLevel(zoomLevel); } // Add a button to colorize countries if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 20, 180, 30), " Colorize Europe", buttonStyle)) { map.FlyToCity("Brussels"); for (int colorizeIndex = 0; colorizeIndex < map.countries.Length; colorizeIndex++) { if (map.countries [colorizeIndex].continent.Equals("Europe")) { Color color = new Color(UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f)); map.ToggleCountrySurface(map.countries [colorizeIndex].name, true, color); } } } // Colorize random country and fly to it if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 60, 180, 30), " Colorize Random", buttonStyle)) { map.FlyToCity("Brussels"); int countryIndex = UnityEngine.Random.Range(0, map.countries.Length); Color color = new Color(UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f)); map.ToggleCountrySurface(countryIndex, true, color); map.FlyToCountry(countryIndex); } // Button to clear colorized countries if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 100, 180, 30), " Reset countries", buttonStyle)) { map.HideCountrySurfaces(); } // Tickers sample if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 140, 180, 30), " Tickers Sample", buttonStyle)) { TickerSample(); } // Decorator sample if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 180, 180, 30), " Texture Sample", buttonStyle)) { TextureSample(); } // Moving the Earth sample if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 220, 180, 30), " Toggle Minimize", buttonStyle)) { ToggleMinimize(); } // Add marker sample (gameobject) if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 260, 180, 30), " Add Marker (Object)", buttonStyle)) { AddMarkerGameObjectOnRandomCity(); } // Add marker sample (gameobject) if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 300, 180, 30), " Add Marker (Circle)", buttonStyle)) { AddMarkerCircleOnRandomPosition(); } if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 340, 180, 30), " Add Trajectories", buttonStyle)) { AddTrajectories(); } if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 380, 180, 30), " Locate Mount Point", buttonStyle)) { LocateMountPoint(); } } zoomLevel = map.GetZoomLevel(); if (zoomLevel != prevZoomLevel) { prevZoomLevel = zoomLevel; //map.SetZoomLevel (zoomLevel); if (zoomLevel < 0.1f) { range = ZoomRange.Close; map.showCountryNames = false; map.showProvinces = true; map.showFrontiers = true; map.showInlandFrontiers = false; map.cityIconSize = 0.1f; map.showCursor = false; map.autoRotationSpeed = 0f; map.showFrontiers = false; } else if (zoomLevel < 0.8f) { range = ZoomRange.Middle; map.showCountryNames = true; map.showProvinces = false; map.showFrontiers = false; map.showInlandFrontiers = false; map.cityIconSize = 0.15f; map.showLatitudeLines = true; map.showCursor = true; map.autoRotationSpeed = 0f; } else { range = ZoomRange.Far; map.showCountryNames = false; map.showProvinces = false; map.showFrontiers = false; map.showInlandFrontiers = false; map.showLatitudeLines = false; map.showLongitudeLines = false; map.showCursor = false; map.cityIconSize = 0.2f; map.autoRotationSpeed = 0.05f; } } // end if zoom level != previousZoomLevel }