Editing Modding Tutorials/ModSettings

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 61: Line 61:
 
         /// The (optional) GUI part to set your settings.
 
         /// The (optional) GUI part to set your settings.
 
         /// </summary>
 
         /// </summary>
         /// <param name="inRect">A Unity Rect with the size of the settings window.</param>
+
         /// <param name="inRect">A Unity Rect with the size of the settins window.</param>
 
         public override void DoSettingsWindowContents(Rect inRect)
 
         public override void DoSettingsWindowContents(Rect inRect)
 
         {
 
         {
Line 99: Line 99:
 
It's not mandatory to implement, but since the point of most settings is the provide customisation to the end user, it makes sense to make them available somehow.
 
It's not mandatory to implement, but since the point of most settings is the provide customisation to the end user, it makes sense to make them available somehow.
 
====The GUI====
 
====The GUI====
Listing_Standard is a barebones but useful class for making a GUI, and it does most of the positioning for you. Listing_Standard.Begin and Listing_Standard.End is required: every GUIGroup in Unity you start has to end. If you want more options to Listing_Standard, there's a good [https://github.com/RimWorld-CCL-Reborn/SettingsHelper/wiki SettingsHelper] available.
+
Listing_Standard is a barebones but useful class for making a GUI, and it does most of the positioning for you. Listing_Standard.Begin and Listing_Standard.End is required: every GUIGroup in Unity you start has to end. If you want more options to Listing_Standard, there's a good [https://github.com/RimWorld-CCL-Reborn/SettingsHelper/wiki| SettingsHelper] available.
  
 
The Widgets class is a powerful alternative to Listing_Standard that gives you more fine-grained control, at the cost of more effort. You'll have to set the size and position of each Rect manually. You can use [[Modding Tutorials/TweakValue|TweakValues]] to do this more easily.
 
The Widgets class is a powerful alternative to Listing_Standard that gives you more fine-grained control, at the cost of more effort. You'll have to set the size and position of each Rect manually. You can use [[Modding Tutorials/TweakValue|TweakValues]] to do this more easily.
Line 110: Line 110:
 
=Using your settings=
 
=Using your settings=
 
* One easy way to call settings is to make them all static and load their values with ExampleSettings.exampleBool. In certain cases, this is not practical.
 
* One easy way to call settings is to make them all static and load their values with ExampleSettings.exampleBool. In certain cases, this is not practical.
* If you can't (or don't want to) make your settings static, you can obtain your settings through the LoadedModManager like so:
+
* If you can't (or don't want to) make your settings static, you can obtain your settings through the LoadedModManager like so: <source>LoadedModManager.GetMod<ExampleMod>().GetSettings<ExampleSettings>().exampleBool</source>
  LoadedModManager.GetMod<ExampleMod>().GetSettings<ExampleSettings>().exampleBool
 
 
* As the above is a lot of code, you can simple add a reference to your settings and resolve it once in a constructor or otherwise.
 
* As the above is a lot of code, you can simple add a reference to your settings and resolve it once in a constructor or otherwise.
  

Please note that all contributions to RimWorld Wiki are considered to be released under the CC BY-SA 3.0 (see RimWorld Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page:

This page is a member of 1 hidden category: