Repository navigation
Expand file tree
/
Copy pathExampleModule.cs
More file actions
65 lines (55 loc) · 2.35 KB
/
Copy pathExampleModule.cs
File metadata and controls
65 lines (55 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using FullBrightMod.Core;
using FullBrightMod.UI;
using UnityEngine;
namespace CheaterMod_Example
{
public class ExampleModule : ModuleBase
{
public override string Name => "Example Module";
public override string Description => "在鼠标指针位置持续渲染一个可自定义颜色的实心方形区域";
public override ModuleCategory Category => _exampleCategory;
private static readonly ModuleCategory _exampleCategory = ModuleCategory.Create("Example");
private readonly int _squareSize = 100;
public override float GetSettingsHeight() => 55f;
public override void DrawSettings(float x, ref float y, float width, Event e)
{
Color color = ReadColorSetting("squareColor", new Color(0.2f, 0.6f, 1.0f, 0.7f));
GUIStyle labelStyle = new GUIStyle(GUI.skin.label)
{
alignment = TextAnchor.MiddleLeft,
fontSize = 10,
normal = { textColor = Color.white },
padding = new RectOffset(10, 0, 4, 0)
};
GUI.Label(new Rect(x, y, width, 20f), "方形颜色:", labelStyle);
y += 22f;
CustomGUI.DrawColorPicker(x, ref y, width, e, "", ref color);
WriteColorSetting("squareColor", color);
y += 28f;
}
public override void OnGUI()
{
if (!Enabled) return;
Color color = ReadColorSetting("squareColor", new Color(0.2f, 0.6f, 1.0f, 0.7f));
Vector2 mousePos = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
float half = _squareSize / 2f;
Rect squareRect = new Rect(mousePos.x - half, mousePos.y - half, _squareSize, _squareSize);
GUI.color = color;
GUI.DrawTexture(squareRect, Texture2D.whiteTexture);
GUI.color = Color.white;
}
private Color ReadColorSetting(string key, Color fallback)
{
if (CustomSettings.TryGetValue(key, out string hex))
{
if (ColorUtility.TryParseHtmlString(hex, out Color c))
return c;
}
return fallback;
}
private void WriteColorSetting(string key, Color value)
{
CustomSettings[key] = "#" + ColorUtility.ToHtmlStringRGBA(value);
}
}
}