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:
- Open your Unity project.
- Navigate to Edit > Project Setings.
- Select 'Player' from the left hand list.
- If Spine is needed you can also add
USE_SPINE
now.
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.
- Make sure that in your installer you are binding the service and UI wrapper in
BindServices(IContainer)
, if you are using theSimpleInstaller
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();
...
}
- You will also need to make use of
LoadStorySequenceDataLoadPhase
to load the needed data. Make sure that your LoadPhase has been bound to yourIContainer
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 thedataRetrieveFunc
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
- In your main gameplay scene add the StorySequenceUI prefab from
com.idlekit/idlekit-tools/Runtime/StorySequenceIntegration/Prefabs/StorySequenceUI.prefab
- 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.
- Find your Startup component in this scene and populate Story Sequence Ui Wrapper field with the
StorySequenceUiWrapper
component.
- Still on your Startup component, Add your
StorySequenceDatabase
to the Story Sequence Database list.