void DrawEvent(int eventIndex) { if (Event.current.type != EventType.Layout) { hoveredEventData = -1; } using (new GUILayout.HorizontalScope(SpriteColliderStyle.EventContainerStyle)) { var scd = spriteColliderData.Colliders[eventIndex]; var mode = scd.Mode; using (new GUILayout.HorizontalScope(SpriteColliderStyle.EventHeaderStyle)) { GUILayout.Label($"{mode}", new GUIStyle().WithAlignment(TextAnchor.MiddleCenter).WithWidth(128).WithHeight(SpriteColliderStyle.EventHeaderStyle.fixedHeight)); { GUIStyle style = null; switch (mode) { case SpriteColliderData.Mode.Hitbox: style = SpriteColliderStyle.HitboxEventNodeStyle; break; case SpriteColliderData.Mode.Hurtbox: style = SpriteColliderStyle.HurtboxEventNodeStyle; break; } if (GUILayout.Button((Texture2D)null, style.Copy().WithMargin(9, 9, 9, 9).WithHoverBackground(SpriteColliderStyle.EventIconHoverTexture))) { if (Event.current.button == 0) { selectedColliderData = eventIndex; slicer.SetUVRect(spriteColliderData.Colliders[selectedColliderData].Rects[selectedFrame].SpriteRect); } else if (Event.current.button == 1) { ShowEventContextMenu(eventIndex); } } } } for (int i = 0; i < frameCount; i++) { var style = SpriteColliderStyle.EventNodeStyle; var colliderData = scd.Rects[i]; if (colliderData.Active) { switch (mode) { case SpriteColliderData.Mode.Hitbox: style = SpriteColliderStyle.HitboxEventNodeStyle; break; case SpriteColliderData.Mode.Hurtbox: style = SpriteColliderStyle.HurtboxEventNodeStyle; break; } } bool clicked = false; if (GUILayout.Button((Texture2D)null, style)) { if (Event.current.button == 0) { selectedFrame = i; selectedColliderData = eventIndex; slicer.SetTexture(slicedSprites[i]); selectedFrameChanged = true; slicer.SetUVRect(colliderData.SpriteRect); } else if (Event.current.button == 1) { scd.Rects[i].Active = !scd.Rects[i].Active; } clicked = true; } var eventButtonRect = GUILayoutUtility.GetLastRect(); if (!clicked && Event.current.type != EventType.Layout) { if (eventButtonRect.Contains(Event.current.mousePosition)) { hoveredEventData = eventIndex; } } var buttonRect = RectHelpers.Inset(eventButtonRect, Vector2.one * 34); // GUI.DrawTexture(buttonRect, SpriteColliderStyle.SmallRoundedBorderTexture); if (i == selectedFrame && selectedColliderData == eventIndex) { buttonRect = RectHelpers.Inset(eventButtonRect, Vector2.one * 20); GUI.DrawTexture(buttonRect, SpriteColliderStyle.EventNodeSelectedStyle.normal.background); } // Connector Line if (colliderData.Active && i < frameCount - 1) { var next = scd.Rects[i + 1]; if (next.Active) { buttonRect = RectHelpers.Inset(eventButtonRect, Vector2.one * 20); Vector2 origin = buttonRect.center; origin.x += buttonRect.width * 0.5f + 6; lineVertTemp[0] = origin; lineVertTemp[1] = origin + Vector2.right * 52; Handles.color = Color.black; Handles.DrawAAPolyLine(3f, lineVertTemp); } } } } var lastRect = GUILayoutUtility.GetLastRect(); Vector2 lineOrigin = lastRect.center; lineOrigin.x = 183; lineVertTemp[0] = lineOrigin; lineVertTemp[1] = lineOrigin + Vector2.right * 59; Handles.color = Color.black; Handles.DrawAAPolyLine(3f, lineVertTemp); }