Slate provides a very basic integration with AC. Only able to run the cutscene.
We would like to access all of the available functions that Slate provides from an Action.
What would be the best way to do this? Would we make one custom action where we can chose the slate function to use? Or to make a separate action for each Slate function?
Available Slate functions: https://slate.paradoxnotion.com/documentation/?section=controlling-cutscenes
Existing Slate AC custom action:
https://slate.paradoxnotion.com/downloads/
using UnityEngine;
using System.Collections.Generic;
using Slate;
using UnityEditor;
namespace AC
{
[System.Serializable]
public class ActionSLATE : Action
{
public int constantID = 0;
public int parameterID = -1;
public Slate.Cutscene slateCutscene;
public ActionSLATE() {
isDisplayed = true;
category = ActionCategory.ThirdParty;
title = "Slate";
description = "Runs a Slate Cutscene";
willWait = true;
}
bool overrideACCamera {
get { return slateCutscene != null && slateCutscene.cameraTrack != null && slateCutscene.cameraTrack.isActive; }
}
public override void AssignValues(List<ActionParameter> parameters) {
slateCutscene = AssignFile<Slate.Cutscene>(parameters, parameterID, constantID, slateCutscene);
ACDebug.Log("slatecutscene=" + slateCutscene);
}
public override float Run() {
if ( slateCutscene == null ) {
return 0f;
}
if ( isRunning ) {
isRunning = false;
return 0;
}
isRunning = true;
if ( overrideACCamera ) {
KickStarter.mainCamera.Disable();
}
if ( !willWait ) {
slateCutscene.Play(OnFinish);
return 0f;
}
slateCutscene.Play(OnFinish);
return slateCutscene.length;
}
void OnFinish() {
isRunning = false;
if ( overrideACCamera ) {
KickStarter.mainCamera.Enable();
}
}
public override void Skip() {
if ( slateCutscene == null ) {
return;
}
slateCutscene.SkipAll();
if ( overrideACCamera ) {
KickStarter.mainCamera.Enable();
}
}
override public void ShowGUI(List<ActionParameter> parameters) {
parameterID = Action.ChooseParameterGUI("Slate Cutscene:", parameters, parameterID, ParameterType.GameObject);
if ( parameterID >= 0 ) {
constantID = 0;
slateCutscene = null;
} else {
slateCutscene = (Slate.Cutscene)EditorGUILayout.ObjectField("Slate Cutscene:", slateCutscene, typeof(Slate.Cutscene), true);
constantID = FieldToID<Slate.Cutscene>(slateCutscene, constantID);
slateCutscene = IDToField<Slate.Cutscene>(slateCutscene, constantID, false);
}
willWait = EditorGUILayout.Toggle("Wait Until Finish?", willWait);
AfterRunningOption();
}
public override void AssignConstantIDs(bool saveScriptsToo, bool fromAssetFile) {
AssignConstantID<Slate.Cutscene>(slateCutscene, constantID, parameterID);
}
public override string SetLabel() {
return slateCutscene != null ? " (" + slateCutscene.gameObject.name + ")" : "";
}
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
After a bit of research, I found the following, please correct if wrong:
It seems that the action 'Third party" category will now allow us to select various slate functions in the drop down box. We would have to create a new category "SLATE" and create separate actions for each slate function and it will be listed in the drop down box.
If this is the case, can you provide further insights regarding how we can expose to AC all of Slate's functions: https://slate.paradoxnotion.com/documentation/?section=controlling-cutscenes
It's not possible to define new Action categories - your Action(s) would still have to be in the existing "Third-party", "Custom" categories etc.
You could separate each function into a separate Actions, but it might be easier to group part/all of them into few Actions.
If it's OK for them to be grouped into one, I can write such an Action for you.
"It's not possible to define new Action categories - your Action(s) would still have to be in the existing "Third-party", "Custom" categories etc."
Can you explain in more details why this is the case.
"You could separate each function into a separate Actions, but it might be easier to group part/all of them into few Actions. If it's OK for them to be grouped into one, I can write such an Action for you."
That would be great if you can do this.
Categories are defined by AC's ActionCategory enum.
An Action that combines the above functions can be found here: https://adventure-creator.fandom.com/wiki/SLATE_integration
Wow, you are next level. Mucho Thank you.
Btw, if we add a new entry to ActionCategory enum, would this allow us to create our own category?
It would - but it would be overwritten upon updating AC.
If you must change it, it's the ActionsCategory enum in the Enums file.
Yes your right, with each AC update, we have to reapply the changes.
Wondering if there is a way for AC to use additional custom Enum files.