/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); if (currentState == GameState.Menu) { menu.drawbackground(); } else if (currentState == GameState.GameOver) { gameover.Drawback(); } else { level.Draw(spriteBatch); wavemanager.Draw(spriteBatch); player.Draw(spriteBatch); toolbar.Draw(spriteBatch, player); arrowbutton.Draw(spriteBatch); spikebutton.Draw(spriteBatch); slowbutton.Draw(spriteBatch); } spriteBatch.End(); base.Draw(gameTime); }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(); base.Draw(gameTime, spriteBatch); toolbar.Draw(gameTime, spriteBatch); spriteBatch.End(); }
void DrawToolMenu() { EditorGUILayout.BeginHorizontal(); if (loadedModuleIndex >= 0) { ToggleModule(loadedModuleIndex); loadedModuleIndex = -1; } selectModule = module; EditorGUI.BeginChangeCheck(); toolbar.Draw(ref selectModule); if (EditorGUI.EndChangeCheck()) { ToggleModule(selectModule); } EditorGUILayout.EndHorizontal(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here // start spriteBatch.Begin(); // draw the level level.Draw(spriteBatch); // draw an enemy waveManager.Draw(spriteBatch); // draw a tower player.Draw(spriteBatch); // draw the toolbar toolbar.Draw(spriteBatch, player); // and then our buttons. treeButton.Draw(spriteBatch); // end spriteBatch.End(); // not sure what this is, but it was initiazlied like this so dont touch it. base.Draw(gameTime); }
/// <summary> This should be called by the IInspectorDrawer of the inspector during every OnGUI event. </summary> /// <param name="inspectorDimensions"> The position and bounds for where the inspecto should be drawn. </param> /// <param name="anyInspectorPartMouseovered"> True if any inspector part is currently mouseovered. </param> public override void OnGUI(Rect inspectorDimensions, bool anyInspectorPartMouseovered) { UnityEngine.Profiling.Profiler.BeginSample("OnGUI"); #if DEV_MODE && DEBUG_CLICK var e = Event.current; if (e.rawType == EventType.MouseDown) { Debug.Log(StringUtils.ToColorizedString(ToString() + " Event=", e, ", e.type=", e.type, ", button=", e.button, ", mousePos=", e.mousePosition, ", GUIUtility.hotControl=", GUIUtility.hotControl)); } #endif //this can happen e.g. if the preferences file gets reimported due to being altered outside of Unity if (Preferences == null) { Preferences = GetPreferences(); } #if DEV_MODE && DEBUG_MOUSEOVERED_PART if (State.drawer.VisibleMembers.Length > 0 && DrawGUI.IsUnityObjectDrag) { Debug.Log(StringUtils.ToColorizedString(ToString(), ".OnGUI with mouseoveredPart=", MouseoveredPart, ", Event=" + StringUtils.ToString(Event.current), ", ignoreAllMouseInputs=", InspectorDrawer.Manager.IgnoreAllMouseInputs, "´, ObjectPickerIsOpen=", ObjectPicker.IsOpen, ", anyInspectorPartMouseovered=", anyInspectorPartMouseovered, ", InspectorDrawer.MouseIsOver=", InspectorDrawer.MouseIsOver, ", DrawGUI.CanRequestMousePosition=", Cursor.CanRequestLocalPosition)); } #endif InspectorUtility.BeginInspector(this, ref anyInspectorPartMouseovered); Rect toolbarRect; Rect viewportRect; Rect previewAreaRect; GetDrawPositions(inspectorDimensions, out toolbarRect, out viewportRect, out previewAreaRect); // trying to fix a bug where the default inspector layout gets wacky if both it and this window are open // by making sure all values that could affect it are restored back to normal // var indentLevelWas = EditorGUI.indentLevel; #if UNITY_EDITOR var labelWidthWas = EditorGUIUtility.labelWidth; #endif var matrixWas = GUI.matrix; var currentEvent = Event.current; switch (currentEvent.type) { case EventType.Layout: State.nextUpdateCachedValues--; if (State.nextUpdateCachedValues <= 0) { UpdateCachedValuesFromFields(); } OnCursorPositionOrLayoutChanged(); break; case EventType.MouseMove: case EventType.MouseDrag: case EventType.DragUpdated: if (IgnoreViewportMouseInputs()) { #if DEV_MODE //Debug.Log("ignoring "+ currentEvent.type+"..."); #endif break; } OnCursorPositionOrLayoutChanged(); InspectorDrawer.RefreshView(); break; } bool dirty; try { dirty = DrawViewport(viewportRect); } catch (Exception e) { if (ExitGUIUtility.ShouldRethrowException(e)) { NowDrawingPart = InspectorPart.None; DrawGUI.IndentLevel = 0; #if UNITY_EDITOR EditorGUIUtility.labelWidth = labelWidthWas; #endif GUI.skin = null; GUI.matrix = matrixWas; throw; } #if DEV_MODE Debug.LogWarning(ToString() + " " + e); #endif dirty = true; } #if !POWER_INSPECTOR_LITE NowDrawingPart = InspectorPart.Toolbar; { Toolbar.Draw(toolbarRect); } #endif NowDrawingPart = InspectorPart.Other; //TO DO: Move to EndInspector if these are needed? //trying to fix a bug where the default inspector layout gets wacky if both it and this window are open //by making sure all values that could affect it are restored back to normal DrawGUI.IndentLevel = 0; #if UNITY_EDITOR EditorGUIUtility.labelWidth = labelWidthWas; #endif GUI.skin = null; GUI.matrix = matrixWas; if (dirty) { InspectorDrawer.RefreshView(); } InspectorUtility.EndInspector(this); UnityEngine.Profiling.Profiler.EndSample(); }
/// <summary> This should be called by the IInspectorDrawer of the inspector during every OnGUI event. </summary> /// <param name="inspectorDimensions"> The position and bounds for where the inspecto should be drawn. </param> /// <param name="anyInspectorPartMouseovered"> True if any inspector part is currently mouseovered. </param> public override void OnGUI(Rect inspectorDimensions, bool anyInspectorPartMouseovered) { UnityEngine.Profiling.Profiler.BeginSample("OnGUI"); #if DEV_MODE && DEBUG_CLICK var ev = Event.current; if (ev.rawType == EventType.MouseDown) { Debug.Log(StringUtils.ToColorizedString(ToString() + " Event=", ev, ", e.type=", ev.type, ", button=", ev.button, ", mousePos=", ev.mousePosition, ", GUIUtility.hotControl=", GUIUtility.hotControl)); } #endif #if DEV_MODE && PI_ASSERTATIONS if (inspectorDimensions.width <= 0f) { Debug.LogError(GetType().Name + ".OnGUI inspectorDimensions.width <= 0f: " + inspectorDimensions); } #endif //this can happen e.g. if the preferences file gets reimported due to being altered outside of Unity if (Preferences == null) { Preferences = GetPreferences(); } #if DEV_MODE && DEBUG_MOUSEOVERED_PART if (State.drawer.VisibleMembers.Length > 0 && DrawGUI.IsUnityObjectDrag) { Debug.Log(StringUtils.ToColorizedString(ToString(), ".OnGUI with mouseoveredPart=", MouseoveredPart, ", Event=" + StringUtils.ToString(Event.current), ", ignoreAllMouseInputs=", InspectorDrawer.Manager.IgnoreAllMouseInputs, "´, ObjectPickerIsOpen=", ObjectPicker.IsOpen, ", anyInspectorPartMouseovered=", anyInspectorPartMouseovered, ", InspectorDrawer.MouseIsOver=", InspectorDrawer.MouseIsOver, ", DrawGUI.CanRequestMousePosition=", Cursor.CanRequestLocalPosition)); } #endif InspectorUtility.BeginInspector(this, ref anyInspectorPartMouseovered); Rect toolbarRect; Rect viewportRect; Rect previewAreaRect; GetDrawPositions(inspectorDimensions, out toolbarRect, out viewportRect, out previewAreaRect); // trying to fix a bug where the default inspector layout gets wacky if both it and this window are open // by making sure all values that could affect it are restored back to normal // var indentLevelWas = EditorGUI.indentLevel; var labelWidthWas = EditorGUIUtility.labelWidth; var matrixWas = GUI.matrix; var currentEvent = Event.current; switch (currentEvent.type) { case EventType.Layout: State.nextUpdateCachedValues--; if (State.nextUpdateCachedValues <= 0) { UpdateCachedValuesFromFields(); } OnCursorPositionOrLayoutChanged(); break; case EventType.MouseMove: case EventType.MouseDrag: case EventType.DragUpdated: if (IgnoreViewportMouseInputs()) { #if DEV_MODE //Debug.Log("ignoring "+ currentEvent.type+"..."); #endif break; } OnCursorPositionOrLayoutChanged(); InspectorDrawer.RefreshView(); break; } bool dirty; try { dirty = DrawViewport(viewportRect); } catch (Exception e) { if (ExitGUIUtility.ShouldRethrowException(e)) { NowDrawingPart = InspectorPart.None; DrawGUI.IndentLevel = 0; EditorGUIUtility.labelWidth = labelWidthWas; GUI.skin = null; GUI.matrix = matrixWas; throw; } #if DEV_MODE Debug.LogWarning(ToString() + " " + e); #endif // Always throw ExitGUI exception if exceptions were caught to avoid GUI Layout warnings. ExitGUIUtility.ExitGUI(); return; } #if !POWER_INSPECTOR_LITE NowDrawingPart = InspectorPart.Toolbar; { Toolbar.Draw(toolbarRect); #if UNITY_2019_3_OR_NEWER Color lineColor; if (DrawGUI.IsProSkin) { lineColor = Preferences.theme.ComponentSeparatorLine; } else { lineColor = new Color32(153, 153, 153, 255); } var lineRect = toolbarRect; lineRect.height = 1f; lineRect.y = toolbarRect.height; DrawGUI.DrawLine(lineRect, lineColor); #endif } #endif NowDrawingPart = InspectorPart.Other; try { if (DrawPreviewArea) { NowDrawingPart = InspectorPart.PreviewArea; { previewDrawer.Draw(previewAreaRect); } NowDrawingPart = InspectorPart.Other; } } #if DEV_MODE catch (ArgumentException e) // GUILayout: Mismatched LayoutGroup.repaint { Debug.LogError(StringUtils.ToString(Event.current) + " " + e + "\nEvent=" + StringUtils.ToString(Event.current)); #else catch (ArgumentException) { #endif // new test to avoid GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced. NowDrawingPart = InspectorPart.None; ExitGUIUtility.ExitGUI(); } //TO DO: Move to EndInspector if these are needed? //trying to fix a bug where the default inspector layout gets wacky if both it and this window are open //by making sure all values that could affect it are restored back to normal DrawGUI.IndentLevel = 0; EditorGUIUtility.labelWidth = labelWidthWas; GUI.skin = null; GUI.matrix = matrixWas; if (dirty) { InspectorDrawer.RefreshView(); } InspectorUtility.EndInspector(this); UnityEngine.Profiling.Profiler.EndSample(); }
private void OnGUI() { toolbar.Draw(); }
private void DrawToolbar() { toolbar.Draw(); }
public void Draw(SpriteBatch spriteBatch) { Screen.render(coordinates, texture, Settings.BLOCK_SIZE, Settings.BLOCK_SIZE, false); Screen.render(new Rectangle(ScreenPosition.Right, ScreenPosition.Top, 16, 16), getInventory().getAt(getToolbar().getCurrentIndex(), 0).getType().getTexture()); toolbar.Draw(); }