C# Integration Guide

Runtime API

Subscribe to callbacks, trigger actions, and query player progress programmatically using clean C# scripting endpoints.

C# API Reference

Access the runtime systems through the main class: SkywardGames.AnimationMontages.AnimationMontagePlayer.

using UnityEngine;
using SkywardGames.AnimationMontages;

public sealed class PotionDrinkController : MonoBehaviour
{
    [Header("Components")]
    [SerializeField] private AnimationMontagePlayer player;
    [SerializeField] private AnimationMontage potionDrinkMontage;
    
    [Header("VFX")]
    [SerializeField] private ParticleSystem potionLiquidVFX;

    private void OnEnable()
    {
        if (player == null) return;
        
        // Subscribe to Timeline Events
        player.OnNotificationFired += HandleNotification;
        player.OnWindowOpened += HandleWindowOpen;
        player.OnWindowClosed += HandleWindowClose;
    }

    private void OnDisable()
    {
        if (player == null) return;
        
        player.OnNotificationFired -= HandleNotification;
        player.OnWindowOpened -= HandleWindowOpen;
        player.OnWindowClosed -= HandleWindowClose;
    }

    public void DrinkPotion()
    {
        if (player == null || potionDrinkMontage == null) return;

        // Initiate potion consumption
        player.Play(potionDrinkMontage);
    }

    private void HandleNotification(string notifyId)
    {
        if (notifyId == "SFX.CorkPop")
        {
            // Spawn sound popup
            PlayCorkSound();
        }
        else if (notifyId == "VFX.Liquid")
        {
            // Play drinking splash particles
            if (potionLiquidVFX != null) potionLiquidVFX.Play();
        }
    }

    private void HandleWindowOpen(string windowId)
    {
        if (windowId == "Buff.ApplyWindow")
        {
            // Activate status boost
            ApplyCharacterStatsBuff();
        }
    }

    private void HandleWindowClose(string windowId)
    {
        if (windowId == "Buff.ApplyWindow")
        {
            // Log status lock
            LockStatusChanges();
        }
    }

    private void PlayCorkSound() { /* Implementation */ }
    private void ApplyCharacterStatsBuff() { /* Implementation */ }
    private void LockStatusChanges() { /* Implementation */ }
}

Core Class Properties & Methods

Property / Method Signature / Return Type Description
Play() void Play(AnimationMontage montage) Starts execution of the specified montage.
Stop() void Stop(float blendOutDuration) Smoothly stops playback with a custom blend-out time.
Cancel() void Cancel() Instantly halts timeline, ignoring blend-out.
JumpToSection() void JumpToSection(string name) Instantly moves the playhead to a named section.
IsPlaying bool True if playback is currently active.
Progress float (0.0 to 1.0) Current normalized playhead position (0.0 to 1.0).
Speed float Read/write playback speed multiplier.