-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This set of controls is used by the K2D2 Kerbal Space Program 2 mod

The repo contains all the code needed to build your own mod using the UI Controls found in K2D2
You can find an exemple of use of each the controls in this repo : https://github.com/cfloutier/test_k2ui I use it to test the UI behavior before using it in KSP 2
test K2UI controls
- : create the mod with the @munix template builder : https://github.com/SpaceWarpDev/SpaceWarp.Template
Follow the Readme.md instructions. It worked like a charm for me
- : add K2UI as a sub module in the
src/yourMod.Unity/yourMod.Unity/Assets/Runtimefolder - : the K2UI needs Newtonsoft.Json, it is included in Kerbal Main Game But should be added in your Unity Project
edit : src/test_k2ui.Unity/test_k2ui.Unity/Packages/manifest.json
and add the line in the modules definition
"com.unity.nuget.newtonsoft-json": "2.0.0"Then Open the Unity Project : src/yourMod.Unity/yourMod.Unity
Open the packageManager. Add the git package : https://github.com/JamesNK/Newtonsoft.Json.git
This repo can not yet be used as a Unity package or a dependendency Mod in SpaceDock.
Dor the moment I just add it as a sub module in my projects. But this can change if I find a better way to deal with dependencies.
You can directly use as git subModule like described upper, or fork it to adjust it to your uses. It can be a good starting point for a bigger set of tools.
And Pull Request would be fully appreciated. Thanks in advance.
All controls are fully editable in the UI Builder.
Creates a new Visual Tree Asset

please use the KerbalUI Theme
And include the K2UI.uss file in your xml tree definition.
This uss defines global variables and includes all others uss that is used by all controls.
Complex controls could have it's own uss file ex : K2Toggle.uss or K2Compas.uss
to edit those file I adds them to the UIBuilder. But only the main K2UI.uss is needed for your own UI file.
Ktool are a set of classes used by the Controls
- Settings : a set of class used to bind values with controls and save it to local disc as player preferences.
-
ColorTools : A set of tools for colors
- Convert colors from and to htlml codes. with
parseColorandformatColorHtml - Create gradients and color colections with
getRandomColorArrayandgetRainbowColorArray - use Hue Saturation Value space to and adjust colors with
FromHSV,ToHSVandchangeColorHSV
- Convert colors from and to htlml codes. with
- Extensions : A set of Function that extends standard cs primitives
- ReflexionTool : tools to call reflexion. It is used to call private and protected functions and to access properties. Useful to call 'forbidden' interanl fucntion from the main game (Ksp2 main engine)
- StrTools a set of tools used to convert to string different kind to values : like Duration, Distances and Vectors