# Rabbit Quick Start

Rabbit Quick Start is a Unity package that simplifies and structures the process of initializing your Unity projects. It provides a flexible framework to define how your project boots up and manages scene loading.

## Profiles

At the core of Rabbit Quick Start is the concept of a **profile**. A profile is a ScriptableObject that outlines the startup behavior of your project, including which scene to load first (only available in the editor).

For example:

* A profile that skips the boot scene and directly loads the main gameplay scene.
* A profile that boots into a specific scene based on the platform (e.g., mobile vs. desktop).
* A profile that boots you into a specific scene with specific settings for testing purposes.

## Getting Started

1. Create a Quick Start Profile asset:
   * Right-click in the Project window and select `Create > Quick Start Profiles > SceneQuickStartProfile`.
   * Give it a name (e.g., `Profile A`).
   * Setup a boot scene in the profile asset.

![Creating a Quick Start Profile](https://680080951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4XX75cnVLYMprACIkZ8O%2Fuploads%2Fgit-blob-504276f8dc1b449f4af4b5971f6a0c27fb3978b5%2Fgetting_started_profile.png?alt=media)

2. Add the toolbar to your Unity Editor:
   * Right click on the toolbar (next to the play button) and select `Quick Start > Profile Selector`.

![Adding the Quick Start Toolbar](https://680080951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4XX75cnVLYMprACIkZ8O%2Fuploads%2Fgit-blob-51ef7b7bf87ad1a2b30ea31eda71d71337f736d0%2Fgetting_started_setup_toolbar.png?alt=media)

3. Select your profile from the toolbar dropdown.

![Selecting a Profile](https://680080951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4XX75cnVLYMprACIkZ8O%2Fuploads%2Fgit-blob-f871bef77a4314abc720f5754005d565b01c3c02%2Fgetting_started_toolbar.png?alt=media)

4. Press Play to see your project boot using the selected profile!

## Project Settings

Rabbit Quick Start allows you to define different profiles for different platforms via project settings.

A settings asset is created by default in `Assets/Settings/QuickstartProjectSettings.asset`. Here you can setup different profiles to run for different platforms.

{% hint style="info" %}
Make sure to at least setup a default profile, the selected profile in the editor does not work in builds!
{% endhint %}

![Project Settings](https://680080951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4XX75cnVLYMprACIkZ8O%2Fuploads%2Fgit-blob-8042ab27cdb046cb8c14b03f3a9371a5a0a0f8c4%2Fgetting_started_project_settings.png?alt=media)

## Custom Profiles

You can create custom profiles by extending the `QuickStartProfile` class. This allows you to define specific startup behaviors and scene loading logic tailored to your project's needs.

Here's a simple example of a custom profile that sets a text to a ui element.

{% code lineNumbers="true" %}

```csharp
using System;
using CrashKonijn.Quickstart;
using TMPro;
using UnityEngine;

namespace CrashKonjin.QuickStart.Examples.Scripts
{
    [CreateAssetMenu(menuName = "QuickstartProfiles/ProfileWithText")]
    public class ProfileWithText : QuickStartProfile<ExampleContext>
    {
        // A custom text to set on startup
        [SerializeField]
        private string text;

        public override void Apply(ExampleContext context)
        {
            context.TextElement.text += $"\n{text}";
        }
    }
    
    public class ExampleContext
    {
        public TextMeshProUGUI TextElement { get; set; }
    }
}

```

{% endcode %}

{% code lineNumbers="true" %}

```csharp
using System;
using CrashKonijn.QuickStart;
using UnityEngine;
using TMPro;

namespace CrashKonjin.QuickStart.Examples.Scripts
{
    // Add this behaviour to a GameObject in your scene to see it in action
    public class ContextBehaviour : MonoBehaviour
    {
        // Reference the project settings to get the selected profile
        [SerializeField]
        private QuickStartProjectSettings settings;

        // Reference to a UI text element to modify
        [SerializeField]
        private TextMeshProUGUI text;
        
        public void Start()
        {
            var context = new ExampleContext
            {
                TextElement = this.text
            };
            
            this.settings.GetProfile().Apply(context);
        }
    }
}
```

{% endcode %}

## Referencing a profile

This is how you can reference and call a profile from your code.

{% code lineNumbers="true" %}

```csharp
public class ContextBehaviour : MonoBehaviour
{
    [SerializeField]
    private QuickStartProjectSettings settings;
    
    public void Start()
    {
        // A profile without context
        this.settings.GetProfile().Apply();
        
        // A profile with context
        this.settings.GetProfile().Apply(new ExampleContext
        {
            TextElement = this.text
        };);
    }
}
```

{% endcode %}

## Samples

The package includes examples that can be imported into your project via the Package Manager. These samples demonstrate how to create and use different profiles.
