Skip to content

Runtime API

All runtime types below are in PixelVfxStudio.Runtime. They contain no UnityEditor API. Core remains pure C#; the Editor asset exporter lives in a separate Editor-only assembly.

Document playback

using PixelVfxStudio.Runtime;
using UnityEngine;

public sealed class PlayEffect : MonoBehaviour
{
    public VfxPlayer player;
    public VfxDocumentAsset effect;
    private void Start()
    {
        player.LoadAsset(effect);
        player.Loop = true;
        player.Play();
    }
}

The Inspector Document Asset takes priority over Document JSON. Reload, Play, Pause, Stop and Seek(seconds) are available. SetDocument(Core.VfxDocument) and LoadJson(string) accept other inputs. Choose CachedFrames or LiveCore before loading. FrameIndex, FrameCount, PlaybackTime, IsLoaded, IsPlaying and Texture expose state.

VfxDocumentAsset.ReadDocument() returns the versioned source. Exported custom PNG inputs are stored in that asset. CreateRenderOptions() supplies their resolver for custom Core integrations. Setting a new document clears its old embedded inputs. SetEmbeddedSilhouette(fileName, pngBytes) validates and stores an input. VfxPlayer.LoadAsset automatically uses these render options in both cache and live modes.

Sheet playback

Assign the generated PNG and .sheet.json to VfxSheetPlayer, or call SetSheet(texture, metadataJson). The player creates sprites from metadata without relying on editor sprite enumeration order. Exported multiple-sprite slices are available separately for Animator and other integrations.

Both players share Play On Awake, Source/Once/Loop, Time Scale, unscaled time, PPU, sorting layer/order, flip, pixel snapping and completion/loop callbacks. Transform position is the authored origin. Core coordinates point down; Unity world Y points up. PixelCoordinates centralizes this conversion.

Core one-shot samples are [0, duration). Exported AnimationClips use one discrete key per frame and retain the final sprite for one frame, giving frameCount / fps clip length. For fractional document durations, this frame-grid clip length can differ from the source duration by less than one frame.

The Core exporter currently emits an empty events array. VfxSheetPlayer supports optional metadata markers; RuntimePlayers includes examples. EventFired(VfxSheetEvent) supplies name/frame/data; Inspector On Event(string) receives the name. Seeking is silent. See Samples for marker behavior.

Editor export API

Editor-only types are in PixelVfxStudio.AssetStore.Editor:

var result = VfxProjectExporter.Export(
    session.Document, session.Registry, "Assets/MyEffects",
    new VfxProjectExportOptions { CreateAnimation = true, PixelsPerUnit = 32 },
    session.RenderOptions);

The destination must already exist. ValidateFolder rejects external/missing/linked folders. Columns = 0 chooses the Core layout automatically. Each call creates a unique output folder, returns its asset paths and rolls back that folder if asset creation fails. Inputs/rendering are validated before writes. This API must run on Unity's main Editor thread.

There is no automatic animation controller, prefab generation, Asset Store upload, account service or Steam integration in this stage.

PixelVfxStudio.VfxProductInfo.DocumentationUrl and IssuesUrl are shared product destinations. Inspector HelpURL attributes use the documentation constant; documentation links are also provided in the package README and store description. These links do not alter runtime playback behavior.