全站通知:
查看“Mod Options Panel”的源代码
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您可以查看和复制此页面的源代码。
x
1
{{页面名|模组设置面板}}{{面包屑}}{{施工中|需要翻译}}
2
It is possible to add options in the Options panel for use in your own mods. The options panel should be used for custom settings for your mod. To enable your mod to be displayed in the Options panel, you need to implement the method <code>OnSettingsUI()</code> in your <code>IUserMod</code> class already describing your mod. (See below)
3
<pre>
4
public class MyMod : IUserMod {
5
public string Name { get { return "MyMod"; } }
6
public string Description { get { return "My very own mod"; } }
7
8
public void OnSettingsUI(UIHelperBase helper) {
9
// Render UI elements using the UIHelperBase (see below)
10
}
11
}
12
</pre>
13
14
== API Reference ==
15
<pre>
16
UIHelperBase AddGroup(string text);
17
object AddButton(string text, OnButtonClicked eventCallback);
18
object AddSpace(int height);
19
object AddCheckbox(string text, bool defaultValue, OnCheckChanged eventCallback);
20
object AddSlider(string text, float min, float max, float step, float defaultValue, OnValueChanged eventCallback);
21
object AddDropdown(string text, string[] options, int defaultSelection, OnDropdownSelectionChanged eventCallback);
22
object AddTextfield(string text, string defaultContent, OnTextChanged eventChangedCallback, OnTextSubmitted eventSubmittedCallback = null);
23
</pre>
24
25
== Example ==
26
<pre>
27
using ICities;
28
using UnityEngine;
29
30
public class MyMod : IUserMod {
31
public string Name { get { return "MyMod"; } }
32
public string Description { get { return "My very own mod"; } }
33
34
public void OnSettingsUI(UIHelperBase helper) {
35
UIHelperBase group = helper.AddGroup("My Own Group");
36
group.AddCheckbox("My Checkbox", false, (isChecked) => Debug.Log(isChecked));
37
group.AddSlider("My Slider", 0, 1, 0.01f, 0.5f, (value) => Debug.Log(value));
38
group.AddDropdown("My Dropdown", new string[] { "First Entry", "Second Entry", "Third Entry" }, -1, (index) => Debug.Log(index));
39
group.AddSpace(250);
40
group.AddButton("My Button", () => { Debug.Log("Button clicked!"); });
41
group.AddTextfield("My Textfield", "Default value", (value) => Debug.Log("text changed: " + value), (value) => Debug.Log("text submitted: " + value));
42
}
43
}
44
</pre>
45
46
== See also ==
47
*[[Modding]]
48
49
{{说明|PWIKI=Mod Options Panel|版本=长期}}
50
返回至“Mod Options Panel”。
刷
历
编
110阅读
2023-11-30更新
最新编辑:Lu_23333
阅读:110
更新日期:2023-11-30
最新编辑:Lu_23333