SGB/Unity Tutorials

Background Music & Sound Effects Volume Sliders

Author: Mad Stuntman
¶ Taken directly from the SGB Discord (with my own notes).

Open file Assets/src/engine/MapScene/CommonWindow/ConfigWindow.cs

Draw Gauge Method

Find the method DrawGauge (line 244).

private void DrawGauge(int i, Vector2 pos, Vector2 size)

and change appropriate values of drawers…

Position Y and height of slider (lines 252-253):

pos.Y += itemHeight – 24;
size.Y = 16;

Slider Background (Border)

Drawing of slider background (border) (line 254):

Graphics.DrawFillRect((int)pos.X, (int)(pos.Y), (int)size.X, (int)size.Y, 128, 128, 128, 128);

Parameters of Graphics.DrawFillRect() are X, Y, size X (width), size Y (height), R, G, B, A), where R, G, B, A are three decimal 16-bit RGB colors values (0-255) and A is 16-bit brightness value (0-255).

Slider Internal Background

Drawing of slider internal background (lines 256-260).

This piece of code just changing position X, Y and size X, Y and drawing smaller rectangle (internal background) inside slider background so slider background turns into the border.

pos.X += 2;
pos.Y += 2;
size.X -= 4;
size.Y -= 4;
Graphics.DrawFillRect((int)pos.X, (int)(pos.Y), (int)size.X, (int)size.Y, 0, 0, 0, 128);

Slider Body

Drawing of slider body (lines 262-270):

Slider body consists 3 various colors. Change the RGB values of each color bow for customization.

size.X = size.X * settings[i] / 100;
Graphics.DrawFillRect((int)pos.X, (int)(pos.Y), (int)size.X, (int)size.Y, 64, 48, 192, 255);

size.Y /= 2;
pos.Y += size.Y / 2;
Graphics.DrawFillRect((int)pos.X, (int)(pos.Y), (int)size.X, (int)size.Y, 32, 16, 96, 255);

pos.Y += size.Y / 2;
Graphics.DrawFillRect((int)pos.X, (int)(pos.Y), (int)size.X, (int)size.Y, 16, 8, 64, 255);

or if you want to draw a single (plain) color slider just use the first block and comment the other two.