Skip to content

Install ReUI and first steps

alerdenisov edited this page Jan 19, 2017 · 4 revisions

Start from scratch

If you're starting new project and found ReUI is useful, let me help you to prepare project.

Create Unity project

First at all, create new clean unity project as before (I hope you already have some experience with Unity).

1. Change compiler:

To make unity ready to work with Rentitas and ReUI, we should change legacy compiler. I recommend to use IncrementalCompiler

2. Add sources:

Go to next repositories and clone them somethere on your computer:

Copy (or create symlinks) to next folders inside your Assets folder: Rentitas, Rentitas.Unity, ReUI.Api, ReUI.Implementation, ReUI.Integration, Uniful, xLua

3. Create your app

First at all, ReUI is a module for Rentitas and requires rentitas application to work. Let's create folder for application in Assets (SampleApp in my case). Next we should to create simple Rentitas application what will register and execute ReUI kernel:

public class SampleApplication : Application
{
    public SampleApplication(
        IViewProvider viewProvider, 
        IContentProvider contentProvider, 
        ILuaProvider luaProvider)
    {
        RegisterKernel(new UIKernel(viewProvider, contentProvider, luaProvider));
    }
}

As you can see UIKernel requires three dependency: IViewProvider, IContentProvider, ILuaProvider. In our case we'll use simple one (from ReUI.Intergation), but you can implement them by yourself as you want.

4. Execute our app (and UIKernel as well)

Create Bootstrap class (as a simple MonoBehaviour) where will create and execute our SampleApplication:

public class Bootstrap : MonoBehaviour, IAppProvider {
    private SampleApplication _application;
    public Application Application => _application;

    private void Start ()
    {
       // create instance of rentitas application
        _application = new SampleApplication(
            new SimpleViewProvider(), 
            new ContentResourcesProvider(), 
            new XLuaProvider());
    }

    public void Update()
    {
       // execute instance of rentitas application on each update
        _application.Execute();
    }
}
It's all! ReUI is ready to use. Next: Create UI