This project demonstrates Arcweave integration with Unity, allowing you to import Arcweave projects both during development and at runtime.
You can preview the example project directly in your browser https://arcweave.itch.io/arcweave-unity-example
- Import Arcweave projects from web (API key + project hash) or local JSON
- Preloaded project support included in builds
- Conditional dialogue branching driven by Arcweave variables
- Arcweave component-based dialogue start/end detection
- Variable-to-gameplay binding (health bars, object activation, UI colors)
- Scene control (lighting, particles) driven by Arcweave attributes
- Sword swing ability unlocked at a specific narrative beat
- Character portraits loaded from Arcweave components
- Runtime narrative update without rebuilding (local JSON or web API)
- Clone this repository
- Open the project in Unity Hub (Unity 6 or Unity 2022 LTS)
- The Arcweave Unity plugin is already included -- no extra setup needed
- Press Play to test the demo scene
To learn more about the plugin: https://github.com/Arcweave/arcweave-unity-plugin
- Export your Arcweave project in Unity format
- Place the JSON file in
Assets/Arcweave/project.json - Place all related images in
Assets/Resources - Alternatively, use the web importer at runtime (see below)
- Select or create an
ArcweaveProjectAssetinAssets/Arcweave/- To create a new one: right-click in Assets > Create > Arcweave > Project Asset
- In the Inspector, choose your import method:
- From JSON: assign the exported
.jsonfile - From Web: enter your API key and project hash
- From JSON: assign the exported
- Click Generate Project
- After import, the Inspector shows variables (useful for debugging). Click Open Project Viewer to browse boards, elements, and connections.
Remember to connect your Arcweave Project Asset to the ArcweaveImporter and ArcweavePlayer GameObjects.
- Arcweave project: create boards (one per NPC), add variables, write conditional branches, attach components to elements, export
- Unity -- import: assign JSON to
ArcweaveProjectAsset, click Generate Project - Unity -- NPC: add
DialogueTriggerwith the board name matching the Arcweave board - Unity -- GameManager: set
Dialogue Start/End Component Nameif using component-based detection - Unity -- portraits: place images in
Assets/Resources/with filenames matching Arcweave - Unity -- variable binding: use
ArcweaveObjectActivationfor object activation andArcweaveHealthUIfor health/slider - Build:
File > Build Settings > Build. Thearcweave/folder is created automatically
Images are searched in this order:
- Unity's
Resourcesfolder [Build Folder]/arcweave/images/
- Launch the application
- Press Esc to open the menu
- Enter your API key and project hash
- Click Import Web
- Place your JSON in
[Build Folder]/arcweave/project.json - Place images in
[Build Folder]/arcweave/images/ - Press Esc > click Import Local
- JSON not loading: verify the file is exported from Arcweave in Unity format
- Images missing: filenames must match those in the Arcweave project
- API key / hash invalid: check your Arcweave account settings and project URL
- NPC not talking: check that
Specific Board Namematches the Arcweave board name exactly (case-sensitive) - Dialogue stuck: the last element needs a
dialogue_endtag orDialogueEndcomponent - Object not activating: check that
ArcweaveObjectActivationis on an always-active object (e.g. the NPC) and points to the hidden object; variable name must match exactly (e.g.sword_locked); object must start inactive; variable must be boolean, defaulttrue - Sword swing not unlocking:
Component NameinSwordSwingHandlermust beAttack(exact match); theAttackcomponent must be attached to the element in Arcweave; the Animator needs anAttackTrigger parameter
Assets/Scripts/
├── Arcweave/ -- ArcweavePlayer, ArcweavePlayerUI, ArcweaveImageLoader,
| RuntimeArcweaveImporter, ArcweaveImporterUI
├── Handlers/ -- ArcweaveAttributeHandler, ArcweaveElementComponentHandler,
| ArcweaveSceneController,
| SwordSwingHandler, ArcweaveHealthUI, ArcweaveObjectActivation
├── Game/ -- GameManager, PlayerController, ThirdPersonCamera, DialogueTrigger
└── Editor/ -- ArcweaveBuildProcessor
Central controller for Arcweave narratives. Manages project state, navigation between elements, variable state, and save/load. Fires events that UI and other scripts subscribe to.
Key events:
onProjectStart(Project)/onProjectFinish(Project)-- project lifecycleonProjectUpdated(Project)-- fires after project is initialized or reloadedonElementEnter(Element)-- new dialogue node reachedonElementOptions(Options, Action<int>)-- player choices availableonWaitInputNext(Action)-- single path forward, caller invokes to advance
arcweavePlayer.onElementEnter += (element) => {
Debug.Log($"Entered: {element.Title}");
};Subscribes to ArcweavePlayer events and renders dialogue text, images, choices, and variable debug list. Configure UI references in the Inspector.
| Inspector Field | Purpose |
|---|---|
noContentText |
Text shown when an element has no content |
emptyOptionText |
Text shown for options with no label |
continueButtonText |
Label for the continue button |
restartButtonText |
Label for the restart button |
enableFade |
Enable fade animation for text entries |
Proximity-based NPC interaction (in Game/ folder). Measures distance to the player each frame; shows a prompt and starts dialogue on key press.
| Inspector Field | Purpose |
|---|---|
Specific Board Name |
Arcweave board name for this NPC (case-sensitive) |
Arcweave Player |
Reference to ArcweavePlayer |
Trigger Distance |
Interaction radius in meters |
Interaction Key |
Key to start dialogue (default: E) |
Interaction Text |
TextMeshPro for the "Press E" prompt |
Connects an Arcweave health variable to a Unity Slider, text, and animator. Also reads a color attribute to style the slider fill.
| Inspector Field | Purpose |
|---|---|
healthVariableName |
Arcweave variable to read (e.g. wanda_health) |
healthBar (Slider) |
UI Slider for the health bar |
maxHealth |
Full scale value for the slider |
healthText (TMP) |
Optional text showing numeric value |
faceCamera |
Rotate the health bar to face the camera |
healthyAnimatorParam |
Animator bool for healthy state (default: Healthy) |
healthyThreshold |
Percentage threshold for healthy (default: 0.4) |
sliderColorComponentName |
Arcweave component for color (default: UI Settings) |
sliderColorAttribute |
Attribute name for hex color (default: SliderColor) |
Toggles a GameObject based on an Arcweave boolean variable. Uses inverted logic: true = object inactive, false = object activates.
| Inspector Field | Purpose |
|---|---|
targetObject |
GameObject to activate/deactivate |
activationVariableName |
Boolean variable name (e.g. sword_locked) |
Object Activation naming convention: name variables for the locked/closed state (e.g. sword_locked). Default true = hidden. When flipped to false, the object activates.
Reads the SceneSettings component on project load/import (in Handlers/ folder). Attributes: Time ("Day" / "Night") controls camera background; ParticleState ("rain" / "clear") toggles particle systems.
| Inspector Field | Purpose |
|---|---|
dayValue |
Value for daytime (default: Day) |
nightValue |
Value for nighttime (default: Night) |
nightColor |
Background color for night (default: black) |
Singleton that loads images by filename from Resources, then [Build]/arcweave/images/, then custom paths. Caches loaded images for performance.
Async import from web API or local JSON at runtime. Provides onImportSuccess / onImportFailure events. Saves credentials between sessions.
UI panel for runtime import. Accessible via Esc key. Supports both web and local JSON import.
Singleton state machine: Gameplay, Dialogue, Paused. Controls cursor lock, player/camera enable, and UI visibility.
| Inspector Field | Purpose |
|---|---|
dialogueStartTag |
Attribute tag for dialogue start (default: dialogue_start) |
dialogueEndTag |
Attribute tag for dialogue end (default: dialogue_end) |
dialogueStartComponentName |
Component name for dialogue start (optional, overrides tag) |
dialogueEndComponentName |
Component name for dialogue end (optional, overrides tag) |
dialogueAnimatorParam |
Animator bool parameter for dialogue state (default: IsInDialogue) |
Detection priority: component name first, attribute tag fallback. Existing boards using tags continue to work.
Camera-relative WASD movement. Drives Animator Speed float. Sword swing on left mouse button when canSwing is true (set by SwordSwingHandler).
| Inspector Field | Purpose |
|---|---|
speedAnimatorParam |
Animator float parameter for movement speed |
attackAnimatorParam |
Animator trigger parameter for attack |
attackStateName |
Animator state name for the attack animation |
Follows a target Transform with mouse-driven rotation. Disabled by GameManager during Dialogue and Paused states.
Editor-only post-build hook. Creates arcweave/ and arcweave/images/ in the build output; copies project.json if present.
Two base classes for extending Arcweave-driven behavior. The designer configures data in Arcweave; the developer implements one method in Unity.
ArcweaveAttributeHandler |
ArcweaveElementComponentHandler |
|
|---|---|---|
| Fires when | Project loads / imports | Every element change during dialogue |
| Reads | Static attribute from a global component | Component on the current element |
| Good for | Config, UI styling, static values | Runtime reactions to narrative beats |
Reads a named attribute from a named component at project load. Override ApplyAttributeValue(string value).
public class MyHandler : ArcweaveAttributeHandler
{
protected override void ApplyAttributeValue(string value)
{
// React to the attribute value
}
}| Inspector Field | Purpose |
|---|---|
componentName |
Arcweave component to search for |
attributeName |
Attribute to read from that component |
Concrete example: ArcweaveHealthUI reads a slider color attribute from a component and applies it to the health bar slider fill.
Watches ArcweavePlayer.onElementEnter. Checks if the current element has a component matching componentName. Override OnComponentDetected and optionally OnComponentAbsent.
public class MyHandler : ArcweaveElementComponentHandler
{
protected override void OnComponentDetected(Element element, Component component)
{
string value = GetAttributeValue(component, "MyAttribute");
// React to the component
}
}| Inspector Field | Purpose |
|---|---|
arcweavePlayer |
Reference to ArcweavePlayer (auto-found if empty) |
componentName |
Arcweave component to watch for (case-sensitive) |
Concrete example: SwordSwingHandler -- detects the Attack component, reads SwingSpeed attribute, calls PlayerController.EnableSwordSwing(speed). Once unlocked, the ability stays for the session.
| Inspector Field | Purpose |
|---|---|
Component Name |
Attack (must match Arcweave component) |
Player Controller |
Reference to the player's PlayerController |
Swing Speed Attribute |
Name of the speed attribute (default: SwingSpeed) |
Uses PlayerPrefs. Key prefix: arcweave_save. Saves current element ID and all variable values as JSON. Call ArcweavePlayer.Save() / Load().
- Unity 6 (6000.0.x) -- primary development version
- Unity 2022 LTS (2022.3.x) -- tested and working. Unity Hub automatically resolves package versions.
- Arcweave plugin: included in the project. Standalone plugin: https://github.com/Arcweave/arcweave-unity-plugin
