public void OnSceneGUI() { if (!MyAutoTileMap.IsInitialized) { return; } GUIStyle style = new GUIStyle(); style.normal.textColor = Color.white; Handles.Label(HandleUtility.GUIPointToWorldRay(Vector3.zero).origin, " Brush Pos: " + MyAutoTileMap.BrushGizmo.BrushTilePos, style); Handles.Label(HandleUtility.GUIPointToWorldRay(new Vector3(0f, 16f)).origin, " Select Tile Idx: " + m_tilesetComponent.SelectedTileIdx, style); Rect rAutoTileMap = new Rect(MyAutoTileMap.transform.position.x, MyAutoTileMap.transform.position.y, MyAutoTileMap.MapTileWidth * MyAutoTileMap.Tileset.TileWorldWidth, -MyAutoTileMap.MapTileHeight * MyAutoTileMap.Tileset.TileWorldHeight); UtilsGuiDrawing.DrawRectWithOutline(rAutoTileMap, new Color(0f, 0f, 0f, 0f), new Color(1f, 1f, 1f, 1f)); if (m_showCollisions) { DrawCollisions(); } if (s_isEditModeOn) { int controlID = GUIUtility.GetControlID(FocusType.Passive); HandleUtility.AddDefaultControl(controlID); EventType currentEventType = Event.current.GetTypeForControl(controlID); bool skip = false; int saveControl = GUIUtility.hotControl; if (currentEventType == EventType.Layout) { skip = true; } else if (currentEventType == EventType.ScrollWheel) { skip = true; } if (!skip) { EditorGUIUtility.AddCursorRect(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), MouseCursor.Arrow); GUIUtility.hotControl = controlID; m_tilesetComponent.OnSceneGUI(); if (currentEventType == EventType.MouseDrag && Event.current.button < 2) // 2 is for central mouse button { // avoid dragging the map Event.current.Use(); } } GUIUtility.hotControl = saveControl; if (GUI.changed) { EditorUtility.SetDirty(target); } } }
public void OnSceneGUI() { if (!MyAutoTileMap.IsInitialized) { return; } DoToolBar(); Rect rAutoTileMap = new Rect(MyAutoTileMap.transform.position.x, MyAutoTileMap.transform.position.y, MyAutoTileMap.MapTileWidth * MyAutoTileMap.Tileset.TileWorldWidth, -MyAutoTileMap.MapTileHeight * MyAutoTileMap.Tileset.TileWorldHeight); UtilsGuiDrawing.DrawRectWithOutline(rAutoTileMap, new Color(0f, 0f, 0f, 0f), new Color(1f, 1f, 1f, 1f)); if (m_showCollisions) { DrawCollisions(); } if (s_isEditModeOn) { int controlID = GUIUtility.GetControlID(FocusType.Passive); HandleUtility.AddDefaultControl(controlID); EventType currentEventType = Event.current.GetTypeForControl(controlID); bool skip = false; int saveControl = GUIUtility.hotControl; if (currentEventType == EventType.Layout) { skip = true; } else if (currentEventType == EventType.ScrollWheel) { skip = true; } if (!skip) { EditorGUIUtility.AddCursorRect(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), MouseCursor.Arrow); GUIUtility.hotControl = controlID; if (Event.current.type == EventType.MouseUp && Event.current.button == 1) { s_brushMode = eBrushMode.Paint; } m_tilesetComponent.OnSceneGUI(); if (currentEventType == EventType.MouseDrag && Event.current.button < 2) // 2 is for central mouse button { // avoid dragging the map Event.current.Use(); } } GUIUtility.hotControl = saveControl; if (GUI.changed) { EditorUtility.SetDirty(target); } } }