Skip to content

Story Sequence Tool Setup

Overview

In this guide we will cover how to install and configure the story sequence tool.

Note

This guide is not meant to be exhaustive documentation of the tool and is only meant to cover the basics of setup.

Project Settings

The Story Sequence tool is included in the IdleKit framework. You may add IdleKit's modified Spine if you intend to use Spine actors withing your narrative:

  1. Open your Unity project.
  2. Navigate to Edit > Project Setings.
  3. Select 'Player' from the left hand list.
  4. If Spine is needed you can also add USE_SPINE now.

project_settings

Code Requirements

To use the Story Sequence Tool you will need to load story sequence data in an ILoadPhase and make sure the StorySequenceService and StorySequenceUiWrapper have been bound to your container.

  1. Make sure that in your installer you are binding the service and UI wrapper in BindServices(IContainer), if you are using the SimpleInstaller this will be done for you. If you are writing your own you can use the below sample code to guide you.
public override void BindServices(IContainer container)(IContainer container)
{
    ...

    container.Bind<StorySequenceUiWrapper>().ToInstance(StorySequenceStartup.StorySequenceUiWrapper).AsSingleton().Conclude();
    container.Bind<IStorySequenceService>().To<StorySequenceService>().AsSingleton().Conclude();
    ...
}
  1. You will also need to make use of LoadStorySequenceDataLoadPhase to load the needed data. Make sure that your LoadPhase has been bound to your IContainer and that it is being initialized with the data needed. We recommend you only load story sequence data required for the stage you are currently in, which you can do using the dataRetrieveFunc argument when initializing the load phase.

In your implementation of IKMonoInstaller, bind the load phase.:

public override void BindLoadPhases(IContainer container)
{
    ...
    container.Bind<LoadStorySequenceDataLoadPhase>().AsSingleton().Conclude();
    ...
}

Next, in your implementation of Startup queue up the load phase and initialize with a function or lambda expression. Use the below sample code or see SimpleStartup for a fully implemented example.

Loader.Enqueue(SequenceFlow.InSequence, Context.Container.Resolve<LoadStorySequenceDataLoadPhase>()
    .Initialize(
        stageId =>
        {
            foreach (StorySequenceDatabaseAssetReference dbReference in _storySequenceDatabases)
            {
                if (dbReference.Asset.StorySequenceActivatorCollection.Data.AssociatedStageId == stageId)
                {
                    return dbReference.Asset.Data;
                }
            }

            return Array.Empty<IData>();
        }));

Scene Setup

  1. In your main gameplay scene add the StorySequenceUI prefab from com.idlekit/idlekit-tools/Runtime/StorySequenceIntegration/Prefabs/StorySequenceUI.prefab

add_prefab

  1. On the new game object, populate the Main Ui field in the inspector with a reference to your games main canvas. The Story Sequence Tool will disable this game object while a story sequence is playing.

add_main_ui

  1. Find your Startup component in this scene and populate Story Sequence Ui Wrapper field with the StorySequenceUiWrapper component.

add_ui_wrapper

  1. Still on your Startup component, Add your StorySequenceDatabase to the Story Sequence Database list.

add_sst_databases