Unity package for UI handling or whatever really
Make UI screens, open them and close. You can even... maybe later I will write this down not now for sure
- none
To install the package, simply copy and paste the following Git URL into the Package Manager in Unity:
https://github.com/xk0fe/k.ui.git
This will add the package to your project, allowing you to easily access and use the k.ui package in your Unity scenes.
- Create UI config SO -> Right click -> k -> UI -> UiConfig
- Create prefab of a Canvas that you will use for your UI. Moving EventSystem inside of it might be a good idea
- Initialize UI system in code
public class Example : MonoBehaviour
{
[SerializeField] private UiConfig _config;
private void Awake()
{
Ui.Instance.Initialize(_config, new ViewFactory());
}
}
- Create script derived from ViewBase
public class ExampleView : ViewBase
{
}
- Attach script to your UI window prefab
- Reference prefab in UiConfig
Ui.Open<ExampleView>();
Ui.Close<ExampleView>();
If you are too lazy to drag and drop your views into UiConfig you can use Editor window that will do this work for you.
- Navigate to top bar menu k -> UI -> UiAutoResolver
- Reference target UiConfig
- Press Resolve
It will add all the views that exist in the project. Even duplicates which might lead to unwated results. Do not create duplicates of the same type derived from ViewBase. Maybe later I will make it so it would at least spit out an error in case of duplicate but for now ....
You can find samples in the Samples folder. Once the package is installed, the samples are ready to use. Simply navigate to the Samples section in the Package Manager to explore and import any sample you’d like to try in your project.
This sample shows how to initialize UI system and open a view.
This one just helps me write less code. Requires k.Services package to work.
This example shows how to use ScriptableObjects to create and manage animations in Unity. It uses a central data storage system, making it easy to trigger animations from the code across different views.