├── .gitattributes ├── .gitignore ├── .idea ├── .idea.VisualStateMachine.dir │ └── .idea │ │ ├── .gitignore │ │ ├── encodings.xml │ │ ├── indexLayout.xml │ │ └── vcs.xml ├── indexLayout.xml ├── material_theme_project_new.xml ├── projectSettingsUpdater.xml ├── vcs.xml └── workspace.xml ├── CHANGELOG.md ├── CHANGELOG.md.meta ├── CONTRIBUTING.md ├── CONTRIBUTING.md.meta ├── Editor.meta ├── Editor ├── Migration.meta ├── Migration │ ├── MethodAttributeInserter.cs │ ├── MethodAttributeInserter.cs.meta │ ├── MigrationUtils.cs │ ├── MigrationUtils.cs.meta │ ├── StateMachineMigrator.cs │ ├── StateMachineMigrator.cs.meta │ ├── StateMigrationTool.cs │ ├── StateMigrationTool.cs.meta │ ├── UsingStatementInserter.cs │ └── UsingStatementInserter.cs.meta ├── NodeGraph.meta ├── NodeGraph │ ├── .idea │ │ └── .idea.NodeGraph.dir │ │ │ └── .idea │ │ │ ├── .gitignore │ │ │ ├── encodings.xml │ │ │ ├── indexLayout.xml │ │ │ └── vcs.xml │ ├── NodeGraphEditorWindow.cs │ ├── NodeGraphEditorWindow.cs.meta │ ├── NodeGraphStateManager.cs │ ├── NodeGraphStateManager.cs.meta │ ├── NodeGraphView.cs │ ├── NodeGraphView.cs.meta │ ├── NodeView.cs │ └── NodeView.cs.meta ├── Persistence.meta ├── Persistence │ ├── CopiedData.cs │ ├── CopiedData.cs.meta │ ├── StateMachineModelSaver.cs │ └── StateMachineModelSaver.cs.meta ├── PropertyDrawer.meta ├── PropertyDrawer │ ├── StateMachineModelPropertyDrawer.cs │ └── StateMachineModelPropertyDrawer.cs.meta ├── Resources.meta ├── Resources │ ├── BreadcrumbTrailView.uss │ ├── BreadcrumbTrailView.uss.meta │ ├── BreadcrumbView.uss │ ├── BreadcrumbView.uss.meta │ ├── DropShadowSliced.png │ ├── DropShadowSliced.png.meta │ ├── DropShadowSliced2.png │ ├── DropShadowSliced2.png.meta │ ├── FooterBarView.uss │ ├── FooterBarView.uss.meta │ ├── GridPositionView.uss │ ├── GridPositionView.uss.meta │ ├── Icons.meta │ ├── Icons │ │ ├── GUI.meta │ │ ├── GUI │ │ │ ├── flow-white.png │ │ │ ├── flow-white.png.meta │ │ │ ├── flow.png │ │ │ ├── flow.png.meta │ │ │ ├── flowIcon.psd │ │ │ ├── flowIcon.psd.meta │ │ │ ├── folder-blue.png │ │ │ ├── folder-blue.png.meta │ │ │ ├── folder-flat-white.png │ │ │ ├── folder-flat-white.png.meta │ │ │ ├── folder-green.png │ │ │ ├── folder-green.png.meta │ │ │ ├── folder-red.png │ │ │ ├── folder-red.png.meta │ │ │ ├── statemachine-blue.png │ │ │ ├── statemachine-blue.png.meta │ │ │ ├── statemachine-green.png │ │ │ ├── statemachine-green.png.meta │ │ │ ├── statemachine-red.png │ │ │ └── statemachine-red.png.meta │ │ ├── Nodes.meta │ │ ├── Nodes │ │ │ ├── arc3d-center-point.png │ │ │ ├── arc3d-center-point.png.meta │ │ │ ├── arc3d.png │ │ │ ├── arc3d.png.meta │ │ │ ├── archery.png │ │ │ ├── archery.png.meta │ │ │ ├── arrow-archery.png │ │ │ ├── arrow-archery.png.meta │ │ │ ├── basketball.png │ │ │ ├── basketball.png.meta │ │ │ ├── box3d-center.png │ │ │ ├── box3d-center.png.meta │ │ │ ├── boxing-glove.png │ │ │ ├── boxing-glove.png.meta │ │ │ ├── bridge3d.png │ │ │ ├── bridge3d.png.meta │ │ │ ├── broadcast-halo-left.png │ │ │ ├── broadcast-halo-left.png.meta │ │ │ ├── broadcast-halo-right.png │ │ │ ├── broadcast-halo-right.png.meta │ │ │ ├── broadcast-left.png │ │ │ ├── broadcast-left.png.meta │ │ │ ├── broadcast-right.png │ │ │ ├── broadcast-right.png.meta │ │ │ ├── center-align.png │ │ │ ├── center-align.png.meta │ │ │ ├── center-square.png │ │ │ ├── center-square.png.meta │ │ │ ├── center.png │ │ │ ├── center.png.meta │ │ │ ├── check-circle-solid.png │ │ │ ├── check-circle-solid.png.meta │ │ │ ├── check-circle.png │ │ │ ├── check-circle.png.meta │ │ │ ├── circle.png │ │ │ ├── circle.png.meta │ │ │ ├── clipboard-check.png │ │ │ ├── clipboard-check.png.meta │ │ │ ├── clock.png │ │ │ ├── clock.png.meta │ │ │ ├── command.png │ │ │ ├── command.png.meta │ │ │ ├── cube.png │ │ │ ├── cube.png.meta │ │ │ ├── curve-array.png │ │ │ ├── curve-array.png.meta │ │ │ ├── download-circle.png │ │ │ ├── download-circle.png.meta │ │ │ ├── download.png │ │ │ ├── download.png.meta │ │ │ ├── eject.png │ │ │ ├── eject.png.meta │ │ │ ├── enter.png │ │ │ ├── enter.png.meta │ │ │ ├── erase.png │ │ │ ├── erase.png.meta │ │ │ ├── exit.png │ │ │ ├── exit.png.meta │ │ │ ├── extrude.png │ │ │ ├── extrude.png.meta │ │ │ ├── eye.png │ │ │ ├── eye.png.meta │ │ │ ├── film.png │ │ │ ├── film.png.meta │ │ │ ├── fishing.png │ │ │ ├── fishing.png.meta │ │ │ ├── floppy-disk.png │ │ │ ├── floppy-disk.png.meta │ │ │ ├── flower.png │ │ │ ├── flower.png.meta │ │ │ ├── folder.png │ │ │ ├── folder.png.meta │ │ │ ├── golf.png │ │ │ ├── golf.png.meta │ │ │ ├── grid-perspective.png │ │ │ ├── grid-perspective.png.meta │ │ │ ├── grid.png │ │ │ ├── grid.png.meta │ │ │ ├── help-circle.png │ │ │ ├── help-circle.png.meta │ │ │ ├── help.png │ │ │ ├── help.png.meta │ │ │ ├── hexagon.png │ │ │ ├── hexagon.png.meta │ │ │ ├── hourglass.png │ │ │ ├── hourglass.png.meta │ │ │ ├── info-circle.png │ │ │ ├── info-circle.png.meta │ │ │ ├── leaderboard-star.png │ │ │ ├── leaderboard-star.png.meta │ │ │ ├── medal.png │ │ │ ├── medal.png.meta │ │ │ ├── menu.png │ │ │ ├── menu.png.meta │ │ │ ├── note.png │ │ │ ├── note.png.meta │ │ │ ├── one-point-circle.png │ │ │ ├── one-point-circle.png.meta │ │ │ ├── pencil.png │ │ │ ├── pencil.png.meta │ │ │ ├── pentagon.png │ │ │ ├── pentagon.png.meta │ │ │ ├── play.png │ │ │ ├── play.png.meta │ │ │ ├── plus-circle.png │ │ │ ├── plus-circle.png.meta │ │ │ ├── plus-square.png │ │ │ ├── plus-square.png.meta │ │ │ ├── post-solid.png │ │ │ ├── post-solid.png.meta │ │ │ ├── post.png │ │ │ ├── post.png.meta │ │ │ ├── random.png │ │ │ ├── random.png.meta │ │ │ ├── report.png │ │ │ ├── report.png.meta │ │ │ ├── ruler-arrows.png │ │ │ ├── ruler-arrows.png.meta │ │ │ ├── share.png │ │ │ ├── share.png.meta │ │ │ ├── sparks.png │ │ │ ├── sparks.png.meta │ │ │ ├── spiral.png │ │ │ ├── spiral.png.meta │ │ │ ├── trash.png │ │ │ ├── trash.png.meta │ │ │ ├── triangle.png │ │ │ ├── triangle.png.meta │ │ │ ├── trophy.png │ │ │ ├── trophy.png.meta │ │ │ ├── warning.png │ │ │ ├── warning.png.meta │ │ │ ├── xray-view.png │ │ │ └── xray-view.png.meta │ │ ├── README.md │ │ ├── README.md.meta │ │ ├── icons.psd │ │ └── icons.psd.meta │ ├── NodeGraphEditor.uss │ ├── NodeGraphEditor.uss.meta │ ├── Nodes.meta │ ├── Nodes │ │ ├── BaseNode.uss │ │ ├── BaseNode.uss.meta │ │ ├── CounterNodeView.uss │ │ ├── CounterNodeView.uss.meta │ │ ├── CounterWithTargetNodeView.uss │ │ ├── CounterWithTargetNodeView.uss.meta │ │ ├── DelayNodeView.uss │ │ ├── DelayNodeView.uss.meta │ │ ├── EntryNodeView.uss │ │ ├── EntryNodeView.uss.meta │ │ ├── ExitNodeView.uss │ │ ├── ExitNodeView.uss.meta │ │ ├── JumpNodeView.uss │ │ ├── JumpNodeView.uss.meta │ │ ├── ProgressBar.uss │ │ ├── ProgressBar.uss.meta │ │ ├── PropertyContainer.uss │ │ ├── PropertyContainer.uss.meta │ │ ├── RelayNodeView.uss │ │ ├── RelayNodeView.uss.meta │ │ ├── StateNodeView.uss │ │ ├── StateNodeView.uss.meta │ │ ├── StickyNoteNodeView.uss │ │ ├── StickyNoteNodeView.uss.meta │ │ ├── SubStateNodeView.uss │ │ ├── SubStateNodeView.uss.meta │ │ ├── TitleBar.uss │ │ └── TitleBar.uss.meta │ ├── StateLabelView.uss │ ├── StateLabelView.uss.meta │ ├── StateNodeEdge.uss │ ├── StateNodeEdge.uss.meta │ ├── StateSelectorWindow.uss │ ├── StateSelectorWindow.uss.meta │ ├── ToolBarView.uss │ ├── ToolBarView.uss.meta │ ├── UnityDefaultRuntimeTheme.tss │ ├── UnityDefaultRuntimeTheme.tss.meta │ ├── folderIcon.psd │ └── folderIcon.psd.meta ├── Services.meta ├── Services │ ├── ImageService.cs │ └── ImageService.cs.meta ├── StateGraph.meta ├── StateGraph │ ├── CopyPasteHelper.cs │ ├── CopyPasteHelper.cs.meta │ ├── Factories.meta │ ├── Factories │ │ ├── StateGraphNodeFactory.cs │ │ ├── StateGraphNodeFactory.cs.meta │ │ ├── StateGraphPortFactory.cs │ │ ├── StateGraphPortFactory.cs.meta │ │ ├── StateGraphTransitionFactory.cs │ │ └── StateGraphTransitionFactory.cs.meta │ ├── Nodes.meta │ ├── Nodes │ │ ├── BaseStateNodeView.cs │ │ ├── BaseStateNodeView.cs.meta │ │ ├── CounterNodeView.cs │ │ ├── CounterNodeView.cs.meta │ │ ├── CounterWithTargetNodeView.cs │ │ ├── CounterWithTargetNodeView.cs.meta │ │ ├── DelayNodeView.cs │ │ ├── DelayNodeView.cs.meta │ │ ├── EntryNodeView.cs │ │ ├── EntryNodeView.cs.meta │ │ ├── ExitNodeView.cs │ │ ├── ExitNodeView.cs.meta │ │ ├── JumpNodeView.cs │ │ ├── JumpNodeView.cs.meta │ │ ├── RelayNodeView.cs │ │ ├── RelayNodeView.cs.meta │ │ ├── StateNodeView.cs │ │ ├── StateNodeView.cs.meta │ │ ├── StickyNoteNodeView.cs │ │ ├── StickyNoteNodeView.cs.meta │ │ ├── SubStateNodeView.cs │ │ └── SubStateNodeView.cs.meta │ ├── StateGraphContextMenu.cs │ ├── StateGraphContextMenu.cs.meta │ ├── StateNodeEdgeListener.cs │ ├── StateNodeEdgeListener.cs.meta │ ├── StateNodeGraphStateManager.cs │ ├── StateNodeGraphStateManager.cs.meta │ ├── VisualElements.meta │ ├── VisualElements │ │ ├── BreadcrumbTrailView.cs │ │ ├── BreadcrumbTrailView.cs.meta │ │ ├── BreadcrumbView.cs │ │ ├── BreadcrumbView.cs.meta │ │ ├── FooterBarView.cs │ │ ├── FooterBarView.cs.meta │ │ ├── GridPositionView.cs │ │ ├── GridPositionView.cs.meta │ │ ├── StateGraphView.cs │ │ ├── StateGraphView.cs.meta │ │ ├── StateLabelView.cs │ │ ├── StateLabelView.cs.meta │ │ ├── StateNodeEdge.cs │ │ ├── StateNodeEdge.cs.meta │ │ ├── ToolBarView.cs │ │ └── ToolBarView.cs.meta │ ├── Windows.meta │ └── Windows │ │ ├── StateGraphEditorWindow.cs │ │ ├── StateGraphEditorWindow.cs.meta │ │ ├── StateSelectorWindow.cs │ │ └── StateSelectorWindow.cs.meta ├── Utils.meta ├── Utils │ ├── ElementUtils.cs │ ├── ElementUtils.cs.meta │ ├── FieldUtils.cs │ ├── FieldUtils.cs.meta │ ├── GraphUtils.cs │ ├── GraphUtils.cs.meta │ ├── PropertyUtils.cs │ ├── PropertyUtils.cs.meta │ ├── ScriptableObjectUtils.cs │ ├── ScriptableObjectUtils.cs.meta │ ├── StateMachineModelUtils.cs │ └── StateMachineModelUtils.cs.meta ├── com.nonatomic.vsm2.editor.asmdef └── com.nonatomic.vsm2.editor.asmdef.meta ├── LICENSE ├── LICENSE.meta ├── README.md ├── README.md.meta ├── Readme~ └── logo.png ├── Runtime.meta ├── Runtime ├── Constants.cs ├── Constants.cs.meta ├── Data.meta ├── Data │ ├── SharedData.cs │ └── SharedData.cs.meta ├── Extensions.meta ├── Extensions │ ├── TypeExtensions.cs │ └── TypeExtensions.cs.meta ├── Logging.meta ├── Logging │ ├── GraphLog.cs │ └── GraphLog.cs.meta ├── NodeGraph.meta ├── NodeGraph │ ├── ModelSelection.cs │ ├── ModelSelection.cs.meta │ ├── NodeGraphModel.cs │ ├── NodeGraphModel.cs.meta │ ├── NodeGraphModelUtils.cs │ ├── NodeGraphModelUtils.cs.meta │ ├── NodeModel.cs │ ├── NodeModel.cs.meta │ ├── PortModel.cs │ ├── PortModel.cs.meta │ ├── SubAssetContainer.cs │ ├── SubAssetContainer.cs.meta │ ├── TransitionEventData.cs │ ├── TransitionEventData.cs.meta │ ├── TransitionModel.cs │ └── TransitionModel.cs.meta ├── StateGraph.meta ├── StateGraph │ ├── Attributes.meta │ ├── Attributes │ │ ├── EnterAttribute.cs │ │ ├── EnterAttribute.cs.meta │ │ ├── HideInStateSelectorAttribute.cs │ │ ├── HideInStateSelectorAttribute.cs.meta │ │ ├── NodeColorAttribute.cs │ │ ├── NodeColorAttribute.cs.meta │ │ ├── NodeIcon.cs │ │ ├── NodeIcon.cs.meta │ │ ├── NodeIconAttribute.cs │ │ ├── NodeIconAttribute.cs.meta │ │ ├── NodeWidthAttribute.cs │ │ ├── NodeWidthAttribute.cs.meta │ │ ├── ResourceSource.cs │ │ ├── ResourceSource.cs.meta │ │ ├── TransitionAttribute.cs │ │ └── TransitionAttribute.cs.meta │ ├── Extensions.meta │ ├── Extensions │ │ ├── ScriptableCommandExtension.meta │ │ └── ScriptableCommandExtension │ │ │ ├── BaseCommandState.cs │ │ │ ├── BaseCommandState.cs.meta │ │ │ ├── CommandState.cs │ │ │ └── CommandState.cs.meta │ ├── ReflectionCache.cs │ ├── ReflectionCache.cs.meta │ ├── State.cs │ ├── State.cs.meta │ ├── StateMachine.cs │ ├── StateMachine.cs.meta │ ├── StateMachineController.cs │ ├── StateMachineController.cs.meta │ ├── StateMachineModel.cs │ ├── StateMachineModel.cs.meta │ ├── StateNodeModel.cs │ ├── StateNodeModel.cs.meta │ ├── StatePortModel.cs │ ├── StatePortModel.cs.meta │ ├── StateTransitionModel.cs │ ├── StateTransitionModel.cs.meta │ ├── States.meta │ ├── States │ │ ├── BaseCounterState.cs │ │ ├── BaseCounterState.cs.meta │ │ ├── BaseDelayState.cs │ │ ├── BaseDelayState.cs.meta │ │ ├── BaseParallelSubStateMachineState.cs │ │ ├── BaseParallelSubStateMachineState.cs.meta │ │ ├── BaseSubStateMachineState.cs │ │ ├── BaseSubStateMachineState.cs.meta │ │ ├── CounterState.cs │ │ ├── CounterState.cs.meta │ │ ├── CounterWithTargetState.cs │ │ ├── CounterWithTargetState.cs.meta │ │ ├── DelayState.cs │ │ ├── DelayState.cs.meta │ │ ├── DelayUnscaledState.cs │ │ ├── DelayUnscaledState.cs.meta │ │ ├── EntryState.cs │ │ ├── EntryState.cs.meta │ │ ├── ExitState.cs │ │ ├── ExitState.cs.meta │ │ ├── JumpId.cs │ │ ├── JumpId.cs.meta │ │ ├── JumpInState.cs │ │ ├── JumpInState.cs.meta │ │ ├── JumpOutState.cs │ │ ├── JumpOutState.cs.meta │ │ ├── JumpState.cs │ │ ├── JumpState.cs.meta │ │ ├── LogState.cs │ │ ├── LogState.cs.meta │ │ ├── ParallelCompletionMode.cs │ │ ├── ParallelCompletionMode.cs.meta │ │ ├── ParallelSubStateMachineState.cs │ │ ├── ParallelSubStateMachineState.cs.meta │ │ ├── RandomFloatState.cs │ │ ├── RandomFloatState.cs.meta │ │ ├── RandomIntegerState.cs │ │ ├── RandomIntegerState.cs.meta │ │ ├── RandomThreeState.cs │ │ ├── RandomThreeState.cs.meta │ │ ├── RandomTwoState.cs │ │ ├── RandomTwoState.cs.meta │ │ ├── RelayState.cs │ │ ├── RelayState.cs.meta │ │ ├── StickyNoteState.cs │ │ ├── StickyNoteState.cs.meta │ │ ├── SubStateMachineState.cs │ │ └── SubStateMachineState.cs.meta │ ├── Validation.meta │ └── Validation │ │ ├── StateMachineValidator.cs │ │ ├── StateMachineValidator.cs.meta │ │ ├── StateNodeValidator.cs │ │ └── StateNodeValidator.cs.meta ├── Utils.meta ├── Utils │ ├── AssetUtils.cs │ ├── AssetUtils.cs.meta │ ├── AttributeUtils.cs │ ├── AttributeUtils.cs.meta │ ├── ColorUtils.cs │ ├── ColorUtils.cs.meta │ ├── GuardUtils.cs │ ├── GuardUtils.cs.meta │ ├── ReflectionUtils.cs │ ├── ReflectionUtils.cs.meta │ ├── StringUtils.cs │ ├── StringUtils.cs.meta │ ├── SubAssetUtils.cs │ ├── SubAssetUtils.cs.meta │ ├── SubAssetValidator.cs │ └── SubAssetValidator.cs.meta ├── com.nonatomic.vsm2.runtime.asmdef └── com.nonatomic.vsm2.runtime.asmdef.meta ├── Samples~ ├── Animation.meta └── Animation │ ├── Content.meta │ ├── Content │ ├── Materials.meta │ ├── Materials │ │ ├── Cube.mat │ │ └── Cube.mat.meta │ ├── Prefabs.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── Animation.unity │ │ └── Animation.unity.meta │ ├── StateMachines.meta │ └── StateMachines │ │ ├── AnimationState.asset │ │ └── AnimationState.asset.meta │ ├── Source.meta │ └── Source │ ├── AnimationController.cs │ ├── AnimationController.cs.meta │ ├── States.meta │ ├── States │ ├── MoveState.cs │ ├── MoveState.cs.meta │ ├── RotateState.cs │ ├── RotateState.cs.meta │ ├── ScaleState.cs │ └── ScaleState.cs.meta │ ├── com.nonatomic.vsm2.samples.animation.runtime.asmdef │ └── com.nonatomic.vsm2.samples.animation.runtime.asmdef.meta ├── Tests.meta ├── Tests ├── EditMode.meta ├── EditMode │ ├── com.nonatomic.vsm2.tests.editmode.asmdef │ └── com.nonatomic.vsm2.tests.editmode.asmdef.meta ├── PlayMode.meta └── PlayMode │ ├── com.nonatomic.vsm2.tests.playmode.asmdef │ └── com.nonatomic.vsm2.tests.playmode.asmdef.meta ├── package.json └── package.json.meta /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case users don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Unity-specific files 5 | *.unity binary 6 | *.prefab binary 7 | *.fbx binary 8 | *.png binary 9 | *.jpg binary 10 | *.gif binary 11 | *.psd binary 12 | *.tga binary 13 | *.dds binary 14 | *.ai binary 15 | *.mp3 binary 16 | *.ogg binary 17 | *.wav binary 18 | *.mp4 binary 19 | *.mov binary 20 | *.anim binary 21 | *.asset binary 22 | *.meta text 23 | *.controller binary 24 | *.physicMaterial binary 25 | *.physicsMaterial2D binary 26 | *.mask binary 27 | *.spriteatlas binary 28 | *.shader text 29 | *.compute text 30 | *.cginc text 31 | *.glslinc text 32 | *.hlsl text 33 | *.shadergraph binary 34 | *.shadervariants binary 35 | *.mat binary 36 | *.flare binary 37 | *.guiskin binary 38 | *.fontsettings binary 39 | *.rendertexture binary 40 | *.lighting binary 41 | *.mesh binary 42 | *.exr binary 43 | *.prefab binary 44 | 45 | # Force text for specific file types 46 | *.cs text 47 | *.json text 48 | *.md text 49 | *.xml text 50 | *.yaml text 51 | *.yml text 52 | *.asmdef text 53 | *.jslib text 54 | *.txt text 55 | *.html text 56 | *.htm text 57 | *.css text 58 | *.scss text 59 | *.less text 60 | *.csv text 61 | *.svg text 62 | *.cg text 63 | *.cgh text 64 | 65 | # Force binary for specific file types 66 | *.a binary 67 | *.so binary 68 | *.dll binary 69 | *.lib binary 70 | *.exe binary 71 | *.apk binary 72 | *.ipa binary 73 | *.7z binary 74 | *.zip binary 75 | *.rar binary 76 | *.tar binary 77 | *.gz binary 78 | *.bz2 binary 79 | *.unitypackage binary 80 | 81 | # Git LFS (Large File Storage) for large binary files 82 | *.psd filter=lfs diff=lfs merge=lfs -text 83 | *.fbx filter=lfs diff=lfs merge=lfs -text 84 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | Samples.meta 14 | 15 | # Ignore .DS_Store files 16 | .DS_Store 17 | 18 | # MemoryCaptures can get excessive in size. 19 | # They also could contain extremely sensitive data 20 | /[Mm]emoryCaptures/ 21 | 22 | # Recordings can get excessive in size 23 | /[Rr]ecordings/ 24 | 25 | # Uncomment this line if you wish to ignore the asset store tools plugin 26 | # /[Aa]ssets/AssetStoreTools* 27 | 28 | # Autogenerated Jetbrains Rider plugin 29 | .idea/.idea.VisualStateMachine.dir/ 30 | /[Aa]ssets/Plugins/Editor/JetBrains* 31 | 32 | # Visual Studio cache directory 33 | .vs/ 34 | 35 | # Gradle cache directory 36 | .gradle/ 37 | 38 | # Autogenerated VS/MD/Consulo solution and project files 39 | ExportedObj/ 40 | .consulo/ 41 | *.csproj 42 | *.unityproj 43 | *.sln 44 | *.suo 45 | *.tmp 46 | *.user 47 | *.userprefs 48 | *.pidb 49 | *.booproj 50 | *.svd 51 | *.pdb 52 | *.mdb 53 | *.opendb 54 | *.VC.db 55 | 56 | # Unity3D generated meta files 57 | *.pidb.meta 58 | *.pdb.meta 59 | *.mdb.meta 60 | 61 | # Unity3D generated file on crash reports 62 | sysinfo.txt 63 | 64 | # Builds 65 | *.apk 66 | *.aab 67 | *.unitypackage 68 | *.app 69 | 70 | # Crashlytics generated file 71 | crashlytics-build.properties 72 | 73 | # Packed Addressables 74 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 75 | 76 | # Temporary auto-generated Android Assets 77 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 78 | /[Aa]ssets/[Ss]treamingAssets/aa/* 79 | -------------------------------------------------------------------------------- /.idea/.idea.VisualStateMachine.dir/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /.idea.VisualStateMachine.iml 6 | /projectSettingsUpdater.xml 7 | /modules.xml 8 | /contentModel.xml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | -------------------------------------------------------------------------------- /.idea/.idea.VisualStateMachine.dir/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/.idea.VisualStateMachine.dir/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea.VisualStateMachine.dir/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/material_theme_project_new.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/projectSettingsUpdater.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d825fd13261d6b94c9769bf84c376238 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Visual State Machine V2 2 | 3 | First off, thank you for considering contributing to Visual State Machine V2. Any contributions you make are **greatly appreciated**. 4 | 5 | ## How to Contribute 6 | 7 | There are many ways you can contribute to our project: 8 | 9 | - Submitting bug reports and feature requests 10 | - Writing tutorials or blog posts 11 | - Improving the documentation 12 | - Writing code which can be incorporated into Visual State Machine V2 itself 13 | 14 | ### Reporting Bugs 15 | 16 | Bugs are tracked as GitHub issues. To report a bug, create an issue and use our bug report template to provide all the necessary information. 17 | 18 | ### Suggesting Enhancements 19 | 20 | This section guides you through submitting an enhancement suggestion for Visual State Machine V2, including completely new features and minor improvements to existing functionality. Use our feature request template to submit a feature request. 21 | 22 | ### Pull Requests 23 | 24 | Here's how you can make a pull request (PR) to the project: 25 | 26 | 1. Fork the repo and create your branch from `main`. 27 | 2. If you've added code that should be tested, add tests. 28 | 3. Ensure your code adheres to the existing style to maintain the project's consistency. 29 | 4. Issue that pull request! 30 | 31 | ## Coding Guidelines 32 | 33 | Visual State Machine V2 follows the [Microsoft C# Coding Conventions](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions). Please ensure your code contributions adhere to these standards. 34 | 35 | ## Local Development 36 | 37 | As this project is a Unity Package I find the best way to develop it is to create a new Unity project and add the package as a local package. This allows you to test the package in a real Unity environment. 38 | My personal preference is to clone the repo and simlink the package into the Unity project's Packages folder. This allows me to easily make changes to the package and test them in the Unity project. 39 | 40 | ## Community and Behavioral Expectations 41 | 42 | Respect our code of conduct, be kind to each other, and help out with the project. We want a healthy and welcoming community. 43 | 44 | ## License 45 | 46 | By contributing to Visual State Machine V2, you agree that your contributions will be licensed under MIT. 47 | 48 | ## Questions? 49 | 50 | If you have any questions, please feel free to contact paul@nonatomic.co.uk 51 | 52 | Thank you for contributing to Visual State Machine V2. 53 | -------------------------------------------------------------------------------- /CONTRIBUTING.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75c03f7f1cb125f4a8917ed5d7b4c838 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa38199e005605041814051098fda8b4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Migration.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 30d1b761662242a4b7a1cdee4b7e558e 3 | timeCreated: 1734868152 -------------------------------------------------------------------------------- /Editor/Migration/MethodAttributeInserter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d78e0174a79c4a0b9fae6874018342a9 3 | timeCreated: 1734870286 -------------------------------------------------------------------------------- /Editor/Migration/MigrationUtils.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System; 4 | using System.IO; 5 | 6 | public static class MigrationUtils 7 | { 8 | public static string GetPathForType(Type type) 9 | { 10 | var guids = AssetDatabase.FindAssets("t:MonoScript"); 11 | 12 | // Figure out the "base" name if this is an open generic type definition 13 | var isOpenGeneric = type.IsGenericTypeDefinition; 14 | var strippedBaseName = isOpenGeneric ? StripBacktick(type.Name) : null; 15 | 16 | foreach (var guid in guids) 17 | { 18 | var path = AssetDatabase.GUIDToAssetPath(guid); 19 | 20 | // 1. If we see an open generic, fallback to checking filename 21 | if (isOpenGeneric && !string.IsNullOrEmpty(strippedBaseName)) 22 | { 23 | var fileName = Path.GetFileName(path); 24 | if (fileName.Equals(strippedBaseName + ".cs", StringComparison.OrdinalIgnoreCase)) 25 | { 26 | var fullPath = Application.dataPath.Replace("Assets", "") + path; 27 | if (File.Exists(fullPath)) 28 | { 29 | return fullPath; 30 | } 31 | } 32 | } 33 | 34 | // 2. Otherwise, do the usual closed-generic / normal type check 35 | var monoScript = AssetDatabase.LoadAssetAtPath(path); 36 | if (monoScript == null) continue; 37 | 38 | var scriptClass = monoScript.GetClass(); 39 | if (scriptClass == null) continue; 40 | 41 | if (IsSameOrOpenGenericEquivalent(scriptClass, type)) 42 | { 43 | var fullPath = Application.dataPath.Replace("Assets", "") + path; 44 | if (File.Exists(fullPath)) 45 | { 46 | return fullPath; 47 | } 48 | } 49 | } 50 | 51 | Debug.LogWarning($"Could not find a .cs file for type: {type.FullName}"); 52 | return null; 53 | } 54 | 55 | private static bool IsSameOrOpenGenericEquivalent(Type scriptClass, Type targetType) 56 | { 57 | if (scriptClass.IsGenericType && targetType.IsGenericType) 58 | { 59 | return scriptClass.GetGenericTypeDefinition() == targetType.GetGenericTypeDefinition(); 60 | } 61 | 62 | return scriptClass == targetType; 63 | } 64 | 65 | private static string StripBacktick(string typeName) 66 | { 67 | // e.g. "RoundListState`1" => "RoundListState" 68 | var index = typeName.IndexOf('`'); 69 | return (index >= 0) 70 | ? typeName.Substring(0, index) 71 | : typeName; 72 | } 73 | } -------------------------------------------------------------------------------- /Editor/Migration/MigrationUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56decc5d83ce4bdf87048b5eff17dcff 3 | timeCreated: 1734868837 -------------------------------------------------------------------------------- /Editor/Migration/StateMachineMigrator.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph; 2 | using Nonatomic.VSM2.Utils; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.Editor.Migration 7 | { 8 | public static class StateMachineMigrator 9 | { 10 | public static void Migrate(StateMachineModel stateMachineModel) 11 | { 12 | if (GuardUtils.GuardAgainstRuntimeOperation()) return; 13 | 14 | MigrateNodePorts(stateMachineModel); 15 | MigrateTransitions(stateMachineModel); 16 | SaveModel(stateMachineModel); 17 | } 18 | 19 | private static void SaveModel(StateMachineModel stateMachineModel) 20 | { 21 | Debug.Log($"Flag as dirty: {stateMachineModel.name}"); 22 | EditorUtility.SetDirty(stateMachineModel); 23 | } 24 | 25 | private static void MigrateTransitions(StateMachineModel stateMachineModel) 26 | { 27 | if (GuardUtils.GuardAgainstRuntimeOperation()) return; 28 | 29 | for (var index = stateMachineModel.Transitions.Count - 1; index >= 0; index--) 30 | { 31 | var transition = stateMachineModel.Transitions[index]; 32 | 33 | // Handle migration (Older state machines had an OnEnterState method) 34 | if (transition.DestinationNodeId == "OnEnterState") 35 | { 36 | transition.DestinationNodeId = "OnEnter"; 37 | } 38 | 39 | if(transition.DestinationPort.Id == "OnEnterState") 40 | { 41 | transition.DestinationPort.Id = "OnEnter"; 42 | } 43 | } 44 | } 45 | 46 | private static void MigrateNodePorts(StateMachineModel stateMachineModel) 47 | { 48 | if (GuardUtils.GuardAgainstRuntimeOperation()) return; 49 | 50 | foreach (var node in stateMachineModel.Nodes) 51 | { 52 | foreach (var port in node.InputPorts) 53 | { 54 | if(port.Id == "OnEnterState") 55 | { 56 | port.Id = "OnEnter"; 57 | } 58 | } 59 | 60 | foreach (var port in node.OutputPorts) 61 | { 62 | if(port.Id == "OnEnterState") 63 | { 64 | port.Id = "OnEnter"; 65 | } 66 | } 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Editor/Migration/StateMachineMigrator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 142b56dab7d84e4fb69ecd789a5fa7c5 3 | timeCreated: 1734882231 -------------------------------------------------------------------------------- /Editor/Migration/StateMigrationTool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc6937b5509e4d4e9ba238a6b02648a2 3 | timeCreated: 1734868174 -------------------------------------------------------------------------------- /Editor/Migration/UsingStatementInserter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nonatomic.VSM2.Editor.Migration 4 | { 5 | public static class UsingStatementInserter 6 | { 7 | /// 8 | /// Inserts a 'using {namespaceToAdd};' statement at the top of the file if 9 | /// it's not already present. 10 | /// 11 | /// Full .cs file contents as a string. 12 | /// The namespace you wish to import, e.g. "System.Collections.Generic". 13 | /// Updated source code with the using statement inserted if needed. 14 | public static string InsertUsingStatementIfMissing(string sourceCode, string namespaceToAdd) 15 | { 16 | if (string.IsNullOrEmpty(sourceCode)) return sourceCode; 17 | if (string.IsNullOrEmpty(namespaceToAdd)) return sourceCode; 18 | 19 | // 1) Check if this using statement is already in the file 20 | var usingLine = $"using {namespaceToAdd};"; 21 | if (sourceCode.Contains(usingLine)) 22 | { 23 | return sourceCode; // It's already there 24 | } 25 | 26 | // 2) Split into lines so we can find where to insert 27 | var lines = sourceCode.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); 28 | 29 | // 3) Figure out where the last using statement is 30 | // We'll insert our using statement right after the last existing using line. 31 | var lastUsingIndex = -1; 32 | for (int i = 0; i < lines.Length; i++) 33 | { 34 | var trimmed = lines[i].TrimStart(); 35 | if (trimmed.StartsWith("using ") && trimmed.EndsWith(";")) 36 | { 37 | lastUsingIndex = i; 38 | } 39 | } 40 | 41 | // 4) Insert the new using line after the last using line (or at the top if none found) 42 | if (lastUsingIndex == -1) 43 | { 44 | // No existing using lines, so place ours at the very top 45 | var newLines = new string[lines.Length + 1]; 46 | newLines[0] = usingLine; 47 | Array.Copy(lines, 0, newLines, 1, lines.Length); 48 | return string.Join("\n", newLines); 49 | } 50 | else 51 | { 52 | // Insert after last using line 53 | var newLines = new string[lines.Length + 1]; 54 | Array.Copy(lines, 0, newLines, 0, lastUsingIndex + 1); 55 | newLines[lastUsingIndex + 1] = usingLine; 56 | Array.Copy(lines, lastUsingIndex + 1, newLines, lastUsingIndex + 2, lines.Length - (lastUsingIndex + 1)); 57 | return string.Join("\n", newLines); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Editor/Migration/UsingStatementInserter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0de62740395f41c7a4c3a262fee8dd6e 3 | timeCreated: 1734876897 -------------------------------------------------------------------------------- /Editor/NodeGraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 670c8bc36866402eaa22c755f2742b3c 3 | timeCreated: 1703328652 -------------------------------------------------------------------------------- /Editor/NodeGraph/.idea/.idea.NodeGraph.dir/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /modules.xml 6 | /contentModel.xml 7 | /.idea.NodeGraph.iml 8 | /projectSettingsUpdater.xml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | -------------------------------------------------------------------------------- /Editor/NodeGraph/.idea/.idea.NodeGraph.dir/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Editor/NodeGraph/.idea/.idea.NodeGraph.dir/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Editor/NodeGraph/.idea/.idea.NodeGraph.dir/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Editor/NodeGraph/NodeGraphEditorWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af97f267a22f4bd092ff58d8b32fb4d9 3 | timeCreated: 1703208275 -------------------------------------------------------------------------------- /Editor/NodeGraph/NodeGraphStateManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1330892853c84fa0b9455c13ede7fbae 3 | timeCreated: 1703364394 -------------------------------------------------------------------------------- /Editor/NodeGraph/NodeGraphView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56b2fca0ae6345c28578bd019b3b2641 3 | timeCreated: 1703209194 -------------------------------------------------------------------------------- /Editor/NodeGraph/NodeView.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor.Experimental.GraphView; 2 | 3 | namespace Nonatomic.VSM2.Editor.NodeGraph 4 | { 5 | public class NodeView : Node 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /Editor/NodeGraph/NodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be3273405b3646da962d152305e6514b 3 | timeCreated: 1703583720 -------------------------------------------------------------------------------- /Editor/Persistence.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ae147275bd94c2a8943c82a2219a1d2 3 | timeCreated: 1722683081 -------------------------------------------------------------------------------- /Editor/Persistence/CopiedData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nonatomic.VSM2.StateGraph; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.Editor.Persistence 7 | { 8 | [Serializable] 9 | public class CopiedData 10 | { 11 | public List SelectedNodes; 12 | public List SelectedTransitions; 13 | 14 | public CopiedData(List selectedNodes, List selectedTransitions) 15 | { 16 | SelectedNodes = selectedNodes; 17 | SelectedTransitions = selectedTransitions; 18 | } 19 | 20 | public string Serialize() 21 | { 22 | return JsonUtility.ToJson(this); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Editor/Persistence/CopiedData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8d581a8dbb44276b15c54389a89b768 3 | timeCreated: 1723934239 -------------------------------------------------------------------------------- /Editor/Persistence/StateMachineModelSaver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b15a3b48b5864bc28f2731c3b5c58a84 3 | timeCreated: 1719735811 -------------------------------------------------------------------------------- /Editor/PropertyDrawer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1928ef494912421a9f7f4b3f2125e164 3 | timeCreated: 1710375305 -------------------------------------------------------------------------------- /Editor/PropertyDrawer/StateMachineModelPropertyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a27656851ca45ec9f7478d431368315 3 | timeCreated: 1710375332 -------------------------------------------------------------------------------- /Editor/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f97c9aadc02a42b5ba5e4b9b339ab33a 3 | timeCreated: 1703208941 -------------------------------------------------------------------------------- /Editor/Resources/BreadcrumbTrailView.uss: -------------------------------------------------------------------------------- 1 | #breadcrumb-trail { 2 | flex-direction: row; 3 | width:100%; 4 | flex-grow: 1; 5 | } -------------------------------------------------------------------------------- /Editor/Resources/BreadcrumbTrailView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d258e8dd010489ca580e5cd3e6b66b8 3 | timeCreated: 1709713540 -------------------------------------------------------------------------------- /Editor/Resources/BreadcrumbView.uss: -------------------------------------------------------------------------------- 1 | #breadcrumb { 2 | flex-direction: row-reverse; 3 | align-items: center; 4 | } 5 | 6 | #breadcrumb-title { 7 | color: white; 8 | background-color: #1D1D1D; 9 | padding:4px; 10 | padding-left:8px; 11 | padding-right:8px; 12 | font-size: 12px; 13 | flex-shrink: 1; 14 | white-space: nowrap; 15 | } 16 | 17 | .show-tip #breadcrumb-title { 18 | padding-right:21px; 19 | margin-left:0px; 20 | margin:0px; 21 | border-radius: 0px; 22 | } 23 | 24 | .hide-tip #breadcrumb-title { 25 | margin-left:5px; 26 | margin:2px; 27 | border-bottom-left-radius: 4px; 28 | border-top-left-radius: 4px; 29 | border-top-right-radius: 4px; 30 | border-bottom-right-radius: 4px; 31 | } 32 | 33 | .origin #breadcrumb-title { 34 | margin-left:5px; 35 | border-bottom-left-radius: 4px; 36 | border-top-left-radius: 4px; 37 | } 38 | 39 | .end #breadcrumb-title { 40 | margin-left: 0px; 41 | border-bottom-left-radius: 0px; 42 | border-top-left-radius: 0px; 43 | } 44 | 45 | .breadcrumb-tip { 46 | position: absolute; 47 | background-color: #1D1D1D; 48 | height:17px; 49 | width:17px; 50 | rotate: 45deg; 51 | border-right-color: #B06101; 52 | border-top-color: #B06101; 53 | border-width: 2px; 54 | border-radius: 2px; 55 | translate: -3 0 0; 56 | } 57 | 58 | .show-tip .breadcrumb-tip { 59 | display: flex; 60 | } 61 | 62 | .hide-tip .breadcrumb-tip { 63 | display: none; 64 | } 65 | 66 | .end .breadcrumb-tip { 67 | display: none; 68 | } 69 | 70 | .end .breadcrumb-tip { 71 | translate: 6 0 0; 72 | } 73 | 74 | .breadcrumb-tip-background { 75 | /*flex: auto;*/ 76 | /*position: absolute;*/ 77 | /*background-color: #1D1D1D;*/ 78 | /*height:23px;*/ 79 | /*width:22px;*/ 80 | } -------------------------------------------------------------------------------- /Editor/Resources/BreadcrumbView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49b2dfde27b1a0f43a2b0282601050d0 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} 11 | disableValidation: 0 12 | -------------------------------------------------------------------------------- /Editor/Resources/DropShadowSliced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/DropShadowSliced.png -------------------------------------------------------------------------------- /Editor/Resources/DropShadowSliced2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/DropShadowSliced2.png -------------------------------------------------------------------------------- /Editor/Resources/FooterBarView.uss: -------------------------------------------------------------------------------- 1 | #footerBar { 2 | height: 30px; 3 | display: flex; 4 | flex-direction: row; 5 | justify-content: space-between; 6 | padding-right: 4px; 7 | padding-left: 4px; 8 | } -------------------------------------------------------------------------------- /Editor/Resources/FooterBarView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80f18b0f7a0b4d57a06f0c4201ac4825 3 | timeCreated: 1708892481 -------------------------------------------------------------------------------- /Editor/Resources/GridPositionView.uss: -------------------------------------------------------------------------------- 1 | #grid-position-container{ 2 | width:100%; 3 | flex-direction: row-reverse; 4 | } 5 | 6 | #grid-position-label-container { 7 | flex-direction: row; 8 | align-items: center; 9 | justify-content: flex-start; 10 | padding: 10px; 11 | background-color: #1d1d1d; 12 | border-radius: 5px; 13 | margin-top:2px; 14 | margin-bottom:2px; 15 | } 16 | 17 | #grid-position-label { 18 | width:100%; 19 | height:100%; 20 | font-size: 12px; 21 | -unity-text-align: middle-center; 22 | -unity-font-style: Bold; 23 | } -------------------------------------------------------------------------------- /Editor/Resources/GridPositionView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ca5222a793d444aa0a4af5784c7c40e 3 | timeCreated: 1709724310 -------------------------------------------------------------------------------- /Editor/Resources/Icons.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6a777b34b36fb644be7478bb3888556 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 516583f34daccca43a357df11d4d672c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/flow-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/GUI/flow-white.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/GUI/flow.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/flowIcon.psd: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:857651b7964ed0ef26c17e75353993b9e0895e304823f317fa7f78ee111d5a7e 3 | size 81300 4 | -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/folder-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/GUI/folder-blue.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/folder-flat-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/GUI/folder-flat-white.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/folder-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/GUI/folder-green.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/folder-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/GUI/folder-red.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/statemachine-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/GUI/statemachine-blue.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/statemachine-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/GUI/statemachine-green.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/GUI/statemachine-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/GUI/statemachine-red.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e757bc22aafe0347bb78b55817113ff 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/arc3d-center-point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/arc3d-center-point.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/arc3d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/arc3d.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/archery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/archery.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/arrow-archery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/arrow-archery.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/basketball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/basketball.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/box3d-center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/box3d-center.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/boxing-glove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/boxing-glove.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/bridge3d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/bridge3d.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/broadcast-halo-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/broadcast-halo-left.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/broadcast-halo-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/broadcast-halo-right.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/broadcast-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/broadcast-left.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/broadcast-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/broadcast-right.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/center-align.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/center-align.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/center-square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/center-square.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/center.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/check-circle-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/check-circle-solid.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/check-circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/check-circle.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/circle.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/clipboard-check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/clipboard-check.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/clock.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/command.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/command.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/cube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/cube.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/curve-array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/curve-array.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/download-circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/download-circle.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/download.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/eject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/eject.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/enter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/enter.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/erase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/erase.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/exit.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/extrude.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/extrude.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/eye.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/film.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/film.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/fishing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/fishing.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/floppy-disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/floppy-disk.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/flower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/flower.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/folder.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/golf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/golf.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/grid-perspective.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/grid-perspective.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/grid.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/help-circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/help-circle.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/help.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/hexagon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/hexagon.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/hourglass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/hourglass.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/info-circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/info-circle.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/leaderboard-star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/leaderboard-star.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/medal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/medal.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/menu.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/note.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/one-point-circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/one-point-circle.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/pencil.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/pentagon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/pentagon.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/play.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/plus-circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/plus-circle.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/plus-square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/plus-square.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/post-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/post-solid.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/post.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/random.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/random.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/report.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/ruler-arrows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/ruler-arrows.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/share.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/sparks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/sparks.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/spiral.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/spiral.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/trash.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/triangle.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/trophy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/trophy.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/warning.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/Nodes/xray-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Editor/Resources/Icons/Nodes/xray-view.png -------------------------------------------------------------------------------- /Editor/Resources/Icons/README.md: -------------------------------------------------------------------------------- 1 | # Icons 2 | 3 | * To add new icons open the icons.psd 4 | * visit https://iconoir.com/ 5 | * Find an icon you like 6 | * Set optical size to 24, stroke weight 1.5 7 | * Open in Photoshop at 24x24 8 | * Copy and paste as a new layer under the V2 folder in the icons.psd 9 | * Disable all layers bar the new icon layer 10 | * Export PNG to the Resources/Nodes directory 11 | * Open NodeIcon.cs and add the new icons name and filename -------------------------------------------------------------------------------- /Editor/Resources/Icons/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cc61003540149a4ea8f577d7270b03f 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/Resources/Icons/icons.psd: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:109bb1dd44ae9e8a5daa0f5f84aa302f9f0972f3cc7815cca9a55e4389ee8be7 3 | size 1194158 4 | -------------------------------------------------------------------------------- /Editor/Resources/NodeGraphEditor.uss: -------------------------------------------------------------------------------- 1 | .graphView { 2 | flex-grow: 1; 3 | } 4 | 5 | #grid { 6 | --grid-background-color: #2a2a2a; 7 | --line-color: #222222; 8 | --thick-line-color: #191919; 9 | --spacing: 10; 10 | } 11 | 12 | #titleBar { 13 | background-color: var(--unity-colors-toolbar_button-background); 14 | height: 21px; 15 | flex-direction: row; 16 | } 17 | 18 | #titleLabel { 19 | background-color: #333333; 20 | -unity-text-align: middle-right; 21 | width: auto; 22 | padding-left:10px; 23 | padding-right:10px; 24 | } 25 | 26 | #button-container{ 27 | flex-direction: row-reverse; 28 | width: 100%; 29 | } 30 | 31 | #toolbtn { 32 | width: 24px; 33 | height: 18px; 34 | padding-left: 2px; 35 | padding-right: 2px; 36 | } 37 | 38 | #toolbtn-icon { 39 | 40 | } 41 | 42 | #gridPositionLabel { 43 | background-color: #333333; 44 | -unity-text-align: middle-right; 45 | width: auto; 46 | padding-left:10px; 47 | padding-right:10px; 48 | } 49 | 50 | #gridShadow { 51 | width:100%; 52 | height:100%; 53 | -unity-slice-left: 4; 54 | -unity-slice-right: 4; 55 | -unity-slice-bottom: 4; 56 | -unity-slice-top: 4; 57 | opacity: 0.7; 58 | } -------------------------------------------------------------------------------- /Editor/Resources/NodeGraphEditor.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e05d4ff5f3bd4e97874db140585356ef 3 | timeCreated: 1703208956 -------------------------------------------------------------------------------- /Editor/Resources/Nodes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de72142e45f1415fad2f5a748581594e 3 | timeCreated: 1726896241 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/BaseNode.uss: -------------------------------------------------------------------------------- 1 | /* BaseNode.uss */ 2 | 3 | /* *********** Base Node *********** */ 4 | 5 | .node { 6 | min-width: 280px; 7 | max-width: 540px; 8 | } 9 | 10 | .node #state-border { 11 | position: absolute; 12 | right: 0; 13 | left: 0; 14 | top: 0; 15 | bottom: 0; 16 | border-color: #4CAF50; 17 | border-width: 2px; 18 | border-radius: 8px; 19 | opacity:0; 20 | margin:1px; 21 | } -------------------------------------------------------------------------------- /Editor/Resources/Nodes/BaseNode.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42f57d3c822d482192fccd574bcdc072 3 | timeCreated: 1726893941 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/CounterNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** CounterNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | @import url("ProgressBar.uss"); 4 | @import url("TitleBar.uss"); 5 | @import url("PropertyContainer.uss"); 6 | 7 | /* *********** Base Node *********** */ 8 | .node { 9 | min-width: auto; 10 | } 11 | 12 | /* *********** Title Bar *********** */ 13 | .node #title { 14 | height:50px; 15 | } 16 | 17 | .node #title-container { 18 | margin-bottom: 6px; 19 | } 20 | 21 | .node #title-icon { 22 | min-width:18px; 23 | min-height:18px; 24 | width: 18px; 25 | height:18px; 26 | margin-left: 3px; 27 | margin-right: 6px; 28 | margin-bottom: 3px; 29 | align-self: center; 30 | } 31 | 32 | .node #title-button-container { 33 | visibility: hidden; 34 | width:0; 35 | height:0; 36 | } 37 | 38 | /* *********** Property Container *********** */ 39 | .node #contents { 40 | display: none; 41 | } 42 | 43 | .node #property-container { 44 | flex-direction: column; 45 | background-color: rgba(0, 0, 0, 0); 46 | } 47 | 48 | /* *********** *********** */ 49 | .node IntegerField { 50 | min-width: 50px; 51 | max-width: 100px; 52 | } 53 | 54 | .unity-text-element { 55 | -unity-text-align: middle-center; 56 | } 57 | 58 | Port { 59 | height: 100%; 60 | width: 25px; 61 | min-width: 25px; 62 | padding-top:12px; 63 | } 64 | 65 | Port Label { 66 | display: none; 67 | } 68 | 69 | .count-field Label { 70 | color: #a89d46; 71 | -unity-font-style: bold; 72 | } 73 | 74 | .count-field IntegerInput { 75 | background-color: #3C3C3C; 76 | } 77 | 78 | .count-field IntegerInput TextElement { 79 | color: #969696; 80 | } 81 | -------------------------------------------------------------------------------- /Editor/Resources/Nodes/CounterNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d12bccca4ab5467cb50acd9d0ca5e5b4 3 | timeCreated: 1723282826 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/CounterWithTargetNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** CountWithTargetNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | @import url("TitleBar.uss"); 4 | @import url("ProgressBar.uss"); 5 | @import url("PropertyContainer.uss"); 6 | 7 | /* *********** Base Node *********** */ 8 | /** No Overrides **/ 9 | 10 | /* *********** Title Bar *********** */ 11 | .node #title { 12 | flex-direction: column; 13 | } 14 | 15 | /* *********** Progress Bar *********** */ 16 | /** No Overrides **/ 17 | 18 | /* *********** Property Container *********** */ 19 | /** No Overrides **/ 20 | 21 | /* *********** *********** */ 22 | .count-field Label { 23 | color: #a89d46; 24 | -unity-font-style: bold; 25 | } 26 | 27 | .count-field IntegerInput { 28 | background-color: #3C3C3C; 29 | } 30 | 31 | .count-field IntegerInput TextElement { 32 | color: #969696; 33 | } 34 | -------------------------------------------------------------------------------- /Editor/Resources/Nodes/CounterWithTargetNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 845110b36c044e3dbe95d388b9acd997 3 | timeCreated: 1726837645 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/DelayNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** DelayNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | @import url("ProgressBar.uss"); 4 | @import url("TitleBar.uss"); 5 | @import url("PropertyContainer.uss"); 6 | 7 | /* *********** Base Node *********** */ 8 | .node { 9 | min-width: auto; 10 | } 11 | 12 | /* *********** Title Bar *********** */ 13 | .node #title { 14 | height:50px; 15 | } 16 | 17 | .node #title-container { 18 | margin-bottom: 6px; 19 | } 20 | 21 | .node #title-icon { 22 | min-width:18px; 23 | min-height:18px; 24 | width: 18px; 25 | height:18px; 26 | margin-left: 3px; 27 | margin-right: 6px; 28 | margin-bottom: 3px; 29 | align-self: center; 30 | } 31 | 32 | .node #title-button-container { 33 | visibility: hidden; 34 | width:0; 35 | height:0; 36 | } 37 | 38 | /* *********** Property Container *********** */ 39 | .node #contents { 40 | display: none; 41 | } 42 | 43 | .node #property-container { 44 | flex-direction: column; 45 | background-color: rgba(0, 0, 0, 0); 46 | } 47 | 48 | /* *********** *********** */ 49 | .node FloatField { 50 | min-width: 40px; 51 | } 52 | 53 | .unity-text-element { 54 | -unity-text-align: middle-center; 55 | } 56 | 57 | Port { 58 | height: 100%; 59 | width: 25px; 60 | min-width: 25px; 61 | padding-top:12px; 62 | } 63 | 64 | Port Label { 65 | display: none; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /Editor/Resources/Nodes/DelayNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2fca00765c7542bbb6831e24f1dee82c 3 | timeCreated: 1707326279 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/EntryNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** EntryNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | @import url("TitleBar.uss"); 4 | 5 | .node { 6 | min-width: auto; 7 | } 8 | 9 | /* *********** Title Bar *********** */ 10 | .node #title-label { 11 | margin-left: 18px; 12 | margin-right: 5px; 13 | } 14 | 15 | .node #title-container { 16 | padding-right: 0px; 17 | margin-bottom: 6px; 18 | } 19 | 20 | .node #title-button-container { 21 | visibility: hidden; 22 | width:0; 23 | height:0; 24 | } 25 | 26 | .node #title-icon { 27 | min-width:24px; 28 | min-height:24px; 29 | width: 24px; 30 | height:24px; 31 | margin-right: -5px; 32 | } 33 | 34 | /* *********** *********** */ 35 | Port { 36 | height: 100%; 37 | width: 26px; 38 | } 39 | 40 | Port Label { 41 | display: none; 42 | } 43 | 44 | .node #contents { 45 | display: none; 46 | } 47 | -------------------------------------------------------------------------------- /Editor/Resources/Nodes/EntryNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd2c9d4498d849a7ae83944369275f11 3 | timeCreated: 1705622013 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/ExitNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** ExitNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | @import url("TitleBar.uss"); 4 | 5 | .node { 6 | min-width: auto; 7 | } 8 | 9 | /* *********** Title Bar *********** */ 10 | .node #title-label { 11 | margin-left: 5px; 12 | margin-right: 18px; 13 | } 14 | 15 | .node #title-container { 16 | padding-left: 0px; 17 | margin-bottom: 6px; 18 | flex-direction: row-reverse; 19 | } 20 | 21 | .node #title-button-container { 22 | visibility: hidden; 23 | width:0; 24 | height:0; 25 | } 26 | 27 | .node #title-icon { 28 | min-width:24px; 29 | min-height:24px; 30 | width: 24px; 31 | height:24px; 32 | margin-left: -5px; 33 | } 34 | 35 | /* *********** *********** */ 36 | Port { 37 | height: 100%; 38 | width: 26px; 39 | } 40 | 41 | Port Label { 42 | display: none; 43 | } 44 | 45 | .node #contents { 46 | display: none; 47 | } 48 | -------------------------------------------------------------------------------- /Editor/Resources/Nodes/ExitNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02f127b769284c08b24e4d79003e9242 3 | timeCreated: 1706577500 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/JumpNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** JumpNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | 4 | /* *********** Base Node *********** */ 5 | .node { 6 | min-width: auto; 7 | } 8 | 9 | /* *********** Title Bar *********** */ 10 | .node #title-container { 11 | padding-right: 0px; 12 | margin-top: 8px; 13 | margin-bottom: 8px; 14 | } 15 | 16 | .node.jump-out #title-container { 17 | flex-direction: row-reverse; 18 | } 19 | 20 | .node.jump-in #title-container { 21 | flex-direction: row; 22 | padding-left: 5px; 23 | } 24 | 25 | .node #title-button-container { 26 | visibility: hidden; 27 | width:0; 28 | height:0; 29 | } 30 | 31 | .node #title-icon { 32 | min-width:24px; 33 | min-height:24px; 34 | width: 24px; 35 | height:24px; 36 | } 37 | 38 | /* *********** *********** */ 39 | Port { 40 | height: 100%; 41 | width: 26px; 42 | } 43 | 44 | Port Label { 45 | display: none; 46 | } 47 | 48 | .node #contents { 49 | display: none; 50 | } 51 | 52 | .jump-out PopupField { 53 | margin-left: -6px; 54 | margin-right: 11px; 55 | height: 20px; 56 | background-color: #2a2a2a; 57 | border-radius: 5; 58 | } 59 | 60 | .jump-in PopupField { 61 | margin-left: 6px; 62 | margin-right: -3px; 63 | height: 20px; 64 | background-color: #2a2a2a; 65 | border-radius: 5; 66 | } 67 | 68 | PopupField .unity-base-field__input { 69 | border-bottom-width: 0px; 70 | border-top-width: 0px; 71 | border-left-width: 0px; 72 | border-right-width: 0px; 73 | min-width: 47px; 74 | } 75 | 76 | PopupTextElement { 77 | font-size: 12px; 78 | flex-grow: 1; 79 | -unity-text-align: middle-center; 80 | -unity-font-style: Bold; 81 | } 82 | 83 | PopupField .unity-text-element { 84 | max-width: 27px; 85 | } 86 | 87 | .jump-out #beacon { 88 | position: absolute; 89 | left: 83px; 90 | top:10px; 91 | } 92 | 93 | .jump-in #beacon { 94 | position: absolute; 95 | left:-20px; 96 | top:10px; 97 | } 98 | 99 | .jump-out #halo { 100 | position: absolute; 101 | left: 86px; 102 | top:11px; 103 | width: 20px; 104 | height: 20px; 105 | } 106 | 107 | .jump-in #halo { 108 | position: absolute; 109 | left:-20px; 110 | top:11px; 111 | width: 20px; 112 | height: 20px; 113 | } -------------------------------------------------------------------------------- /Editor/Resources/Nodes/JumpNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7c339090a754df3979aead5c9332b8c 3 | timeCreated: 1706445262 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/ProgressBar.uss: -------------------------------------------------------------------------------- 1 | /* ProgressBar.uss */ 2 | 3 | /* *********** Progress Bar *********** */ 4 | 5 | .node #progress-bar { 6 | margin-left: 0px; 7 | margin-right: 0px; 8 | margin-bottom: 0px; 9 | translate: 0px 2px; 10 | } 11 | 12 | .node .unity-progress-bar__background { 13 | background-color: #252525; 14 | } 15 | 16 | .unity-progress-bar__progress { 17 | visibility: hidden; 18 | } 19 | 20 | .active-node .unity-progress-bar__progress { 21 | visibility: visible; 22 | } 23 | 24 | #progress-bar { 25 | height: 6px; 26 | margin:2px; 27 | } 28 | 29 | .unity-progress-bar__progress { 30 | background-color: #4CAF50; 31 | } -------------------------------------------------------------------------------- /Editor/Resources/Nodes/ProgressBar.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 821e7a635c63443596a119f92f43f751 3 | timeCreated: 1726897718 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/PropertyContainer.uss: -------------------------------------------------------------------------------- 1 | /* PropertyContainer.uss */ 2 | 3 | /* *********** Property Container *********** */ 4 | #property-container { 5 | background-color: #2E2E2E; 6 | width: auto; 7 | padding-bottom: 5px; 8 | padding-top: 5px; 9 | max-height: 200px; 10 | } 11 | 12 | #property-container.has-properties { 13 | width: auto; 14 | } 15 | 16 | #property-container.has-properties #unity-content-viewport{ 17 | padding-top:5px; 18 | padding-bottom:5px; 19 | padding-left:2px; 20 | padding-right:2px; 21 | } 22 | 23 | #property-container.relay { 24 | width: 120px; 25 | } 26 | 27 | #unity-content { 28 | margin:5px; 29 | } 30 | 31 | #field-container { 32 | height: 20px; 33 | flex-direction: row; 34 | } -------------------------------------------------------------------------------- /Editor/Resources/Nodes/PropertyContainer.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84fe4621b0484b25b0784819de798c6a 3 | timeCreated: 1727078902 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/RelayNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** RelayNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | @import url("TitleBar.uss"); 4 | 5 | /* *********** Base Node *********** */ 6 | .node { 7 | min-width: auto; 8 | } 9 | 10 | /* *********** Title Bar *********** */ 11 | .node #title { 12 | height: 19px; 13 | } 14 | 15 | .node #title-container { 16 | padding-left: 0px; 17 | padding-right: 0px; 18 | } 19 | 20 | .node #title-label { 21 | font-size: 14px; 22 | margin-left: 0px; 23 | margin-right: 0px; 24 | flex-grow: 1; 25 | -unity-text-align: middle-center; 26 | -unity-font-style: Bold; 27 | } 28 | 29 | .node #title-container { 30 | margin-top: 0px; 31 | margin-bottom: 0px; 32 | } 33 | 34 | .node #title-button-container { 35 | visibility: hidden; 36 | width:0; 37 | height:0; 38 | } 39 | 40 | /* *********** *********** */ 41 | .node Port { 42 | height: 19px; 43 | padding-top:0px; 44 | } 45 | 46 | .port.input { 47 | background-color: #555555; 48 | } 49 | 50 | .port.output { 51 | background-color: #777777; 52 | } 53 | 54 | .port.input #connector { 55 | border-left-color: white; 56 | } 57 | 58 | Port { 59 | height: 100%; 60 | width: 25px; 61 | min-width: 25px; 62 | padding-top:8px; 63 | } 64 | 65 | Port Label { 66 | display: none; 67 | } 68 | 69 | .node #contents { 70 | display: none; 71 | } 72 | -------------------------------------------------------------------------------- /Editor/Resources/Nodes/RelayNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 952aacbb97134a25a6287853e740bb83 3 | timeCreated: 1723506087 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/StateNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** StateNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | @import url("ProgressBar.uss"); 4 | @import url("PropertyContainer.uss"); 5 | @import url("TitleBar.uss"); 6 | 7 | /* *********** Base Node *********** */ 8 | /** No Overrides **/ 9 | 10 | /* *********** Title Bar *********** */ 11 | .node #title { 12 | flex-direction: column; 13 | } 14 | 15 | /* *********** Property Container *********** */ 16 | -------------------------------------------------------------------------------- /Editor/Resources/Nodes/StateNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f31c987d37042ed8d86147df9288056 3 | timeCreated: 1704239534 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/StickyNoteNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** StickyNoteNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | @import url("ProgressBar.uss"); 4 | @import url("PropertyContainer.uss"); 5 | @import url("TitleBar.uss"); 6 | 7 | /* *********** Base Node *********** */ 8 | .node #title { 9 | flex-direction: column; 10 | } 11 | 12 | /* *********** Property Container *********** */ 13 | #property-container { 14 | padding-bottom: 2px; 15 | padding-top: 2px; 16 | max-height: 100px; 17 | } 18 | 19 | #property-container.has-properties #unity-content-viewport{ 20 | padding-top:2px; 21 | padding-bottom:2px; 22 | } 23 | 24 | #unity-content { 25 | margin:2px; 26 | } 27 | 28 | #field-container { 29 | height: 20px; 30 | flex-direction: row; 31 | } -------------------------------------------------------------------------------- /Editor/Resources/Nodes/StickyNoteNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48782335a7984a7aa81e5b380da26c91 3 | timeCreated: 1722780874 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/SubStateNodeView.uss: -------------------------------------------------------------------------------- 1 | /* *********** SubStateNodeView *********** */ 2 | @import url("BaseNode.uss"); 3 | @import url("ProgressBar.uss"); 4 | @import url("PropertyContainer.uss"); 5 | @import url("TitleBar.uss"); 6 | 7 | .node { 8 | min-width: 340px; 9 | max-width: 320px; 10 | } 11 | 12 | .node #title { 13 | flex-direction: column; 14 | } 15 | 16 | .node #title-button-container { 17 | visibility: hidden; 18 | width:0; 19 | height:0; 20 | } 21 | 22 | .node #title-icon { 23 | min-width:22px; 24 | min-height:22px; 25 | width: 22px; 26 | height:22px; 27 | } 28 | 29 | .unity-text-element { 30 | min-width: 50px; 31 | } -------------------------------------------------------------------------------- /Editor/Resources/Nodes/SubStateNodeView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 505e35ab332f43bd80003a879d999af9 3 | timeCreated: 1707343338 -------------------------------------------------------------------------------- /Editor/Resources/Nodes/TitleBar.uss: -------------------------------------------------------------------------------- 1 | /* TitleBar.uss */ 2 | 3 | /* *********** Title Bar *********** */ 4 | .node #title { 5 | height:36px; 6 | } 7 | 8 | .node #title-label { 9 | font-size: 14px; 10 | margin-left: 10px; 11 | margin-right: 10px; 12 | flex-grow: 1; 13 | -unity-text-align: middle-center; 14 | -unity-font-style: Bold; 15 | } 16 | 17 | .node #title-container { 18 | padding-left: 10px; 19 | padding-right: 10px; 20 | align-items: center; 21 | margin-top: 6px; 22 | margin-bottom: 0px; 23 | flex-direction: row; 24 | width: 100% 25 | } 26 | 27 | .node #title-button-container { 28 | 29 | } 30 | 31 | .node #title-icon { 32 | min-width:22px; 33 | min-height:22px; 34 | width: 22px; 35 | height:22px; 36 | } 37 | 38 | #edit-btn { 39 | background-color: #1d1d1d; 40 | margin:0px; 41 | height:100%; 42 | width:30px; 43 | border-radius: 5px; 44 | align-items: center; 45 | justify-content: center; 46 | } 47 | 48 | #edit-btn-icon { 49 | width: 80%; 50 | height: auto; 51 | } -------------------------------------------------------------------------------- /Editor/Resources/Nodes/TitleBar.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d923939bf9fc429092d43d6e9b098e08 3 | timeCreated: 1727079595 -------------------------------------------------------------------------------- /Editor/Resources/StateLabelView.uss: -------------------------------------------------------------------------------- 1 | #state-label-view { 2 | border-radius: 5px; 3 | margin-top:2px; 4 | margin-bottom:2px; 5 | } 6 | 7 | #state-label-txt { 8 | width: auto; 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | font-size: 12px; 12 | border-radius: 5px; 13 | margin-top:2px; 14 | margin-bottom:2px; 15 | -unity-text-align: middle-center; 16 | -unity-font-style: Bold; 17 | flex-grow: 1; 18 | } 19 | 20 | .play-mode { 21 | background-color: #980e23; 22 | } 23 | 24 | .edit-mode { 25 | background-color: #0e5816; 26 | } 27 | 28 | .active-mode { 29 | background-color: #af6001; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Editor/Resources/StateLabelView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4e15932d69f4293adedca5373734a7e 3 | timeCreated: 1709193803 -------------------------------------------------------------------------------- /Editor/Resources/StateNodeEdge.uss: -------------------------------------------------------------------------------- 1 | #durationLabel { 2 | position: absolute; 3 | background-color: #1d1d1d; 4 | padding-left: 4px; 5 | padding-right: 4px; 6 | padding-top: 2px; 7 | padding-bottom: 2px; 8 | border-radius: 5px; 9 | color: grey; 10 | -unity-font-style: Bold; 11 | } 12 | 13 | .unity-disabled #durationLabel { 14 | opacity: 0; 15 | } -------------------------------------------------------------------------------- /Editor/Resources/StateNodeEdge.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 244f1cee46b84a1eb1214da82633975d 3 | timeCreated: 1722768576 -------------------------------------------------------------------------------- /Editor/Resources/StateSelectorWindow.uss: -------------------------------------------------------------------------------- 1 | /* *********** State Type Selector *********** */ 2 | .unity-button { 3 | color: white; 4 | background-color: var(--unity-colors-window-background); 5 | font-size: 12px; 6 | padding: 1px 0px; 7 | border-width:0; 8 | flex-direction: row; 9 | -unity-text-align: middle-left; 10 | } 11 | 12 | .unity-button.even.highlighted-button-style { 13 | background-color: #595959; 14 | } 15 | .unity-button.highlighted-button-style { 16 | background-color: #595959; 17 | } 18 | 19 | .unity-button.even { 20 | background-color: var(--unity-colors-alternated_rows-background); 21 | } 22 | 23 | .unity-button .unity-image { 24 | width: 16px; 25 | height: 16px; 26 | margin-right: 5px; 27 | } 28 | 29 | .unity-scroll-view__content-container { 30 | padding-top:10px; 31 | background-color: var(--unity-colors-window-background); 32 | } 33 | 34 | .search-bar { 35 | width: auto; 36 | } 37 | 38 | .search-bar #unity-cancel { 39 | visibility: hidden; 40 | } 41 | 42 | #group-header{ 43 | flex-direction: row; 44 | padding-top:5px; 45 | padding-bottom:5px; 46 | } 47 | 48 | #group-body { 49 | flex-direction: column; 50 | padding-top: 0px; 51 | } 52 | 53 | #group-body.first-group { 54 | padding-top: 0px; 55 | } 56 | 57 | #group-icon{ 58 | width: 16px; 59 | height: 16px; 60 | margin-left: 5px; 61 | margin-right: 5px; 62 | } 63 | 64 | #state-button { 65 | padding-left: 8px; 66 | } 67 | 68 | #unity-checkmark { 69 | /*visibility: hidden;*/ 70 | } 71 | -------------------------------------------------------------------------------- /Editor/Resources/StateSelectorWindow.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8d22995be8e404bb3cdefb125539cd7 3 | timeCreated: 1704272207 -------------------------------------------------------------------------------- /Editor/Resources/ToolBarView.uss: -------------------------------------------------------------------------------- 1 | /* *********** Tool Bar *********** */ 2 | #toolBar { 3 | height: 34px; 4 | background-color: #2d2d2d; 5 | display: flex; 6 | flex-direction: row; 7 | align-items: center; 8 | justify-content: space-between; 9 | padding-left: 2px; 10 | padding-right: 2px; 11 | } 12 | 13 | #button-container { 14 | flex-direction: row-reverse; 15 | height: 100%; 16 | padding:2px; 17 | width: 100px; 18 | } 19 | 20 | #toolbtn { 21 | background-color: #1d1d1d; 22 | margin:0px; 23 | height:100%; 24 | width:30px; 25 | border-radius: 5px; 26 | align-items: center; 27 | justify-content: center; 28 | } 29 | 30 | #toolbtn-icon { 31 | width: 75%; 32 | height: auto; 33 | } 34 | 35 | .node #title-button-container { 36 | visibility: hidden; 37 | width:0; 38 | height:0; 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /Editor/Resources/ToolBarView.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c92197347ea0416db47f195265adab94 3 | timeCreated: 1708893122 -------------------------------------------------------------------------------- /Editor/Resources/UnityDefaultRuntimeTheme.tss: -------------------------------------------------------------------------------- 1 | @import url("unity-theme://default"); 2 | VisualElement {} -------------------------------------------------------------------------------- /Editor/Resources/UnityDefaultRuntimeTheme.tss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 469d2edcd047e2b40bd4f6940fba6fa3 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 12388, guid: 0000000000000000e000000000000000, type: 0} 11 | disableValidation: 0 12 | -------------------------------------------------------------------------------- /Editor/Resources/folderIcon.psd: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4608914e3daabe591064d4ac8ab18365d69b4bdcf7881e548dc85d3ad1ea4597 3 | size 1111288 4 | -------------------------------------------------------------------------------- /Editor/Services.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3e348a7434640668977284dfcfede6d 3 | timeCreated: 1706570610 -------------------------------------------------------------------------------- /Editor/Services/ImageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.StateGraph.Attributes; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.Editor.Services 7 | { 8 | public class ImageService 9 | { 10 | public static Texture2D FetchTexture(string path, ResourceSource source = ResourceSource.Resources) 11 | { 12 | return source switch 13 | { 14 | ResourceSource.Resources => Resources.Load(path), 15 | ResourceSource.AssetPath => AssetDatabase.LoadAssetAtPath(path), 16 | _ => throw new ArgumentOutOfRangeException() 17 | }; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Editor/Services/ImageService.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d834a0ee64894efb8da3fb424650b8d6 3 | timeCreated: 1706570618 -------------------------------------------------------------------------------- /Editor/StateGraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8c0a95dfdb74904a4bfdb11a2558e4e 3 | timeCreated: 1703365822 -------------------------------------------------------------------------------- /Editor/StateGraph/CopyPasteHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8060411222f947b7b1b83d8332539bf8 3 | timeCreated: 1723978458 -------------------------------------------------------------------------------- /Editor/StateGraph/Factories.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be000309fd2640929f111b0b1dfccbce 3 | timeCreated: 1707328125 -------------------------------------------------------------------------------- /Editor/StateGraph/Factories/StateGraphNodeFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nonatomic.VSM2.Editor.StateGraph.Nodes; 4 | using Nonatomic.VSM2.StateGraph; 5 | using Nonatomic.VSM2.StateGraph.States; 6 | using Nonatomic.VSM2.StateGraph.Validation; 7 | using UnityEditor; 8 | using UnityEditor.Experimental.GraphView; 9 | using UnityEngine; 10 | 11 | namespace Nonatomic.VSM2.Editor.StateGraph 12 | { 13 | public static class StateGraphNodeFactory 14 | { 15 | private static readonly Dictionary _stateTypeToNodeViewType = new () 16 | { 17 | {typeof(EntryState), typeof(EntryNodeView)}, 18 | {typeof(ExitState), typeof(ExitNodeView)}, 19 | {typeof(JumpInState), typeof(JumpNodeView)}, 20 | {typeof(JumpOutState), typeof(JumpNodeView)}, 21 | {typeof(DelayState), typeof(DelayNodeView)}, 22 | {typeof(RelayState), typeof(RelayNodeView)}, 23 | {typeof(CounterState), typeof(CounterNodeView)}, 24 | {typeof(CounterWithTargetState), typeof(CounterWithTargetNodeView)}, 25 | {typeof(DelayUnscaledState), typeof(DelayNodeView)}, 26 | {typeof(SubStateMachineState), typeof(SubStateNodeView)}, 27 | {typeof(StickyNoteState), typeof(StickyNoteNodeView)} 28 | }; 29 | 30 | public static BaseStateNodeView MakeNode(GraphView graphView, 31 | StateNodeModel node, 32 | StateMachineModel model) 33 | { 34 | var stateType = node.State.GetType(); 35 | var viewType = GetViewTypeByStateType(stateType); 36 | var instance = (BaseStateNodeView)Activator.CreateInstance(viewType, graphView, model, node); 37 | return instance; 38 | } 39 | 40 | public static StateNodeModel MakeStateNodeData(StateMachineModel model, 41 | Type stateType, 42 | Vector2 position) 43 | { 44 | var state = ScriptableObject.CreateInstance(stateType) as State; 45 | if (!state) return null; 46 | 47 | state.name = GenerateStateName(stateType); 48 | var stateNode = new StateNodeModel(state, position); 49 | StateNodeValidator.InitializePorts(stateNode); 50 | 51 | model.AddState(stateNode); 52 | 53 | return stateNode; 54 | } 55 | 56 | public static string GenerateStateName(Type stateType) 57 | { 58 | return $"{stateType.Name}-{GUID.Generate()}"; 59 | } 60 | 61 | private static Type GetViewTypeByStateType(Type stateType) 62 | { 63 | return _stateTypeToNodeViewType.TryGetValue(stateType, out var value) 64 | ? value 65 | : typeof(StateNodeView); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Factories/StateGraphNodeFactory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d339be0afcd490c8a97b11e4e068655 3 | timeCreated: 1704321791 -------------------------------------------------------------------------------- /Editor/StateGraph/Factories/StateGraphPortFactory.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.Editor.NodeGraph; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph; 4 | using Nonatomic.VSM2.Utils; 5 | using UnityEditor.Experimental.GraphView; 6 | using UnityEngine; 7 | using UnityEngine.UIElements; 8 | 9 | namespace Nonatomic.VSM2.Editor.StateGraph 10 | { 11 | public static class StateGraphPortFactory 12 | { 13 | public static Port MakePort(GraphView graphView, 14 | StateMachineModel model, 15 | NodeView nodeView, 16 | VisualElement parent, 17 | Direction direction, 18 | Port.Capacity capacity, 19 | PortModel portModel) 20 | { 21 | var stateNodeEdgeListener = new StateNodeEdgeListener(graphView, model); 22 | var edgeConnector = new EdgeConnector(stateNodeEdgeListener); 23 | 24 | var port = nodeView.InstantiatePort(Orientation.Horizontal, direction, capacity, typeof(Node)); 25 | port.name = portModel.Id; 26 | port.userData = portModel; 27 | port.AddManipulator(edgeConnector); 28 | port.portName = portModel.PortLabel == default 29 | ? StringUtils.ProcessPortName(portModel.Id) 30 | : StringUtils.ProcessPortName(portModel.PortLabel); 31 | 32 | if (ColorUtility.TryParseHtmlString(portModel.PortColor, out var color)) 33 | { 34 | port.portColor = color; 35 | } 36 | 37 | if (!string.IsNullOrEmpty(portModel.PortTypeName)) 38 | { 39 | var colorHex = ColorUtility.ToHtmlStringRGB(port.portColor); 40 | port.portName += $"<{portModel.PortTypeLabel}>"; 41 | port.AddToClassList("typed"); 42 | } 43 | 44 | parent.Add(port); 45 | 46 | return port; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Factories/StateGraphPortFactory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90dfecd7890044758d72ef01ced0ab9e 3 | timeCreated: 1707326948 -------------------------------------------------------------------------------- /Editor/StateGraph/Factories/StateGraphTransitionFactory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76f6b6ddccec440a824a875c224ebff9 3 | timeCreated: 1707326621 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b558b334da014948bee921cf6160cd91 3 | timeCreated: 1705734817 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/BaseStateNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0eca3d5e53fe4f97a41e580ad39c6cc9 3 | timeCreated: 1705734798 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/CounterNodeView.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph; 2 | using Nonatomic.VSM2.StateGraph.States; 3 | using UnityEditor.Experimental.GraphView; 4 | using UnityEngine.UIElements; 5 | 6 | namespace Nonatomic.VSM2.Editor.StateGraph.Nodes 7 | { 8 | public sealed class CounterNodeView : BaseStateNodeView 9 | { 10 | private readonly VisualElement _propertyContainer; 11 | private Image _icon; 12 | private IntegerField _field; 13 | private readonly BaseCounterState _counterState; 14 | 15 | public CounterNodeView(GraphView graphView, 16 | StateMachineModel stateMachineModel, 17 | StateNodeModel nodeModel) 18 | : base(graphView, stateMachineModel, nodeModel) 19 | { 20 | 21 | _counterState = (BaseCounterState) nodeModel.State; 22 | 23 | AddStyle(nameof(CounterNodeView)); 24 | AddTitleContainer(); 25 | ColorizeTitle(); 26 | RemoveTitleLabel(); 27 | AddGlowBorder(); 28 | AddInputPorts(TitleContainer); 29 | 30 | _propertyContainer = CreatePropertyContainer(); 31 | TitleContainer.Add(_propertyContainer); 32 | 33 | AddTitleIcon(); 34 | AddCounterField(); 35 | AddOutputPorts(TitleContainer); 36 | UpdatePosition(); 37 | } 38 | 39 | public override void Update() 40 | { 41 | UpdateGlowBorder(); 42 | UpdateField(); 43 | } 44 | 45 | private void UpdateField() 46 | { 47 | _field.value = _counterState.Count; 48 | } 49 | 50 | private void AddCounterField() 51 | { 52 | _field = new IntegerField(""); 53 | _field.isReadOnly = true; 54 | _field.AddToClassList("count-field"); 55 | 56 | _propertyContainer.Add(_field); 57 | } 58 | 59 | protected override void AddTitleIcon() 60 | { 61 | _icon = MakeIcon(NodeModel); 62 | _propertyContainer.Insert(0, _icon); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/CounterNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d122cc9757d14bfebda4accad9e8b04f 3 | timeCreated: 1723282791 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/CounterWithTargetNodeView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.StateGraph; 3 | using Nonatomic.VSM2.StateGraph.States; 4 | using UnityEditor.Experimental.GraphView; 5 | using UnityEngine.UIElements; 6 | 7 | namespace Nonatomic.VSM2.Editor.StateGraph.Nodes 8 | { 9 | public sealed class CounterWithTargetNodeView : BaseStateNodeView 10 | { 11 | private readonly StateMachineModel _model; 12 | private readonly Type _stateType; 13 | private VisualElement _titleContainer; 14 | private VisualElement _title; 15 | private GraphView _graphView; 16 | private VisualElement _glowBorder; 17 | private IntegerField _field; 18 | private readonly BaseCounterState _counterState; 19 | private readonly VisualElement _propertyContainer; 20 | 21 | public CounterWithTargetNodeView(GraphView graphView, 22 | StateMachineModel stateMachineModel, 23 | StateNodeModel nodeModel) 24 | : base(graphView, stateMachineModel, nodeModel) 25 | { 26 | 27 | _counterState = (BaseCounterState) nodeModel.State; 28 | var contents = this.Query("contents").First(); 29 | 30 | AddStyle(nameof(CounterWithTargetNodeView)); 31 | AddTitleContainer(); 32 | ColorizeTitle(); 33 | AddTitleLabel(); 34 | AddTitleIcon(); 35 | AddEditButton(); 36 | AddProgressBar(); 37 | AddInputPorts(inputContainer); 38 | AddOutputPorts(outputContainer); 39 | 40 | _propertyContainer = CreatePropertyContainer(); 41 | _propertyContainer.AddToClassList("full-width"); 42 | contents.Insert(0, _propertyContainer); 43 | 44 | AddProperties(_propertyContainer); 45 | AddCounterField(); 46 | AddGlowBorder(); 47 | CheckCustomWidth(); 48 | UpdatePosition(); 49 | } 50 | 51 | public override void Update() 52 | { 53 | UpdateGlowBorder(); 54 | UpdateField(); 55 | } 56 | 57 | private void UpdateField() 58 | { 59 | _field.value = _counterState.Count; 60 | } 61 | 62 | private void AddCounterField() 63 | { 64 | _field = new IntegerField("Count"); 65 | _field.isReadOnly = true; 66 | _field.AddToClassList("count-field"); 67 | 68 | var scroll = _propertyContainer.Q(); 69 | scroll.Insert(0, _field); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/CounterWithTargetNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 493a75408a544c2f829bf48583db2223 3 | timeCreated: 1726836811 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/DelayNodeView.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph; 2 | using Nonatomic.VSM2.StateGraph.States; 3 | using UnityEditor; 4 | using UnityEditor.Experimental.GraphView; 5 | using UnityEditor.UIElements; 6 | using UnityEngine.UIElements; 7 | 8 | namespace Nonatomic.VSM2.Editor.StateGraph.Nodes 9 | { 10 | public sealed class DelayNodeView : BaseStateNodeView 11 | { 12 | private readonly VisualElement _propertyContainer; 13 | private Image _icon; 14 | 15 | public DelayNodeView(GraphView graphView, 16 | StateMachineModel stateMachineModel, 17 | StateNodeModel nodeModel) 18 | : base(graphView, stateMachineModel, nodeModel) 19 | { 20 | 21 | AddStyle(nameof(DelayNodeView)); 22 | AddTitleContainer(); 23 | ColorizeTitle(); 24 | RemoveTitleLabel(); 25 | AddGlowBorder(); 26 | AddInputPorts(TitleContainer); 27 | 28 | _propertyContainer = CreatePropertyContainer(); 29 | TitleContainer.Add(_propertyContainer); 30 | 31 | AddTitleIcon(); 32 | AddDurationField(); 33 | AddOutputPorts(TitleContainer); 34 | UpdatePosition(); 35 | } 36 | 37 | public override void Update() 38 | { 39 | UpdateGlowBorder(); 40 | UpdateIconSpin(); 41 | } 42 | 43 | private void AddDurationField() 44 | { 45 | var delayState = (BaseDelayState) NodeModel.State; 46 | var floatField = new FloatField("") 47 | { 48 | bindingPath = nameof(delayState.Duration) 49 | }; 50 | this.Bind(new SerializedObject(delayState)); 51 | 52 | _propertyContainer.Add(floatField); 53 | } 54 | 55 | private void UpdateIconSpin() 56 | { 57 | var rot = _icon.style.rotate; 58 | var ang = rot.value; 59 | ang.angle = NodeModel.Active ? (NodeModel.LastActive % 1f) * 350f : 0f; 60 | rot.value = ang; 61 | 62 | _icon.style.rotate = rot; 63 | } 64 | 65 | protected override void AddTitleIcon() 66 | { 67 | _icon = MakeIcon(NodeModel); 68 | _propertyContainer.Insert(0, _icon); 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/DelayNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1ed040631e64c140ae455e661c8b7cc -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/EntryNodeView.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph; 2 | using UnityEditor.Experimental.GraphView; 3 | 4 | namespace Nonatomic.VSM2.Editor.StateGraph.Nodes 5 | { 6 | public sealed class EntryNodeView : BaseStateNodeView 7 | { 8 | public EntryNodeView(GraphView graphView, 9 | StateMachineModel stateMachineModel, 10 | StateNodeModel nodeModel) 11 | : base(graphView, stateMachineModel, nodeModel) 12 | { 13 | 14 | AddStyle(nameof(EntryNodeView)); 15 | AddTitleContainer(); 16 | ColorizeTitle(); 17 | AddTitleLabel(); 18 | AddGlowBorder(); 19 | AddTitleIcon(); 20 | AddOutputPorts(TitleContainer); 21 | UpdatePosition(); 22 | } 23 | 24 | public override void Update() 25 | { 26 | UpdateGlowBorder(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/EntryNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6425f22d8103464cbaf9439f3a3370f8 3 | timeCreated: 1705619874 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/ExitNodeView.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph; 2 | using UnityEditor.Experimental.GraphView; 3 | 4 | namespace Nonatomic.VSM2.Editor.StateGraph.Nodes 5 | { 6 | public sealed class ExitNodeView : BaseStateNodeView 7 | { 8 | 9 | public ExitNodeView(GraphView graphView, 10 | StateMachineModel stateMachineModel, 11 | StateNodeModel nodeModel) 12 | : base(graphView, stateMachineModel, nodeModel) 13 | { 14 | AddStyle(nameof(ExitNodeView)); 15 | AddTitleContainer(); 16 | ColorizeTitle(); 17 | AddTitleLabel(); 18 | AddGlowBorder(); 19 | AddTitleIcon(); 20 | AddInputPorts(TitleContainer); 21 | UpdatePosition(); 22 | } 23 | 24 | public override void Update() 25 | { 26 | UpdateGlowBorder(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/ExitNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3e5e694318e4aceba91bc3a70c78654 3 | timeCreated: 1706576844 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/JumpNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce4cd0026cfd423e9f6e344b0a5fa8fb 3 | timeCreated: 1706442599 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/RelayNodeView.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph; 2 | using UnityEditor.Experimental.GraphView; 3 | 4 | namespace Nonatomic.VSM2.Editor.StateGraph.Nodes 5 | { 6 | public class RelayNodeView : BaseStateNodeView 7 | { 8 | public RelayNodeView(GraphView graphView, 9 | StateMachineModel stateMachineModel, 10 | StateNodeModel nodeModel) 11 | : base(graphView, stateMachineModel, nodeModel) 12 | { 13 | AddStyle(nameof(RelayNodeView)); 14 | AddTitleContainer(); 15 | ColorizeTitle(); 16 | RemoveTitleLabel(); 17 | AddGlowBorder(); 18 | AddInputPorts(TitleContainer); 19 | AddOutputPorts(TitleContainer); 20 | UpdatePosition(); 21 | } 22 | 23 | public override void Update() 24 | { 25 | UpdateGlowBorder(); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/RelayNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfea216f58634ba19f4f5d93e7b45457 3 | timeCreated: 1723505928 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/StateNodeView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.StateGraph; 3 | using UnityEditor.Experimental.GraphView; 4 | using UnityEngine.UIElements; 5 | 6 | namespace Nonatomic.VSM2.Editor.StateGraph.Nodes 7 | { 8 | public sealed class StateNodeView : BaseStateNodeView 9 | { 10 | private readonly StateMachineModel _model; 11 | private readonly Type _stateType; 12 | private VisualElement _titleContainer; 13 | private VisualElement _title; 14 | private GraphView _graphView; 15 | private VisualElement _glowBorder; 16 | 17 | public StateNodeView(GraphView graphView, 18 | StateMachineModel stateMachineModel, 19 | StateNodeModel nodeModel) 20 | : base(graphView, stateMachineModel, nodeModel) 21 | { 22 | 23 | var contents = this.Query("contents").First(); 24 | 25 | AddStyle(nameof(StateNodeView)); 26 | AddTitleContainer(); 27 | ColorizeTitle(); 28 | AddTitleLabel(); 29 | AddTitleIcon(); 30 | AddEditButton(); 31 | AddProgressBar(); 32 | AddInputPorts(inputContainer); 33 | AddOutputPorts(outputContainer); 34 | 35 | var propertyContainer = CreatePropertyContainer(); 36 | propertyContainer.AddToClassList("full-width"); 37 | contents.Insert(0, propertyContainer); 38 | 39 | AddProperties(propertyContainer); 40 | AddGlowBorder(); 41 | CheckCustomWidth(); 42 | UpdatePosition(); 43 | } 44 | 45 | public override void Update() 46 | { 47 | UpdateProgressBar(); 48 | UpdateGlowBorder(); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/StateNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a2d052a4ed74c13bafed7480b043409 3 | timeCreated: 1703414289 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/StickyNoteNodeView.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Nonatomic.VSM2.StateGraph; 3 | using UnityEditor; 4 | using UnityEditor.Experimental.GraphView; 5 | using UnityEditor.UIElements; 6 | using UnityEngine.UIElements; 7 | 8 | namespace Nonatomic.VSM2.Editor.StateGraph.Nodes 9 | { 10 | public class StickyNoteNodeView : BaseStateNodeView 11 | { 12 | public StickyNoteNodeView(GraphView graphView, StateMachineModel stateMachineModel, StateNodeModel nodeModel) : base(graphView, stateMachineModel, nodeModel) 13 | { 14 | var contents = this.Query("contents").First(); 15 | 16 | AddStyle(nameof(StickyNoteNodeView)); 17 | AddTitleContainer(); 18 | ColorizeTitle(); 19 | AddTitleLabel("Note"); 20 | AddTitleIcon(); 21 | AddProgressBar(); 22 | 23 | var propertyContainer = CreatePropertyContainer(); 24 | propertyContainer.AddToClassList("full-width"); 25 | contents.Insert(0, propertyContainer); 26 | AddProperties(propertyContainer); 27 | 28 | RemovePortContainer(); 29 | CheckCustomWidth(); 30 | UpdatePosition(); 31 | } 32 | 33 | protected override VisualElement MakePropertyInspector(UnityEngine.Object target, 34 | List propertiesToExclude = null) 35 | { 36 | var container = new VisualElement(); 37 | var serializedObject = new SerializedObject(target); 38 | 39 | var multilineTextField = new TextField(); 40 | multilineTextField.multiline = true; 41 | multilineTextField.bindingPath = "_note"; 42 | multilineTextField.style.whiteSpace = WhiteSpace.Normal; 43 | multilineTextField.style.minHeight = 60; 44 | multilineTextField.style.overflow = Overflow.Hidden; // Hide overflow initially 45 | multilineTextField.style.flexGrow = 1; 46 | multilineTextField.Bind(serializedObject); 47 | 48 | container.Add(multilineTextField); 49 | return container; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/StickyNoteNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 298b42a828d14f9e8afcfceae35b058c 3 | timeCreated: 1722780751 -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/SubStateNodeView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.StateGraph; 3 | using UnityEditor.Experimental.GraphView; 4 | using UnityEngine.UIElements; 5 | 6 | namespace Nonatomic.VSM2.Editor.StateGraph.Nodes 7 | { 8 | public sealed class SubStateNodeView : BaseStateNodeView 9 | { 10 | private readonly StateMachineModel _model; 11 | private readonly Type _stateType; 12 | private VisualElement _titleContainer; 13 | private VisualElement _title; 14 | private GraphView _graphView; 15 | private VisualElement _glowBorder; 16 | 17 | public SubStateNodeView(GraphView graphView, 18 | StateMachineModel stateMachineModel, 19 | StateNodeModel nodeModel) 20 | : base(graphView, stateMachineModel, nodeModel) 21 | { 22 | AddStyle(nameof(SubStateNodeView)); 23 | AddTitleContainer(); 24 | ColorizeTitle(); 25 | AddTitleLabel(); 26 | AddTitleIcon(); 27 | AddProgressBar(); 28 | AddInputPorts(inputContainer); 29 | AddOutputPorts(outputContainer); 30 | 31 | var contents = this.Query("contents").First(); 32 | var propertyContainer = CreatePropertyContainer(); 33 | propertyContainer.AddToClassList("full-width"); 34 | contents.Insert(0, propertyContainer); 35 | 36 | AddProperties(propertyContainer); 37 | AddGlowBorder(); 38 | CheckCustomWidth(); 39 | UpdatePosition(); 40 | } 41 | 42 | public override void Update() 43 | { 44 | UpdateProgressBar(); 45 | UpdateGlowBorder(); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Nodes/SubStateNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db94f32622b74114aff5c1f8d8066f7b 3 | timeCreated: 1707343315 -------------------------------------------------------------------------------- /Editor/StateGraph/StateGraphContextMenu.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91a31c047530400481ccc2eab24d5b94 3 | timeCreated: 1704270265 -------------------------------------------------------------------------------- /Editor/StateGraph/StateNodeEdgeListener.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efc8b5140bd2423485fad6e32f6d5afb 3 | timeCreated: 1704320573 -------------------------------------------------------------------------------- /Editor/StateGraph/StateNodeGraphStateManager.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Nonatomic.VSM2.Editor.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace Nonatomic.VSM2.Editor.StateGraph 8 | { 9 | public class StateNodeGraphStateManager : NodeGraphStateManager 10 | { 11 | public string StateControllerId { get; private set; } = string.Empty; 12 | 13 | private const string StateMachineControllerIdKey = "StateMachineControllerId"; 14 | 15 | public StateNodeGraphStateManager(string id) : base(id) 16 | { 17 | // ... 18 | } 19 | 20 | public void LoadModelFromStateController() 21 | { 22 | // Look for the controller that matches the stored ID. 23 | var stateMachines = GameObject.FindObjectsByType(FindObjectsInactive.Exclude, FindObjectsSortMode.None); 24 | var controller = stateMachines.FirstOrDefault(smc => smc.Id == StateControllerId); 25 | 26 | if (controller) 27 | { 28 | SetModel(controller.Model); 29 | } 30 | else 31 | { 32 | Debug.LogWarning($"StateMachineController with ID {StateControllerId} not found."); 33 | } 34 | } 35 | 36 | public void SetStateControllerId(string id) 37 | { 38 | if (string.IsNullOrEmpty(id)) return; 39 | 40 | StateControllerId = id; 41 | SaveState(); 42 | } 43 | 44 | protected override void ResetState() 45 | { 46 | base.ResetState(); 47 | EditorPrefs.DeleteKey(GetKey(StateMachineControllerIdKey)); 48 | } 49 | 50 | public override void LoadState() 51 | { 52 | base.LoadState(); 53 | StateControllerId = EditorPrefs.GetString(GetKey(StateMachineControllerIdKey)); 54 | } 55 | 56 | public override void SaveState() 57 | { 58 | base.SaveState(); 59 | if (!Model) return; 60 | 61 | EditorPrefs.SetString(GetKey(StateMachineControllerIdKey), StateControllerId); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Editor/StateGraph/StateNodeGraphStateManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3937b64cf0454955ad2075dc45c98723 3 | timeCreated: 1705154929 -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 494abcec19c746d39150e7e7e8f1273d 3 | timeCreated: 1707328176 -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/BreadcrumbTrailView.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Nonatomic.VSM2.StateGraph; 4 | using UnityEngine.UIElements; 5 | 6 | namespace Nonatomic.VSM2.Editor.StateGraph 7 | { 8 | public class BreadcrumbTrailView : VisualElement 9 | { 10 | private readonly List _breadcrumbTrail = new (); 11 | 12 | public BreadcrumbTrailView() 13 | { 14 | name = "breadcrumb-trail"; 15 | ApplyStyle(); 16 | } 17 | 18 | private void ApplyStyle() 19 | { 20 | var styleSheet = UnityEngine.Resources.Load(nameof(BreadcrumbTrailView)); 21 | styleSheets.Add(styleSheet); 22 | } 23 | 24 | public void SetModel(StateMachineModel model) 25 | { 26 | if(!model) return; 27 | 28 | _breadcrumbTrail.Clear(); 29 | Clear(); 30 | CreateBreadcrumb(model); 31 | CreateBreadcrumbOrigin(model); 32 | AddBreadcrumbsToTrail(); 33 | } 34 | 35 | private void AddBreadcrumbsToTrail() 36 | { 37 | _breadcrumbTrail.Reverse(); 38 | 39 | foreach (var breadcrumb in _breadcrumbTrail) 40 | { 41 | Add(breadcrumb); 42 | 43 | if (_breadcrumbTrail.Count > 1) 44 | { 45 | breadcrumb.ToggleTip(true); 46 | } 47 | } 48 | 49 | _breadcrumbTrail.First().SetAsOrigin(); 50 | _breadcrumbTrail.Last().SetAsEnd(); 51 | } 52 | 53 | private void CreateBreadcrumbOrigin(StateMachineModel model) 54 | { 55 | while (true) 56 | { 57 | if (!model) return; 58 | 59 | var modelParent = model.Parent; 60 | if (!modelParent) return; 61 | if (modelParent == model) return; 62 | 63 | CreateBreadcrumb(modelParent); 64 | model = modelParent; 65 | } 66 | } 67 | 68 | private void CreateBreadcrumb(StateMachineModel model) 69 | { 70 | if(!model) return; 71 | 72 | var breadcrumb = new BreadcrumbView(); 73 | breadcrumb.SetModel(model); 74 | 75 | _breadcrumbTrail.Add(breadcrumb); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/BreadcrumbTrailView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b08d9ebec2b4d0094f36127916f86d9 3 | timeCreated: 1709713451 -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/BreadcrumbView.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.NodeGraph; 2 | using Nonatomic.VSM2.StateGraph; 3 | using UnityEngine.UIElements; 4 | 5 | namespace Nonatomic.VSM2.Editor.StateGraph 6 | { 7 | public class BreadcrumbView : VisualElement 8 | { 9 | private Label _title; 10 | private VisualElement _tip; 11 | private StateMachineModel _model; 12 | 13 | public BreadcrumbView() 14 | { 15 | name = "breadcrumb"; 16 | 17 | Build(); 18 | ApplyStyle(); 19 | ToggleTip(false); 20 | 21 | this.AddManipulator(new Clickable(HandleClick)); 22 | } 23 | 24 | public void ToggleTip(bool show) 25 | { 26 | AddToClassList(show ? "show-tip" : "hide-tip"); 27 | RemoveFromClassList(show ? "hide-tip" : "show-tip"); 28 | } 29 | 30 | public void SetModel(StateMachineModel model) 31 | { 32 | if (!model) return; 33 | 34 | _model = model; 35 | SetText(model.ModelName); 36 | } 37 | 38 | private void HandleClick(EventBase eventBase) 39 | { 40 | if (!_model) return; 41 | 42 | ModelSelection.ActiveModel = _model; 43 | } 44 | 45 | public void SetAsOrigin() 46 | { 47 | AddToClassList("origin"); 48 | } 49 | 50 | public void SetAsEnd() 51 | { 52 | ToggleTip(false); 53 | AddToClassList("end"); 54 | } 55 | 56 | private void Build() 57 | { 58 | pickingMode = PickingMode.Position; 59 | 60 | _title = new Label 61 | { 62 | name = "breadcrumb-title", 63 | pickingMode = PickingMode.Ignore 64 | }; 65 | Add(_title); 66 | 67 | _tip = new VisualElement(); 68 | _tip.AddToClassList("breadcrumb-tip"); 69 | Add(_tip); 70 | } 71 | 72 | private void ApplyStyle() 73 | { 74 | var styleSheet = UnityEngine.Resources.Load(nameof(BreadcrumbView)); 75 | styleSheets.Add(styleSheet); 76 | } 77 | 78 | private void SetText(string txt) 79 | { 80 | _title.text = txt; 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/BreadcrumbView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be92e036591d41b2a610f7c25ab06198 -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/FooterBarView.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph; 2 | using UnityEngine; 3 | using UnityEngine.UIElements; 4 | 5 | namespace Nonatomic.VSM2.Editor.StateGraph 6 | { 7 | public class FooterBarView : VisualElement 8 | { 9 | private Label _gridPositionLabel; 10 | private VisualElement _footerBar; 11 | private GridPositionView _gridPosition; 12 | private StateLabelView _stateLabelView; 13 | 14 | public FooterBarView() 15 | { 16 | name = "footerBar"; 17 | 18 | ApplyStyle(); 19 | AddGridPosition(); 20 | AddStateLabel(); 21 | ApplySpacing(); 22 | } 23 | 24 | private void AddGridPosition() 25 | { 26 | _gridPosition = new GridPositionView(); 27 | Add(_gridPosition); 28 | } 29 | 30 | private void ApplySpacing() 31 | { 32 | var children = Children(); 33 | 34 | foreach (var child in children) 35 | { 36 | child.style.marginLeft = 4; 37 | } 38 | } 39 | 40 | private void AddStateLabel() 41 | { 42 | _stateLabelView = new StateLabelView(); 43 | Add(_stateLabelView); 44 | } 45 | 46 | private void ApplyStyle() 47 | { 48 | var styleSheet = UnityEngine.Resources.Load(nameof(FooterBarView)); 49 | styleSheets.Add(styleSheet); 50 | } 51 | 52 | public void SetModel(StateMachineModel model) 53 | { 54 | _stateLabelView.SetModel(model); 55 | } 56 | 57 | public void SetGridPosition(Vector2 position) 58 | { 59 | _gridPosition.SetGridPosition(position); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/FooterBarView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5933bc5310564d0b8c215901b0fc1108 3 | timeCreated: 1708889520 -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/GridPositionView.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UIElements; 3 | 4 | namespace Nonatomic.VSM2.Editor.StateGraph 5 | { 6 | public class GridPositionView : VisualElement 7 | { 8 | private Label _gridPositionLabel; 9 | private VisualElement _container; 10 | 11 | public GridPositionView() 12 | { 13 | name = "grid-position-container"; 14 | ApplyStyle(); 15 | 16 | _container = new VisualElement() 17 | { 18 | name = "grid-position-label-container" 19 | }; 20 | Add(_container); 21 | 22 | AddGridPositionLabel(); 23 | } 24 | 25 | public void SetGridPosition(Vector2 position) 26 | { 27 | // Limit precision to one decimal place 28 | var formattedX = position.x.ToString("F1"); 29 | var formattedY = position.y.ToString("F1"); 30 | 31 | // Update the label text 32 | _gridPositionLabel.text = $"x: {formattedX}, y: {formattedY}"; 33 | } 34 | 35 | private void ApplyStyle() 36 | { 37 | var styleSheet = UnityEngine.Resources.Load(nameof(GridPositionView)); 38 | styleSheets.Add(styleSheet); 39 | } 40 | 41 | private void AddGridPositionLabel() 42 | { 43 | _gridPositionLabel = new Label 44 | { 45 | name = "grid-position-label" 46 | }; 47 | 48 | _container.Add(_gridPositionLabel); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/GridPositionView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60c00fdcaa344f9facdb662c2066d284 3 | timeCreated: 1709724131 -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/StateGraphView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0a1afe84bb24144a127e37168a6aac6 3 | timeCreated: 1703365875 -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/StateLabelView.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph; 2 | using UnityEngine; 3 | using UnityEngine.UIElements; 4 | 5 | namespace Nonatomic.VSM2.Editor.StateGraph 6 | { 7 | public class StateLabelView : VisualElement 8 | { 9 | private readonly string[] _stateLabels = {"Edit Mode", "View Mode", "Active Mode"}; 10 | private readonly string[] _stateClasses = {"edit-mode", "play-mode", "active-mode"}; 11 | private readonly Label _label; 12 | private StateMachineModel _model; 13 | 14 | public StateLabelView() 15 | { 16 | name = "state-label-view"; 17 | 18 | var styleSheet = UnityEngine.Resources.Load(nameof(StateLabelView)); 19 | styleSheets.Add(styleSheet); 20 | 21 | _label = new Label 22 | { 23 | name = "state-label-txt" 24 | }; 25 | Add(_label); 26 | 27 | EditMode(); 28 | 29 | schedule.Execute(Update).Every(100); 30 | } 31 | 32 | private void EditMode() 33 | { 34 | SetMode(0); 35 | } 36 | 37 | private void PlayMode() 38 | { 39 | SetMode(1); 40 | } 41 | 42 | private void ActiveMode() 43 | { 44 | SetMode(2); 45 | } 46 | 47 | private void SetMode(int index) 48 | { 49 | foreach(var className in _stateClasses) 50 | { 51 | this.RemoveFromClassList(className); 52 | } 53 | 54 | if(index < 0 || index >= _stateClasses.Length) return; 55 | 56 | AddToClassList(_stateClasses[index]); 57 | _label.text = _stateLabels[index]; 58 | } 59 | 60 | public void SetModel(StateMachineModel model) 61 | { 62 | _model = model; 63 | } 64 | 65 | private void Update() 66 | { 67 | if(!_model) return; 68 | 69 | if (!Application.isPlaying) 70 | { 71 | EditMode(); 72 | } 73 | else 74 | { 75 | if (!_model.Original || (_model.Original.name == _model.name)) 76 | { 77 | PlayMode(); 78 | } 79 | else 80 | { 81 | ActiveMode(); 82 | } 83 | } 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/StateLabelView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98713fd4108744a091b5f5c583f0f05b 3 | timeCreated: 1709193710 -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/StateNodeEdge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4911d74b1dd24f7592a56d17f383ef87 3 | timeCreated: 1704320546 -------------------------------------------------------------------------------- /Editor/StateGraph/VisualElements/ToolBarView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1249fda5c3e451a96cb6887c92462b3 3 | timeCreated: 1704223496 -------------------------------------------------------------------------------- /Editor/StateGraph/Windows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5cb1f48c85884a8b9b7fbf99a25a7517 3 | timeCreated: 1707328137 -------------------------------------------------------------------------------- /Editor/StateGraph/Windows/StateGraphEditorWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.Editor.NodeGraph; 3 | using Nonatomic.VSM2.NodeGraph; 4 | using Nonatomic.VSM2.StateGraph; 5 | using UnityEditor; 6 | 7 | namespace Nonatomic.VSM2.Editor.StateGraph 8 | { 9 | public class StateGraphEditorWindow : NodeGraphEditorWindow 10 | { 11 | protected static string WindowTitle = "State Machine Editor"; 12 | 13 | public StateGraphEditorWindow() : base("State Machine Editor") 14 | { 15 | 16 | } 17 | 18 | [MenuItem("Window/State Machine Editor")] 19 | public static void OpenWindow() 20 | { 21 | var window = NodeGraphEditorWindow.OpenWindow(); 22 | window.titleContent.text = WindowTitle; 23 | } 24 | 25 | public override void OnEnable() 26 | { 27 | base.OnEnable(); 28 | OpenWindow(); 29 | } 30 | 31 | private void OnFocus() 32 | { 33 | Initialize(); 34 | } 35 | 36 | [InitializeOnLoadMethod] 37 | private static void InitializeOnLoad() 38 | { 39 | OpenWindowDelegate = OpenSpecificWindow; 40 | } 41 | 42 | private static NodeGraphEditorWindow OpenSpecificWindow(NodeGraphDataModel model) 43 | { 44 | if (model is not StateMachineModel) return null; 45 | 46 | var window = OpenWindow(model); 47 | window.titleContent.text = WindowTitle; 48 | 49 | return window; 50 | } 51 | 52 | protected override NodeGraphView AddGraphView() 53 | { 54 | try 55 | { 56 | var graphview = new StateGraphView("StateGraphView"); 57 | rootVisualElement.Add(graphview); 58 | return graphview; 59 | } 60 | catch (Exception e) 61 | { 62 | Console.WriteLine(e); 63 | throw; 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /Editor/StateGraph/Windows/StateGraphEditorWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a38fd0d0e5fd4d17841f26c5bb836de7 3 | timeCreated: 1703365849 -------------------------------------------------------------------------------- /Editor/StateGraph/Windows/StateSelectorWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a5326a578b44829a7cc807c1fedfed4 3 | timeCreated: 1704272066 -------------------------------------------------------------------------------- /Editor/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4755a9b21dd04ee3990961565283c9fd 3 | timeCreated: 1704245586 -------------------------------------------------------------------------------- /Editor/Utils/ElementUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEngine.UIElements; 3 | 4 | namespace Nonatomic.VSM2.Editor.Utils 5 | { 6 | public static class ElementUtils 7 | { 8 | public static bool BothContainClass(VisualElement elementA, VisualElement elementB, string className) 9 | { 10 | var elementAHasClass = elementA.GetClasses().Contains(className); 11 | var elementBHasClass = elementB.GetClasses().Contains(className); 12 | return elementAHasClass == elementBHasClass; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Editor/Utils/ElementUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6a9c7d6014946e093f268095a912fbc 3 | timeCreated: 1704324799 -------------------------------------------------------------------------------- /Editor/Utils/FieldUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using UnityEngine; 6 | 7 | namespace Nonatomic.VSM2.Editor.Utils 8 | { 9 | public static class FieldUtils 10 | { 11 | public static IEnumerable GetInheritedSerializedFields(Type type) 12 | { 13 | var infoFields = new List(); 14 | 15 | while (type != null && type != typeof(UnityEngine.Object)) 16 | { 17 | var publicFields = type.GetFields(BindingFlags.Instance | 18 | BindingFlags.Public | 19 | BindingFlags.DeclaredOnly); 20 | 21 | infoFields.AddRange(publicFields.Where(field 22 | => field.GetCustomAttribute() == null)); 23 | 24 | var privateFields = type.GetFields(BindingFlags.Instance | 25 | BindingFlags.NonPublic | 26 | BindingFlags.DeclaredOnly); 27 | 28 | infoFields.AddRange(privateFields.Where(field 29 | => field.GetCustomAttribute() != null)); 30 | 31 | type = type.BaseType; 32 | } 33 | 34 | return infoFields.ToArray(); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Editor/Utils/FieldUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa5aad9af5af458ab3092e250958828d 3 | timeCreated: 1707327962 -------------------------------------------------------------------------------- /Editor/Utils/GraphUtils.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor.Experimental.GraphView; 2 | using UnityEngine; 3 | 4 | namespace Nonatomic.VSM2.Editor.Utils 5 | { 6 | public static class GraphUtils 7 | { 8 | public static Vector3 ScreenPointToGraphPoint(Vector2 screenPoint, GraphView graphView) 9 | { 10 | return (Vector3)screenPoint - graphView.contentViewContainer.transform.position; 11 | } 12 | 13 | public static Vector2 ScreenPointToGraphPointWithZoom(Vector2 screenPoint, GraphView graphView) 14 | { 15 | var scale = graphView.contentViewContainer.transform.scale; 16 | var offset = screenPoint - (Vector2)graphView.contentViewContainer.transform.position; 17 | var scaledOffset = new Vector2(offset.x / scale.x, offset.y / scale.y); 18 | 19 | return scaledOffset; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Editor/Utils/GraphUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5eb027f296a0420bba7f3ef9b4e0b589 3 | timeCreated: 1704701314 -------------------------------------------------------------------------------- /Editor/Utils/PropertyUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Reflection; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.Editor.Utils 7 | { 8 | public static class PropertyUtils 9 | { 10 | public static T GetInstance(SerializedProperty property) where T : class 11 | { 12 | var index = GetListIndex(property.propertyPath); 13 | 14 | return index != -1 15 | ? GetInstanceFromList(property, index) 16 | : property.objectReferenceValue as T; 17 | } 18 | 19 | public static bool IsListElement(SerializedProperty property) 20 | { 21 | return GetListIndex(property.propertyPath) != -1; 22 | } 23 | 24 | private static T GetInstanceFromList(SerializedProperty property, int index) where T : class 25 | { 26 | if (property?.serializedObject == null) return default; 27 | if (property.serializedObject.targetObject == null) return default; 28 | 29 | var fieldName = ExtractListFieldName(property.propertyPath); 30 | if (fieldName == null) 31 | { 32 | Debug.LogError("Could not find field name in property path: " + property.propertyPath); 33 | return default; 34 | } 35 | 36 | var list = GetFieldListValue(property.serializedObject.targetObject, fieldName); 37 | return list != null && index < list.Count 38 | ? (T)list[index] 39 | : default; 40 | } 41 | 42 | private static int GetListIndex(string path) 43 | { 44 | var parts = path.Split('['); 45 | if (parts.Length <= 1) return -1; 46 | 47 | var indexStr = parts[1].Split(']')[0]; 48 | if (!int.TryParse(indexStr, out var index)) return -1; 49 | 50 | return index; 51 | } 52 | 53 | private static IList GetFieldListValue(object source, string fieldName) 54 | { 55 | var field = source.GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); 56 | var list = field?.GetValue(source) as IList; 57 | return list; 58 | } 59 | 60 | private static string ExtractListFieldName(string path) 61 | { 62 | var parts = path.Split('.'); 63 | for (var i = 0; i < parts.Length - 1; i++) 64 | { 65 | if (parts[i + 1] == "Array") 66 | { 67 | return parts[i]; 68 | } 69 | } 70 | 71 | return null; 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Editor/Utils/PropertyUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0442197e0f4426db8d77c0fb563a6c3 3 | timeCreated: 1710582074 -------------------------------------------------------------------------------- /Editor/Utils/ScriptableObjectUtils.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace Nonatomic.VSM2.Editor.Utils 6 | { 7 | public static class ScriptableObjectUtils 8 | { 9 | public static T CreateInstanceInProject(bool selectInstance = true) where T : ScriptableObject 10 | { 11 | var asset = ScriptableObject.CreateInstance(); 12 | 13 | var path = AssetDatabase.GetAssetPath(Selection.activeObject); 14 | if (string.IsNullOrEmpty(path)) 15 | { 16 | path = "Assets"; 17 | } 18 | else if (Path.GetExtension(path) != "") 19 | { 20 | path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), ""); 21 | } 22 | 23 | var assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/New " + typeof(T).Name + ".asset"); 24 | 25 | AssetDatabase.CreateAsset(asset, assetPathAndName); 26 | AssetDatabase.SaveAssets(); 27 | AssetDatabase.Refresh(); 28 | 29 | if(selectInstance) Selection.activeObject = asset; 30 | 31 | return asset; 32 | } 33 | 34 | /// 35 | /// Clones the specified ScriptableObject. 36 | /// 37 | /// Type of the ScriptableObject. 38 | /// The original ScriptableObject to clone. 39 | /// A deep copy of the original ScriptableObject. 40 | public static T Clone(T original) where T : ScriptableObject 41 | { 42 | if (!original) return null; 43 | 44 | return Object.Instantiate(original); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Editor/Utils/ScriptableObjectUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cca9094daf84c26a3b666ab63c3f8ac 3 | timeCreated: 1707653047 -------------------------------------------------------------------------------- /Editor/Utils/StateMachineModelUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph; 4 | 5 | namespace Nonatomic.VSM2.Editor.Utils 6 | { 7 | public static class StateMachineModelUtils 8 | { 9 | public static StateMachineModel UpdatePortDataInModel(StateMachineModel model) 10 | { 11 | for (var index = 0; index < model.Transitions.Count; index++) 12 | { 13 | var transition = model.Transitions[index]; 14 | if (model.TryGetNodeById(transition.OriginNodeId, out var originNode)) 15 | { 16 | transition.OriginPort = UpdateTransitionPortDataFromState(originNode, transition.OriginPort); 17 | } 18 | 19 | if (model.TryGetNodeById(transition.DestinationNodeId, out var destinationNode)) 20 | { 21 | transition.DestinationPort = UpdateTransitionPortDataFromState(destinationNode, transition.DestinationPort); 22 | } 23 | 24 | model.UpdateTransition(index, transition); 25 | } 26 | 27 | return model; 28 | } 29 | 30 | public static PortModel UpdateTransitionPortDataFromState(StateNodeModel nodeModel, PortModel currentPortModel) 31 | { 32 | if (nodeModel == null) return currentPortModel; 33 | if (!nodeModel.State) return currentPortModel; 34 | 35 | var stateType = nodeModel.State.GetType(); 36 | 37 | var eventInfo = stateType.GetEvent(currentPortModel.Id); 38 | if (eventInfo == null) return currentPortModel; 39 | 40 | var attributes = eventInfo.GetCustomAttributes(typeof(TransitionAttribute), false); 41 | if (attributes.Length == 0) return currentPortModel; 42 | 43 | var transAtt = (TransitionAttribute) attributes[0]; 44 | var actualPortModel = transAtt.GetPortData(eventInfo, 0); 45 | 46 | if (currentPortModel.PortLabel != actualPortModel.PortLabel) 47 | { 48 | currentPortModel.PortLabel = actualPortModel.PortLabel; 49 | } 50 | 51 | if (currentPortModel.FrameDelay != actualPortModel.FrameDelay) 52 | { 53 | currentPortModel.FrameDelay = actualPortModel.FrameDelay; 54 | } 55 | 56 | return currentPortModel; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Editor/Utils/StateMachineModelUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c263c1d32ad54685899370c7fa662896 3 | timeCreated: 1722681911 -------------------------------------------------------------------------------- /Editor/com.nonatomic.vsm2.editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.nonatomic.vsm2.editor", 3 | "rootNamespace": "Nonatomic.VSM2", 4 | "references": [ 5 | "com.nonatomic.vsm2.runtime" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": true, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /Editor/com.nonatomic.vsm2.editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64c9cf537cf49ce46bfc61ea9e66c047 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Nonatomic Ltd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 886f91a76db382c48ae7b353cf17c547 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87ae41f987182124aa6ae83e9bc7256e 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Readme~/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaulNonatomic/VisualStateMachineV2/d4c5cad22a2a82551d1027d4755715e7fde98a98/Readme~/logo.png -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33aa990a513ef674d95c842ad96c3dc4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace Nonatomic.VSM2 2 | { 3 | public static class Constants 4 | { 5 | public const string AssetMenuRoot = "Visual State Machine 2"; 6 | } 7 | } -------------------------------------------------------------------------------- /Runtime/Constants.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8328cab7e54c4284b5e271946e802e3e 3 | timeCreated: 1706945607 -------------------------------------------------------------------------------- /Runtime/Data.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65ec9798401947d0ba56d5496c01da19 3 | timeCreated: 1724567043 -------------------------------------------------------------------------------- /Runtime/Data/SharedData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e88c7cbdf72e416ea14a0c5688423867 3 | timeCreated: 1724567050 -------------------------------------------------------------------------------- /Runtime/Extensions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76399c3d25c5434a87f07f54b420ba53 3 | timeCreated: 1724626112 -------------------------------------------------------------------------------- /Runtime/Extensions/TypeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Nonatomic.VSM2.Extensions 5 | { 6 | public static class TypeExtensions 7 | { 8 | private static readonly Dictionary TypeAliases = new Dictionary 9 | { 10 | { typeof(int), "int" }, 11 | { typeof(short), "short" }, 12 | { typeof(byte), "byte" }, 13 | { typeof(byte[]), "byte[]" }, 14 | { typeof(long), "long" }, 15 | { typeof(double), "double" }, 16 | { typeof(float), "float" }, 17 | { typeof(decimal), "decimal" }, 18 | { typeof(string), "string" }, 19 | { typeof(bool), "bool" }, 20 | { typeof(object), "object" }, 21 | { typeof(void), "void" }, 22 | { typeof(char), "char" } 23 | }; 24 | 25 | public static string GetSimplifiedName(this Type type) 26 | { 27 | if (type == null) return string.Empty; 28 | 29 | if (TypeAliases.TryGetValue(type, out var alias)) 30 | { 31 | return alias; 32 | } 33 | 34 | // If no alias found, return the original type name 35 | return type.Name; 36 | } 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /Runtime/Extensions/TypeExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6574b0c473874ed7a7555cdd5587f2b3 3 | timeCreated: 1724625869 -------------------------------------------------------------------------------- /Runtime/Logging.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78f6b91d83774fc4831e3b3ada429a68 3 | timeCreated: 1706351412 -------------------------------------------------------------------------------- /Runtime/Logging/GraphLog.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Nonatomic.VSM2.Logging 4 | { 5 | public static class GraphLog 6 | { 7 | public static void Log(object msg, Object context = null) 8 | { 9 | #if GRAPH_LOG 10 | Debug.Log(msg, context); 11 | #endif 12 | } 13 | 14 | public static void LogWarning(object msg, Object context = null) 15 | { 16 | #if GRAPH_LOG 17 | Debug.LogWarning(msg, context); 18 | #endif 19 | } 20 | 21 | public static void LogError(object msg, Object context = null) 22 | { 23 | #if GRAPH_LOG 24 | Debug.LogError(msg, context); 25 | #endif 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Runtime/Logging/GraphLog.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73abee22e4f74f77a46c46b7a29ce070 3 | timeCreated: 1706351427 -------------------------------------------------------------------------------- /Runtime/NodeGraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51a59c9b7c9043a4a50d07e74743c2a5 3 | timeCreated: 1703847212 -------------------------------------------------------------------------------- /Runtime/NodeGraph/ModelSelection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nonatomic.VSM2.NodeGraph 4 | { 5 | public static class ModelSelection 6 | { 7 | public static event Action OnModelSelected; 8 | 9 | public static NodeGraphDataModel ActiveModel 10 | { 11 | get => _selectedModel; 12 | 13 | set 14 | { 15 | if (value == _selectedModel) return; 16 | 17 | _selectedModel = value; 18 | OnModelSelected?.Invoke(_selectedModel); 19 | } 20 | } 21 | 22 | private static NodeGraphDataModel _selectedModel; 23 | } 24 | } -------------------------------------------------------------------------------- /Runtime/NodeGraph/ModelSelection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f3f69978bb048c9bdf7a9bbf6239c28 3 | timeCreated: 1709979951 -------------------------------------------------------------------------------- /Runtime/NodeGraph/NodeGraphModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.NodeGraph 7 | { 8 | public abstract class NodeGraphDataModel : SubAssetContainer 9 | { 10 | 11 | } 12 | 13 | public abstract class NodeGraphModel : NodeGraphDataModel where T1 : NodeModel where T2 : TransitionModel 14 | { 15 | public List Nodes => _nodes; 16 | public List Transitions => _transitions; 17 | 18 | [SerializeField] private List _nodes = new (); 19 | [SerializeField] private List _transitions = new (); 20 | 21 | public bool TryRemoveNode(T1 node) 22 | { 23 | if (node == null || !_nodes.Contains(node)) return false; 24 | 25 | _nodes.Remove(node); 26 | MarkDirty(); 27 | return true; 28 | } 29 | 30 | public bool TryRemoveTransition(T2 transition) 31 | { 32 | if (!_transitions.Contains(transition)) return false; 33 | 34 | _transitions.Remove(transition); 35 | return true; 36 | } 37 | 38 | public void UpdateTransition(int index, T2 transition) 39 | { 40 | if(index < 0 || index >= _transitions.Count) return; 41 | 42 | _transitions[index] = transition; 43 | } 44 | 45 | protected bool TryAddNode(T1 node) 46 | { 47 | if (node == null || _nodes.Contains(node)) return false; 48 | 49 | _nodes.Add(node); 50 | MarkDirty(); 51 | return true; 52 | } 53 | 54 | protected bool TryAddTransition(T2 transition) 55 | { 56 | var existingTransition = _transitions.FirstOrDefault(t => t.Equals(transition)); 57 | if (existingTransition != null) return false; 58 | 59 | _transitions.Add(transition); 60 | 61 | #if UNITY_EDITOR 62 | { 63 | EditorUtility.SetDirty(this); 64 | EditorApplication.delayCall += () => AssetDatabase.SaveAssets(); 65 | } 66 | #endif 67 | 68 | return true; 69 | } 70 | 71 | private void MarkDirty() 72 | { 73 | #if UNITY_EDITOR 74 | { 75 | EditorUtility.SetDirty(this); 76 | } 77 | #endif 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /Runtime/NodeGraph/NodeGraphModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3032a548fadc4b46bc6b32dd478f18dc 3 | timeCreated: 1703210872 -------------------------------------------------------------------------------- /Runtime/NodeGraph/NodeGraphModelUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7153c88dc314a03ba14122f66f28c70 3 | timeCreated: 1704208515 -------------------------------------------------------------------------------- /Runtime/NodeGraph/NodeModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Nonatomic.VSM2.NodeGraph 6 | { 7 | [Serializable] 8 | public class NodeModel 9 | { 10 | public string Id; 11 | public Vector2 Position; 12 | public List OutputPorts = new List(); 13 | public List InputPorts = new List(); 14 | } 15 | } -------------------------------------------------------------------------------- /Runtime/NodeGraph/NodeModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9741b43fc2c2442ca09e44dafb2cf982 3 | timeCreated: 1703751954 -------------------------------------------------------------------------------- /Runtime/NodeGraph/PortModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.Extensions; 3 | 4 | namespace Nonatomic.VSM2.NodeGraph 5 | { 6 | [Serializable] 7 | public class PortModel 8 | { 9 | public string Id; 10 | public int Index; 11 | public int FrameDelay = 1; 12 | public string PortLabel; 13 | public string PortColor; 14 | public string PortTypeName; 15 | public string PortTypeLabel; 16 | public Type PortType; 17 | 18 | public PortModel Clone() 19 | { 20 | return new PortModel() 21 | { 22 | Id = Id, 23 | Index = Index, 24 | FrameDelay = FrameDelay, 25 | PortLabel = PortLabel, 26 | PortColor = PortColor, 27 | PortType = PortType, 28 | PortTypeLabel = PortTypeLabel, 29 | PortTypeName = PortTypeName 30 | }; 31 | } 32 | 33 | public void SetPortType(Type type) 34 | { 35 | PortType = type; 36 | PortTypeLabel = type?.GetSimplifiedName() ?? string.Empty; 37 | PortTypeName = type?.FullName ?? string.Empty; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Runtime/NodeGraph/PortModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22ea759095e5403a893a797da25a9726 3 | timeCreated: 1703845968 -------------------------------------------------------------------------------- /Runtime/NodeGraph/SubAssetContainer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2985cf22c579467880977e4f836e765e 3 | timeCreated: 1703752251 -------------------------------------------------------------------------------- /Runtime/NodeGraph/TransitionEventData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nonatomic.VSM2.NodeGraph 4 | { 5 | [Serializable] 6 | public struct TransitionEventData 7 | { 8 | public static readonly TransitionEventData Empty = new (null, null); 9 | public bool HasValue => Value != null; 10 | public object Value { get; } 11 | public Type Type { get; } 12 | 13 | public TransitionEventData(object value, Type valueType) 14 | { 15 | Value = value; 16 | Type = valueType; 17 | } 18 | 19 | public T GetValueOrDefault(T defaultValue = default) 20 | { 21 | return TryGetValue(out var result) 22 | ? result 23 | : defaultValue; 24 | } 25 | 26 | public T GetValue() 27 | { 28 | if (Value == null) 29 | { 30 | throw new InvalidOperationException("No value is present."); 31 | } 32 | 33 | if (typeof(T) != Type && !Type.IsAssignableFrom(typeof(T))) 34 | { 35 | throw new InvalidCastException($"Cannot cast value of type '{Type.Name}' to '{typeof(T).Name}'."); 36 | } 37 | 38 | return (T)Value; 39 | } 40 | 41 | public bool TryGetValue(out T result) 42 | { 43 | if (Value != null && Type == typeof(T)) 44 | { 45 | result = (T)Value; 46 | return true; 47 | } 48 | 49 | result = default; 50 | return false; 51 | } 52 | 53 | public bool HasValueOfType() 54 | { 55 | return Value != null && Type == typeof(T); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Runtime/NodeGraph/TransitionEventData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a62976609e844d66bfbb012d919a2b16 3 | timeCreated: 1724614274 -------------------------------------------------------------------------------- /Runtime/NodeGraph/TransitionModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace Nonatomic.VSM2.NodeGraph 5 | { 6 | [Serializable] 7 | public class TransitionModel 8 | { 9 | public event Action OnTransition; 10 | 11 | public string OriginNodeId; 12 | public string DestinationNodeId; 13 | 14 | public PortModel OriginPort; 15 | public PortModel DestinationPort; 16 | 17 | public void Transition() 18 | { 19 | OnTransition?.Invoke(this, TransitionEventData.Empty); 20 | } 21 | 22 | public void Transition(T value) 23 | { 24 | var eventData = new TransitionEventData(value, typeof(T)); 25 | OnTransition?.Invoke(this, eventData); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Runtime/NodeGraph/TransitionModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6568a423100422c9a25c5193de209a2 3 | timeCreated: 1703845660 -------------------------------------------------------------------------------- /Runtime/StateGraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a99500afb6a148999544a7b02a7947e8 3 | timeCreated: 1703847247 -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5adc01effe0d47c493ed9da070435a6f 3 | timeCreated: 1704625062 -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/EnterAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Nonatomic.VSM2.NodeGraph; 4 | using Nonatomic.VSM2.Utils; 5 | 6 | #if UNITY_EDITOR 7 | #endif 8 | 9 | namespace Nonatomic.VSM2.StateGraph 10 | { 11 | #pragma warning disable 0067 12 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 13 | public class EnterAttribute : Attribute 14 | { 15 | private PortModel _portModel = new (); 16 | 17 | public EnterAttribute(string portLabel = default) 18 | { 19 | _portModel.PortLabel = portLabel; 20 | } 21 | 22 | public PortModel GetPortData(MethodInfo methodInfo, int methodIndex) 23 | { 24 | _portModel.Id = methodInfo.Name; 25 | _portModel.Index = methodIndex; 26 | 27 | #if UNITY_EDITOR 28 | { 29 | if (string.IsNullOrEmpty(_portModel.PortLabel)) 30 | { 31 | _portModel.PortLabel = StringUtils.ProcessPortName(methodInfo.Name); 32 | } 33 | } 34 | #endif 35 | 36 | var args = methodInfo.GetParameters(); 37 | if (args.Length > 0) 38 | { 39 | _portModel.SetPortType(args[0].ParameterType); 40 | } 41 | 42 | return _portModel; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/EnterAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87cd91b939f94e0a96f674417325d1cb 3 | timeCreated: 1726030763 -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/HideInStateSelectorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nonatomic.VSM2.StateGraph.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 6 | public class HideInStateSelectorAttribute : Attribute 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/HideInStateSelectorAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a91220e96cd8451ab514aaf532cfb94e 3 | timeCreated: 1704625073 -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/NodeColorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nonatomic.VSM2.StateGraph.Attributes 4 | { 5 | public static class NodeColor 6 | { 7 | public const string Grey = "#444444"; 8 | public const string Red = "#990e23"; 9 | public const string Orange = "#B06101"; 10 | public const string LimeGreen = "#6d9111"; 11 | public const string Green = "#116f1c"; 12 | public const string ForestGreen = "#08704a"; 13 | public const string Teal = "#066670"; 14 | public const string LightBlue = "#037091"; 15 | public const string Blue = "#084870"; 16 | public const string Purple = "#4a0e99"; 17 | public const string Violet = "#740e99"; 18 | public const string Pink = "#750b55"; 19 | public const string Cantera = "#551C25"; 20 | public const string Dijon = "#a89d46"; 21 | 22 | public const string Black = "#000000"; 23 | public const string White = "#ffffff"; 24 | } 25 | 26 | 27 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 28 | public class NodeColorAttribute : Attribute 29 | { 30 | public string HexColor { get; private set; } 31 | 32 | public NodeColorAttribute(string hexColor) 33 | { 34 | HexColor = hexColor; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/NodeColorAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12e98585b45e4e1287ef8f8355989a4b 3 | timeCreated: 1706045705 -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/NodeIcon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51f0c2f0ecaa481e8f44189b12fa715c 3 | timeCreated: 1704625650 -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/NodeIconAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nonatomic.VSM2.StateGraph.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 6 | public class NodeIconAttribute : Attribute 7 | { 8 | public string Color { get; private set; } 9 | public string Path { get; private set; } 10 | public float Opacity { get; private set; } 11 | public ResourceSource Source { get; private set; } 12 | 13 | public NodeIconAttribute(string path, float opacity = 1f, ResourceSource source = ResourceSource.Resources, string color = "#ffffff") 14 | { 15 | Source = source; 16 | Path = path; 17 | Opacity = opacity; 18 | Color = color; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/NodeIconAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fbb1a70c82ef4f6daf5703cb88d49b18 3 | timeCreated: 1706570477 -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/NodeWidthAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nonatomic.VSM2.StateGraph.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 6 | public class NodeWidthAttribute : Attribute 7 | { 8 | public float Width { get; private set; } 9 | 10 | public NodeWidthAttribute(float width) 11 | { 12 | Width = width; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/NodeWidthAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85a9302f537e41e6ac308f8fca16abfe 3 | timeCreated: 1706569926 -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/ResourceSource.cs: -------------------------------------------------------------------------------- 1 | namespace Nonatomic.VSM2.StateGraph.Attributes 2 | { 3 | public enum ResourceSource 4 | { 5 | Resources, 6 | AssetPath 7 | } 8 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/ResourceSource.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a6f696ec9664456b01249733c38d533 3 | timeCreated: 1706570520 -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/TransitionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using UnityEngine; 4 | 5 | namespace Nonatomic.VSM2.NodeGraph 6 | { 7 | [AttributeUsage(AttributeTargets.Event)] 8 | public class TransitionAttribute : Attribute 9 | { 10 | private PortModel _portModel = new (); 11 | 12 | public TransitionAttribute() 13 | { 14 | 15 | } 16 | 17 | public TransitionAttribute(string portLabel = default, string portColor = default, int frameDelay = 1) 18 | { 19 | _portModel.PortLabel = portLabel; 20 | _portModel.PortColor = portColor; 21 | _portModel.FrameDelay = frameDelay; 22 | } 23 | 24 | public PortModel GetPortData(EventInfo eventInfo, int eventIndex) 25 | { 26 | _portModel.Id = eventInfo.Name; 27 | _portModel.Index = eventIndex; 28 | 29 | var args = eventInfo.EventHandlerType.GenericTypeArguments; 30 | if (args.Length > 0) 31 | { 32 | _portModel.SetPortType(args[0]); 33 | } 34 | 35 | return _portModel; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/Attributes/TransitionAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c86e1dacffc44e9b221a31343c6a631 3 | timeCreated: 1703861900 -------------------------------------------------------------------------------- /Runtime/StateGraph/Extensions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5284ae92b5ea45a782bc698dcfe4cbbf 3 | timeCreated: 1719960517 -------------------------------------------------------------------------------- /Runtime/StateGraph/Extensions/ScriptableCommandExtension.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a03e9d1ee35141c6af9de2321936e0c1 3 | timeCreated: 1710256151 -------------------------------------------------------------------------------- /Runtime/StateGraph/Extensions/ScriptableCommandExtension/BaseCommandState.cs: -------------------------------------------------------------------------------- 1 | #if SCRIPTABLE_COMMANDS 2 | 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using UnityEngine; 7 | using Nonatomic.ScriptableCommands; 8 | 9 | namespace Nonatomic.VSM2.StateGraph.States 10 | { 11 | public abstract class BaseCommandState : State 12 | { 13 | protected CancellationTokenSource CancellationTokenSource { get; private set; } 14 | 15 | [SerializeField] private ScriptableCommand[] _commands; 16 | 17 | public override void OnEnter() 18 | { 19 | CancellationTokenSource = new CancellationTokenSource(); 20 | _ = ExecuteCommands(); 21 | } 22 | 23 | public override void OnExit() 24 | { 25 | if (CancellationTokenSource == null) return; 26 | 27 | CancellationTokenSource.Cancel(); 28 | CancellationTokenSource.Dispose(); 29 | CancellationTokenSource = null; 30 | } 31 | 32 | protected virtual async Task ExecuteCommands() 33 | { 34 | try 35 | { 36 | await ExecuteCommandsAsync(); 37 | } 38 | catch (Exception ex) 39 | { 40 | HandleCommandException(ex); 41 | } 42 | 43 | HandleTaskCompletion(); 44 | } 45 | 46 | protected virtual async Task ExecuteCommandsAsync() 47 | { 48 | try 49 | { 50 | foreach (var command in _commands) 51 | { 52 | await command.ExecuteAsync(CancellationTokenSource.Token); 53 | } 54 | } 55 | catch (Exception ex) 56 | { 57 | HandleCommandException(ex); 58 | } 59 | } 60 | 61 | protected virtual void HandleTaskCompletion() 62 | { 63 | //... 64 | } 65 | 66 | protected virtual void HandleCommandException(Exception ex) 67 | { 68 | //... 69 | } 70 | } 71 | } 72 | #endif -------------------------------------------------------------------------------- /Runtime/StateGraph/Extensions/ScriptableCommandExtension/BaseCommandState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31ef0eee66a343d08217a166d50bf287 3 | timeCreated: 1710256119 -------------------------------------------------------------------------------- /Runtime/StateGraph/Extensions/ScriptableCommandExtension/CommandState.cs: -------------------------------------------------------------------------------- 1 | #if SCRIPTABLE_COMMANDS 2 | 3 | using System; 4 | using Nonatomic.VSM2.NodeGraph; 5 | using Nonatomic.VSM2.StateGraph.Attributes; 6 | 7 | namespace Nonatomic.VSM2.StateGraph.States 8 | { 9 | [NodeColor(NodeColor.LightBlue), NodeIcon(NodeIcon.Command)] 10 | public class CommandState : BaseCommandState 11 | { 12 | [Transition] public event Action OnComplete; 13 | 14 | [Enter] 15 | public override void OnEnter() 16 | { 17 | base.OnEnter(); 18 | } 19 | 20 | protected override void HandleTaskCompletion() 21 | { 22 | OnComplete?.Invoke(); 23 | } 24 | } 25 | } 26 | #endif -------------------------------------------------------------------------------- /Runtime/StateGraph/Extensions/ScriptableCommandExtension/CommandState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9447e7cbdbd344b38ba53aaa90c19154 3 | timeCreated: 1726780497 -------------------------------------------------------------------------------- /Runtime/StateGraph/ReflectionCache.cs: -------------------------------------------------------------------------------- 1 | namespace Nonatomic.VSM2.StateGraph 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Reflection; 7 | 8 | public static class ReflectionCache 9 | { 10 | private static readonly Dictionary<(Type Type, string EventName), EventInfo> _eventInfoCache = new(); 11 | private static readonly Dictionary<(string MethodName, Type[] GenericArgs), MethodInfo> _genericMethodCache = new(); 12 | 13 | public static EventInfo GetEventInfo(Type targetType, string eventName) 14 | { 15 | var key = (targetType, eventName); 16 | 17 | if (_eventInfoCache.TryGetValue(key, out var cachedEventInfo)) 18 | { 19 | return cachedEventInfo; 20 | } 21 | 22 | var eventInfo = targetType.GetEvent(eventName); 23 | if (eventInfo != null) 24 | { 25 | _eventInfoCache[key] = eventInfo; 26 | } 27 | 28 | return eventInfo; 29 | } 30 | 31 | public static MethodInfo GetGenericMethod( 32 | Type declaringType, 33 | string methodName, 34 | Type[] argumentTypes, 35 | int paramCount) 36 | { 37 | var key = (methodName, argumentTypes); 38 | 39 | if (_genericMethodCache.TryGetValue(key, out var cachedMethod)) 40 | { 41 | return cachedMethod; 42 | } 43 | 44 | var methodCandidates = declaringType.GetMethods(BindingFlags.Public | BindingFlags.Instance) 45 | .Where(m => m.Name == methodName && m.IsGenericMethodDefinition); 46 | 47 | foreach (var candidate in methodCandidates) 48 | { 49 | var parameters = candidate.GetParameters(); 50 | if (parameters.Length != paramCount) continue; 51 | 52 | // make a generic method 53 | var constructed = candidate.MakeGenericMethod(argumentTypes); 54 | _genericMethodCache[key] = constructed; 55 | return constructed; 56 | } 57 | 58 | return null; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/ReflectionCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e51218bc7224750ad09e83af3f57354 3 | timeCreated: 1734866457 -------------------------------------------------------------------------------- /Runtime/StateGraph/State.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bff35323bef47ed997f81c17e0e612e 3 | timeCreated: 1703583850 -------------------------------------------------------------------------------- /Runtime/StateGraph/StateMachine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 901cfbcb112c4b95abfac62e16e4a1aa 3 | timeCreated: 1704750352 -------------------------------------------------------------------------------- /Runtime/StateGraph/StateMachineController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2e11912a7b74ef785466aaf72795fa0 3 | timeCreated: 1704233868 -------------------------------------------------------------------------------- /Runtime/StateGraph/StateMachineModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fbad6fa67694a73a1930e6cbe475649 3 | timeCreated: 1703365924 -------------------------------------------------------------------------------- /Runtime/StateGraph/StateNodeModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20682a5c40fb4e2b92b99750e696272c 3 | timeCreated: 1703763111 -------------------------------------------------------------------------------- /Runtime/StateGraph/StatePortModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | 4 | namespace Nonatomic.VSM2.StateGraph 5 | { 6 | [Serializable] 7 | public class StatePortModel : PortModel 8 | { 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/StatePortModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27b653cb193542faa02b2fe6e39a9b42 3 | timeCreated: 1703847099 -------------------------------------------------------------------------------- /Runtime/StateGraph/StateTransitionModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nonatomic.VSM2.NodeGraph; 4 | 5 | namespace Nonatomic.VSM2.StateGraph 6 | { 7 | [Serializable] 8 | public class StateTransitionModel : TransitionModel, IEqualityComparer 9 | { 10 | public event Action OnTransitionBegin; 11 | public event Action OnTransitionUpdate; 12 | public event Action OnTransitionEnd; 13 | 14 | public StateTransitionModel(string originNodeId, PortModel originPort, string destinationNodeId, PortModel destinationPort) 15 | { 16 | OriginNodeId = originNodeId; 17 | OriginPort = originPort; 18 | DestinationNodeId = destinationNodeId; 19 | DestinationPort = destinationPort; 20 | } 21 | 22 | public void Start() 23 | { 24 | OnTransitionBegin?.Invoke(); 25 | } 26 | 27 | public void Update() 28 | { 29 | OnTransitionUpdate?.Invoke(); 30 | } 31 | 32 | public void End() 33 | { 34 | OnTransitionEnd?.Invoke(); 35 | } 36 | 37 | public bool Equals(TransitionModel x, TransitionModel y) 38 | { 39 | if (ReferenceEquals(x, y)) return true; 40 | if (ReferenceEquals(x, null)) return false; 41 | if (ReferenceEquals(y, null)) return false; 42 | if (x.GetType() != y.GetType()) return false; 43 | 44 | return x.OriginNodeId == y.OriginNodeId && 45 | x.DestinationNodeId == y.DestinationNodeId && 46 | Equals(x.OriginPort, y.OriginPort) && 47 | Equals(x.DestinationPort, y.DestinationPort); 48 | } 49 | 50 | public int GetHashCode(TransitionModel obj) 51 | { 52 | return HashCode.Combine(obj.OriginNodeId, obj.DestinationNodeId, obj.OriginPort, obj.DestinationPort); 53 | } 54 | 55 | public StateTransitionModel Clone() 56 | { 57 | var clone = new StateTransitionModel(this.OriginNodeId, this.OriginPort, this.DestinationNodeId, this.DestinationPort); 58 | return clone; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/StateTransitionModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24b5f00f51994f1e87bceca6d7b9a3fe 3 | timeCreated: 1703847031 -------------------------------------------------------------------------------- /Runtime/StateGraph/States.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d62f010ec0c489c9ca9c06f4a452700 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/StateGraph/States/BaseCounterState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace Nonatomic.VSM2.StateGraph.States 5 | { 6 | public abstract class BaseCounterState : State 7 | { 8 | [NonSerialized, Tooltip("Counter")] 9 | public int Count = 0; 10 | 11 | public override void OnAwake() 12 | { 13 | Count = 0; 14 | } 15 | 16 | protected virtual void IncrementCounter() 17 | { 18 | Count++; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/BaseCounterState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a53996d9c5940028ca1fcf8dd580957 3 | timeCreated: 1723282935 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/BaseDelayState.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Nonatomic.VSM2.StateGraph.States 4 | { 5 | public abstract class BaseDelayState : State 6 | { 7 | [SerializeField, Tooltip("Duration in seconds")] 8 | public float Duration = 1f; 9 | } 10 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/BaseDelayState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6babb7f318c14394a8e0daafcbbafa41 3 | timeCreated: 1720509249 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/BaseParallelSubStateMachineState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24a184e7a40448b1a6c6f8ebd10eac85 3 | timeCreated: 1710260913 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/BaseSubStateMachineState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c69c95902532483dbaf3b1d3b752bda9 3 | timeCreated: 1708042905 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/CounterState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph.Attributes; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.StateGraph.States 7 | { 8 | /** 9 | * Remember that States~ are derived from ScriptableObject so 10 | * it's important to flag that the Count value should not be 11 | * serialized, although we reset the value on awake any way. 12 | */ 13 | [NodeWidth(width:190), NodeColor(NodeColor.Dijon), NodeIcon(NodeIcon.PlusCircle)] 14 | public class CounterState : BaseCounterState 15 | { 16 | [Transition(frameDelay:0)] public event Action OnComplete; 17 | 18 | [Enter] 19 | public override void OnEnter() 20 | { 21 | IncrementCounter(); 22 | OnComplete?.Invoke(); 23 | } 24 | 25 | public override void OnExit() 26 | { 27 | //... 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/CounterState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63c24ed0b9b2490eacbb0991f0f7d08a 3 | timeCreated: 1723282337 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/CounterWithTargetState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph.Attributes; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.StateGraph.States 7 | { 8 | /** 9 | * Remember that States~ are derived from ScriptableObject so 10 | * it's important to flag that the Count value should not be 11 | * serialized, although we reset the value on awake any way. 12 | */ 13 | [NodeColor(NodeColor.Dijon), NodeIcon(NodeIcon.PlusCircle)] 14 | public class CounterWithTargetState : BaseCounterState 15 | { 16 | [Transition(frameDelay:0)] public event Action OnContinue; 17 | [Transition(frameDelay:0)] public event Action OnContinueWithCount; 18 | [Transition(frameDelay:0)] public event Action OnTargetReached; 19 | 20 | [SerializeField] private int _target = 2; 21 | [SerializeField] private bool _resetOnTarget = true; 22 | 23 | [Enter] 24 | public override void OnEnter() 25 | { 26 | Enter(); 27 | } 28 | 29 | [Enter("Enter with target")] 30 | public void OnEnterWithTarget(int target) 31 | { 32 | _target = target; 33 | Enter(); 34 | } 35 | 36 | private void Enter() 37 | { 38 | IncrementCounter(); 39 | 40 | if (Count < _target) 41 | { 42 | OnContinue?.Invoke(); 43 | OnContinueWithCount?.Invoke(Count); 44 | } 45 | else 46 | { 47 | if(_resetOnTarget) Count = 0; 48 | OnTargetReached?.Invoke(); 49 | } 50 | } 51 | 52 | public override void OnExit() 53 | { 54 | //... 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/CounterWithTargetState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b6543e1471d4436aa4bb80d7b65b008 3 | timeCreated: 1726836264 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/DelayState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph.Attributes; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.StateGraph.States 7 | { 8 | [NodeWidth(width:190), NodeColor(NodeColor.Teal), NodeIcon(NodeIcon.Clock)] 9 | public class DelayState : BaseDelayState 10 | { 11 | [Transition(frameDelay:0)] 12 | public event Action OnComplete; 13 | 14 | [NonSerialized] 15 | private float _elapsedTime; 16 | 17 | [Enter] 18 | public override void OnEnter() 19 | { 20 | _elapsedTime = 0f; 21 | } 22 | 23 | public override void OnUpdate() 24 | { 25 | _elapsedTime += Time.deltaTime; 26 | 27 | if (_elapsedTime < Duration) return; 28 | OnComplete?.Invoke(); 29 | } 30 | 31 | public override void OnExit() 32 | { 33 | //... 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/DelayState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd7c4e1bb4a74258a1a0c65ea7d7cb63 3 | timeCreated: 1706572832 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/DelayUnscaledState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph.Attributes; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.StateGraph.States 7 | { 8 | [NodeWidth(width:190)] 9 | [NodeColor(NodeColor.Pink), NodeIcon(NodeIcon.Clock)] 10 | public class DelayUnscaledState : BaseDelayState 11 | { 12 | [Transition] 13 | public event Action OnComplete; 14 | 15 | [NonSerialized] 16 | private float _elapsedTime; 17 | 18 | [Enter] 19 | public override void OnEnter() 20 | { 21 | _elapsedTime = 0f; 22 | } 23 | 24 | public override void OnUpdate() 25 | { 26 | _elapsedTime += Time.unscaledTime; 27 | 28 | if (_elapsedTime >= Duration) 29 | { 30 | OnComplete?.Invoke(); 31 | } 32 | } 33 | 34 | public override void OnExit() 35 | { 36 | 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/DelayUnscaledState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11d2fec47f524b0da9772fb64ad8129a 3 | timeCreated: 1707342576 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/EntryState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph.Attributes; 4 | 5 | namespace Nonatomic.VSM2.StateGraph.States 6 | { 7 | [NodeIcon(NodeIcon.Enter)] 8 | [HideInStateSelector, NodeColor(NodeColor.Green)] 9 | public class EntryState : State 10 | { 11 | [Transition(portColor:NodeColor.Green, frameDelay:0)] 12 | public event Action OnEntry; 13 | 14 | [Enter] 15 | public override void OnEnter() 16 | { 17 | OnEntry?.Invoke(); 18 | } 19 | 20 | public override void OnExit() 21 | { 22 | //.. 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/EntryState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1b46786219545fc8928dcdef8cbfadd 3 | timeCreated: 1705617927 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/ExitState.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph.Attributes; 2 | 3 | namespace Nonatomic.VSM2.StateGraph.States 4 | { 5 | [NodeIcon(NodeIcon.Exit)] 6 | [NodeColor(NodeColor.Red)] 7 | public class ExitState : State 8 | { 9 | [Enter] 10 | public override void OnEnter() 11 | { 12 | StateMachine.Complete(this); 13 | } 14 | 15 | public override void OnExit() 16 | { 17 | 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/ExitState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d8fc6600f1d49c081c7c2be9a87be17 3 | timeCreated: 1706575151 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/JumpId.cs: -------------------------------------------------------------------------------- 1 | namespace Nonatomic.VSM2.StateGraph.States 2 | { 3 | public enum JumpId 4 | { 5 | A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z 6 | } 7 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/JumpId.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a26bbde3a514902b2c737cbe76a90f8 3 | timeCreated: 1706442889 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/JumpInState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | 4 | namespace Nonatomic.VSM2.StateGraph.States 5 | { 6 | public class JumpInState : JumpState 7 | { 8 | [Transition(frameDelay:0)] 9 | public event Action Exit; 10 | 11 | [Enter] 12 | public override void OnEnter() 13 | { 14 | Exit?.Invoke(); 15 | } 16 | 17 | public override void OnExit() 18 | { 19 | 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/JumpInState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f00f4b10b2f5415b912dc5864683742d 3 | timeCreated: 1706442776 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/JumpOutState.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph.Attributes; 2 | 3 | namespace Nonatomic.VSM2.StateGraph.States 4 | { 5 | public class JumpOutState : JumpState 6 | { 7 | [Enter] 8 | public override void OnEnter() 9 | { 10 | StateMachine.JumpTo(this.JumpId); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/JumpOutState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1b11c06ff864651b72e92893be9b746 3 | timeCreated: 1706442757 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/JumpState.cs: -------------------------------------------------------------------------------- 1 | namespace Nonatomic.VSM2.StateGraph.States 2 | { 3 | public abstract class JumpState : State 4 | { 5 | public JumpId JumpId; 6 | 7 | [Enter] 8 | public override void OnEnter() 9 | { 10 | this.StateMachine.JumpTo(this.JumpId); 11 | } 12 | 13 | public override void OnExit() 14 | { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/JumpState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44e88c9989a6474b809bf04c3590c089 3 | timeCreated: 1706442824 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/LogState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph.Attributes; 4 | using UnityEngine; 5 | 6 | namespace Nonatomic.VSM2.StateGraph.States 7 | { 8 | [NodeColor(NodeColor.Blue), NodeIcon(NodeIcon.Note), NodeWidth(400)] 9 | public class LogState : State 10 | { 11 | [Transition] 12 | public event Action Exit; 13 | 14 | [SerializeField, Multiline(3)] 15 | private string _message = "Hello World"; 16 | 17 | [Enter] 18 | public override void OnEnter() 19 | { 20 | Debug.Log(_message); 21 | Exit?.Invoke(); 22 | } 23 | 24 | public override void OnExit() 25 | { 26 | //... 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/LogState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e497804acd3b4f9587271039674b0412 3 | timeCreated: 1706574999 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/ParallelCompletionMode.cs: -------------------------------------------------------------------------------- 1 | namespace Nonatomic.VSM2.StateGraph.States 2 | { 3 | public enum ParallelCompletionMode 4 | { 5 | Any, 6 | All 7 | } 8 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/ParallelCompletionMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 710936d23e8f4ee8b226b83090a05363 3 | timeCreated: 1710658566 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/ParallelSubStateMachineState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using UnityEngine; 4 | 5 | namespace Nonatomic.VSM2.StateGraph.States 6 | { 7 | 8 | public class ParallelSubStateMachineState : BaseParallelSubStateMachineState 9 | { 10 | [Transition] 11 | public event Action OnComplete; 12 | 13 | [SerializeField] protected ParallelCompletionMode CompletionMode = ParallelCompletionMode.Any; 14 | 15 | private int _completionCount; 16 | 17 | [Enter] 18 | public override void OnEnter() 19 | { 20 | _completionCount = 0; 21 | 22 | base.OnEnter(); 23 | } 24 | 25 | protected override void OnSubStateComplete(State state, StateMachineModel model) 26 | { 27 | switch (CompletionMode) 28 | { 29 | case ParallelCompletionMode.Any: 30 | CompletionAnyMode(); 31 | break; 32 | case ParallelCompletionMode.All: 33 | CompletionAllMode(); 34 | break; 35 | } 36 | 37 | base.OnSubStateComplete(state, model); 38 | } 39 | 40 | private void CompletionAllMode() 41 | { 42 | _completionCount++; 43 | if (_completionCount != Models.Count) return; 44 | 45 | OnComplete?.Invoke(); 46 | } 47 | 48 | private void CompletionAnyMode() 49 | { 50 | OnComplete?.Invoke(); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/ParallelSubStateMachineState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e846b7642b7406cb9b87e687c7eea19 3 | timeCreated: 1710264807 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RandomFloatState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using UnityEngine; 4 | using Random = UnityEngine.Random; 5 | 6 | namespace Nonatomic.VSM2.StateGraph.States 7 | { 8 | public class RandomFloatState : State 9 | { 10 | [Transition(frameDelay: 0)] public event Action OnContinueWithValue; 11 | 12 | [SerializeField] private float _min = 0f; 13 | [SerializeField] private float _max = 1f; 14 | 15 | [NonSerialized, Tooltip("Random value between min and max")] 16 | public float RandomValue = 0; 17 | 18 | [Enter] 19 | public override void OnEnter() 20 | { 21 | RandomValue = Random.Range(_min, _max); 22 | OnContinueWithValue?.Invoke(RandomValue); 23 | } 24 | 25 | [Enter] 26 | public void OnEnterWithMin(float value) 27 | { 28 | _min = value; 29 | OnEnter(); 30 | } 31 | 32 | [Enter] 33 | public void OnEnterWithMax(float value) 34 | { 35 | _max = value; 36 | OnEnter(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RandomFloatState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a55d8eb250743a4970945f1aa371787 3 | timeCreated: 1727126601 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RandomIntegerState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using UnityEngine; 4 | using Random = UnityEngine.Random; 5 | 6 | namespace Nonatomic.VSM2.StateGraph.States 7 | { 8 | public class RandomIntegerState : State 9 | { 10 | [Transition(frameDelay: 0)] public event Action OnContinueWithValue; 11 | 12 | [SerializeField] private int _min = 0; 13 | [SerializeField] private int _max = 1; 14 | 15 | [NonSerialized, Tooltip("Random value between min and max")] 16 | public int RandomValue = 0; 17 | 18 | [Enter] 19 | public override void OnEnter() 20 | { 21 | RandomValue = Random.Range(_min, _max + 1); 22 | OnContinueWithValue?.Invoke(RandomValue); 23 | } 24 | 25 | [Enter] 26 | public void OnEnterWithMin(int value) 27 | { 28 | _min = value; 29 | OnEnter(); 30 | } 31 | 32 | [Enter] 33 | public void OnEnterWithMax(int value) 34 | { 35 | _max = value; 36 | OnEnter(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RandomIntegerState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cae2028389d4326b0328240ca239440 3 | timeCreated: 1727126095 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RandomThreeState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph.Attributes; 4 | 5 | namespace Nonatomic.VSM2.StateGraph.States 6 | { 7 | [NodeColor(NodeColor.LightBlue), NodeIcon(NodeIcon.Random)] 8 | public class RandomThreeState : State 9 | { 10 | [Transition] public event Action OnOutcomeA; 11 | [Transition] public event Action OnOutcomeB; 12 | [Transition] public event Action OnOutcomeC; 13 | 14 | private Random _random = new(); 15 | 16 | [Enter] 17 | public override void OnEnter() 18 | { 19 | switch (_random.Next(0, 2)) 20 | { 21 | case 0: 22 | OnOutcomeA?.Invoke(); 23 | break; 24 | case 1: 25 | OnOutcomeB?.Invoke(); 26 | break; 27 | case 2: 28 | OnOutcomeC?.Invoke(); 29 | break; 30 | } 31 | } 32 | 33 | public override void OnExit() 34 | { 35 | //... 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RandomThreeState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb0703bd4dae4765a7ca3e21ffbcb2dc 3 | timeCreated: 1710089696 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RandomTwoState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph.Attributes; 4 | 5 | namespace Nonatomic.VSM2.StateGraph.States 6 | { 7 | [NodeColor(NodeColor.LightBlue), NodeIcon(NodeIcon.Random)] 8 | public class RandomTwoState : State 9 | { 10 | [Transition] public event Action OnOutcomeA; 11 | [Transition] public event Action OnOutcomeB; 12 | 13 | private Random _random = new(); 14 | 15 | [Enter] 16 | public override void OnEnter() 17 | { 18 | switch (_random.Next(0, 1)) 19 | { 20 | case 0: 21 | OnOutcomeA?.Invoke(); 22 | break; 23 | case 1: 24 | OnOutcomeB?.Invoke(); 25 | break; 26 | } 27 | } 28 | 29 | public override void OnExit() 30 | { 31 | //... 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RandomTwoState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 03d8dbcf63474d3190b23f3cdac3907b 3 | timeCreated: 1710089536 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RelayState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph.Attributes; 4 | 5 | namespace Nonatomic.VSM2.StateGraph.States 6 | { 7 | [NodeColor(NodeColor.Blue)] 8 | public class RelayState : State 9 | { 10 | [Transition(frameDelay:0)] public event Action OnComplete; 11 | 12 | [Enter] 13 | public override void OnEnter() 14 | { 15 | OnComplete?.Invoke(); 16 | } 17 | 18 | public override void OnExit() 19 | { 20 | //... 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/RelayState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5461ccc0eee4c42820dbca69a574b7d 3 | timeCreated: 1723505832 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/StickyNoteState.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.StateGraph.Attributes; 2 | using UnityEngine; 3 | 4 | namespace Nonatomic.VSM2.StateGraph.States 5 | { 6 | [NodeIcon(NodeIcon.Post), NodeWidth(200)] 7 | [HideInStateSelector, NodeColor(NodeColor.Cantera)] 8 | public class StickyNoteState : State 9 | { 10 | [SerializeField, Multiline(5)] 11 | private string _note; 12 | 13 | [Enter] 14 | public override void OnEnter() 15 | { 16 | } 17 | 18 | public override void OnExit() 19 | { 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/StickyNoteState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e1ce3f8d6ce4165951ff1bf1d35e0f8 3 | timeCreated: 1722780284 -------------------------------------------------------------------------------- /Runtime/StateGraph/States/SubStateMachineState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | 4 | namespace Nonatomic.VSM2.StateGraph.States 5 | { 6 | public class SubStateMachineState : BaseSubStateMachineState 7 | { 8 | [Transition(frameDelay:0)] 9 | public event Action OnComplete; 10 | 11 | protected override void OnSubStateComplete(State state, StateMachineModel model) 12 | { 13 | base.OnSubStateComplete(state, model); 14 | OnComplete?.Invoke(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Runtime/StateGraph/States/SubStateMachineState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f32c978824f4c9a99c86a716585fc97 3 | timeCreated: 1706575480 -------------------------------------------------------------------------------- /Runtime/StateGraph/Validation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80f5bbe1ae8b4730a353d2f077d05377 3 | timeCreated: 1726609423 -------------------------------------------------------------------------------- /Runtime/StateGraph/Validation/StateMachineValidator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc602ab915cd4f108854fa8ec1e137e8 3 | timeCreated: 1726609436 -------------------------------------------------------------------------------- /Runtime/StateGraph/Validation/StateNodeValidator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19eaf50ecd2544988b1a693b88929c15 3 | timeCreated: 1726609429 -------------------------------------------------------------------------------- /Runtime/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96ccc0cc8cfe454ebecc4aeb8586ae3c 3 | timeCreated: 1703584969 -------------------------------------------------------------------------------- /Runtime/Utils/AssetUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Nonatomic.VSM2.Utils 5 | { 6 | public static class AssetUtils 7 | { 8 | public static List GetAllDerivedTypes() 9 | { 10 | var derivedType = typeof(T); 11 | var derivedTypes = new List(); 12 | var assemblies = AppDomain.CurrentDomain.GetAssemblies(); 13 | 14 | foreach (var assembly in assemblies) 15 | { 16 | var types = assembly.GetTypes(); 17 | foreach (var type in types) 18 | { 19 | if (!type.IsSubclassOf(derivedType)) continue; 20 | derivedTypes.Add(type); 21 | } 22 | } 23 | 24 | return derivedTypes; 25 | } 26 | 27 | public static List FindAllDerivedTypes() 28 | { 29 | var derivedType = typeof(T); 30 | var assemblies = AppDomain.CurrentDomain.GetAssemblies(); 31 | var derivedTypes = new List(); 32 | 33 | foreach (var assembly in assemblies) 34 | { 35 | var types = assembly.GetTypes(); 36 | foreach (var type in types) 37 | { 38 | if (derivedType.IsAssignableFrom(type) && type != derivedType) 39 | { 40 | derivedTypes.Add(type); 41 | } 42 | } 43 | } 44 | 45 | return derivedTypes; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Runtime/Utils/AssetUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39f9fa0c7334427aa5d398ae0f6c275a 3 | timeCreated: 1703584982 -------------------------------------------------------------------------------- /Runtime/Utils/AttributeUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Nonatomic.VSM2.Utils 5 | { 6 | public static class AttributeUtils 7 | { 8 | public static T GetInheritedCustomAttribute(Type type) where T : Attribute 9 | { 10 | T attribute = null; 11 | 12 | while (type != null && attribute == null) 13 | { 14 | attribute = type.GetCustomAttribute(); 15 | type = type.BaseType; 16 | } 17 | 18 | return attribute; 19 | } 20 | 21 | public static bool TryGetInheritedCustomAttribute(Type type, out T attribute) where T : Attribute 22 | { 23 | attribute = null; 24 | 25 | while (type != null && attribute == null) 26 | { 27 | attribute = type.GetCustomAttribute(); 28 | type = type.BaseType; 29 | } 30 | 31 | return attribute != null; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Runtime/Utils/AttributeUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b991fbb499114a2898e2cbc837ee2127 3 | timeCreated: 1706045904 -------------------------------------------------------------------------------- /Runtime/Utils/ColorUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a36b8f44e484ef382f4325caa494c8b 3 | timeCreated: 1706444689 -------------------------------------------------------------------------------- /Runtime/Utils/GuardUtils.cs: -------------------------------------------------------------------------------- 1 | using Nonatomic.VSM2.Logging; 2 | using UnityEngine; 3 | 4 | namespace Nonatomic.VSM2.Utils 5 | { 6 | public static class GuardUtils 7 | { 8 | public static bool GuardAgainstRuntimeOperation(string errorMessage = "Cannot perform this operation at runtime") 9 | { 10 | if (!Application.isPlaying) return false; 11 | 12 | GraphLog.LogError(errorMessage); 13 | return true; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Utils/GuardUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac5e0d18ff4145b3b1ec3d0d788f5214 3 | timeCreated: 1704752236 -------------------------------------------------------------------------------- /Runtime/Utils/ReflectionUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Nonatomic.VSM2.Utils 4 | { 5 | public static class ReflectionUtils 6 | { 7 | public static int GetMethodIndexInType(MethodInfo methodInfo) 8 | { 9 | if (methodInfo.DeclaringType == null) return -1; 10 | 11 | // Get all methods declared in the type (including private and public) 12 | var methods = methodInfo.DeclaringType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); 13 | 14 | // Find the index of the given MethodInfo 15 | for (var i = 0; i < methods.Length; i++) 16 | { 17 | if (methods[i] == methodInfo) 18 | { 19 | return i; 20 | } 21 | } 22 | 23 | // Return -1 if the method is not found 24 | return -1; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Runtime/Utils/ReflectionUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10e918309fc348298d9772276c633df5 3 | timeCreated: 1726603004 -------------------------------------------------------------------------------- /Runtime/Utils/StringUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Text.RegularExpressions; 4 | 5 | namespace Nonatomic.VSM2.Utils 6 | { 7 | public static class StringUtils 8 | { 9 | public static string RemoveStateSuffix(string title) 10 | { 11 | if (title.Length < 5) return title; 12 | return !title.EndsWith("State", StringComparison.OrdinalIgnoreCase) 13 | ? title : 14 | title[..^5]; 15 | } 16 | 17 | public static string RemoveOnSuffix(string title) 18 | { 19 | if (title.Length < 2) return title; 20 | return !title.StartsWith("On", StringComparison.OrdinalIgnoreCase) 21 | ? title 22 | : title[2..]; 23 | } 24 | 25 | public static string ApplyEllipsis(string text, int maxLength) 26 | { 27 | if (maxLength - 3 < 0 || maxLength - 3 > text.Length) return text; 28 | 29 | return text.Length <= maxLength 30 | ? text 31 | : text[..(maxLength - 3)] + "..."; 32 | } 33 | 34 | public static string PascalCaseToTitleCase(string pascalCaseString) 35 | { 36 | var withSpaces = Regex.Replace(pascalCaseString, "(\\B[A-Z])", " $1"); 37 | var textInfo = CultureInfo.CurrentCulture.TextInfo; 38 | 39 | return textInfo.ToTitleCase(withSpaces); 40 | } 41 | 42 | public static int FindLevenshteinDistance(string s, string t) 43 | { 44 | var n = s.Length; 45 | var m = t.Length; 46 | var d = new int[n + 1, m + 1]; 47 | 48 | if (n == 0) return m; 49 | if (m == 0) return n; 50 | 51 | for (var i = 0; i <= n; d[i, 0] = i++) { } 52 | for (var j = 0; j <= m; d[0, j] = j++) { } 53 | 54 | for (var i = 1; i <= n; i++) 55 | { 56 | for (var j = 1; j <= m; j++) 57 | { 58 | var cost = (t[j - 1] == s[i - 1]) ? 0 : 1; 59 | d[i, j] = Math.Min(Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1), d[i - 1, j - 1] + cost); 60 | } 61 | } 62 | 63 | return d[n, m]; 64 | } 65 | 66 | public static string ProcessPortName(string portName) 67 | { 68 | portName = RemoveOnSuffix(portName); 69 | portName = PascalCaseToTitleCase(portName); 70 | portName = ApplyEllipsis(portName, 30); 71 | 72 | return portName; 73 | } 74 | 75 | public static string ProcessNodeTitle(string title) 76 | { 77 | title = PascalCaseToTitleCase(title); 78 | title = RemoveStateSuffix(title); 79 | title = ApplyEllipsis(title, 30); 80 | 81 | return title; 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /Runtime/Utils/StringUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99b55fa793084591b2845a8f6e0a88e3 3 | timeCreated: 1704245591 -------------------------------------------------------------------------------- /Runtime/Utils/SubAssetUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b438f143c894181bd5ad7af92982dc5 3 | timeCreated: 1703753064 -------------------------------------------------------------------------------- /Runtime/Utils/SubAssetValidator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba966941241f4f169dd3a7adfc77bfb8 3 | timeCreated: 1703755289 -------------------------------------------------------------------------------- /Runtime/com.nonatomic.vsm2.runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.nonatomic.vsm2.runtime", 3 | "rootNamespace": "Nonatomic.VSM2", 4 | "references": [ 5 | "com.nonatomic.scriptablecommands.runtime" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": true, 11 | "precompiledReferences": [], 12 | "autoReferenced": false, 13 | "defineConstraints": [], 14 | "versionDefines": [ 15 | { 16 | "name": "com.nonatomic.scriptablecommands", 17 | "expression": "", 18 | "define": "SCRIPTABLE_COMMANDS" 19 | } 20 | ], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /Runtime/com.nonatomic.vsm2.runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52e31b26fd08a6741864360bf0c7822e 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Animation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76d8a0f30aaf96e4894e060560f45497 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Animation/Content.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04f089891660f6243b41cac14985d3c6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Animation/Content/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63e29d345cf44ab4b9488ec9f7de37df 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Animation/Content/Materials/Cube.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b60e9287ac7d2b04a94cb02e8a745c16 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Animation/Content/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d5cfa07cdb629b46884ba299be6dac9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Animation/Content/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2f98d18cb472634ab0f046d3392d51f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Animation/Content/Scenes/Animation.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6554b5bb4ff3eeb4c8b4d6ef1eb7c95d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Animation/Content/StateMachines.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d57229252fb1c8459f322c36a5a1b8e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Animation/Content/StateMachines/AnimationState.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92ad3b7ffea363249bb7af5bc29edfb7 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Animation/Source.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1e6b5204b82258408a69f687472448c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Animation/Source/AnimationController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Assertions; 4 | 5 | namespace Samples.Animation.Source 6 | { 7 | public class AnimationController : MonoBehaviour 8 | { 9 | public event Action OnLeftClick; 10 | public event Action OnRightClick; 11 | 12 | public Vector3 Scale => _cube.localScale; 13 | public Vector3 Position => _cube.position; 14 | public Vector3 LocalPosition => _cube.localPosition; 15 | 16 | [SerializeField] private Transform _cube; 17 | 18 | private RaycastHit _hit; 19 | private Camera _camera; 20 | 21 | private void Start() 22 | { 23 | _camera = Camera.main; 24 | Assert.IsNotNull(_camera); 25 | } 26 | 27 | public void Awake() 28 | { 29 | Assert.IsNotNull(_cube); 30 | } 31 | 32 | public void RotateCube(Vector3 axis, float angle, Space space) 33 | { 34 | _cube.Rotate(axis, angle, space); 35 | } 36 | 37 | public void ScaleCube(Vector3 scale) 38 | { 39 | _cube.localScale = scale; 40 | } 41 | 42 | public void MoveCube(Vector3 position, Space space) 43 | { 44 | switch (space) 45 | { 46 | case Space.World: 47 | _cube.position = position; 48 | break; 49 | case Space.Self: 50 | _cube.localPosition = position; 51 | break; 52 | } 53 | } 54 | 55 | public void Update() 56 | { 57 | CheckForClick(0); 58 | CheckForClick(1); 59 | } 60 | 61 | private void CheckForClick(int button) 62 | { 63 | if (!Input.GetMouseButtonDown(button)) return; 64 | 65 | var ray = _camera.ScreenPointToRay(Input.mousePosition); 66 | 67 | if (!Physics.Raycast(ray, out _hit)) return; 68 | if (_hit.transform != _cube) return; 69 | 70 | switch (button) 71 | { 72 | case 0: 73 | OnLeftClick?.Invoke(); 74 | break; 75 | case 1: 76 | OnRightClick?.Invoke(); 77 | break; 78 | } 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /Samples~/Animation/Source/AnimationController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3a9716b51014067b869dbf98ba4b370 3 | timeCreated: 1707345802 -------------------------------------------------------------------------------- /Samples~/Animation/Source/States.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e60cd7a64f050b4478fba5eb494ba475 3 | timeCreated: 1707078807 4 | -------------------------------------------------------------------------------- /Samples~/Animation/Source/States/MoveState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph; 4 | using UnityEngine; 5 | 6 | namespace Samples.Animation.Source.States 7 | { 8 | public class MoveState : State 9 | { 10 | [Transition] 11 | public event Action OnLeftClick; 12 | 13 | [Transition] 14 | public event Action OnRightClick; 15 | 16 | [SerializeField] private float _moveSpeed = 1.0f; 17 | [SerializeField] private float _maxHeight = 2.0f; 18 | [SerializeField] private float _minHeight = 0.5f; 19 | 20 | private AnimationController _animController; 21 | private float _time; 22 | private Vector3 _basePosition; 23 | 24 | public override void OnEnter() 25 | { 26 | _animController = GameObject.GetComponent(); 27 | _animController.OnLeftClick += HandleLeftClick; 28 | _animController.OnRightClick += HandleRightClick; 29 | _basePosition = _animController.LocalPosition; 30 | } 31 | 32 | public override void OnUpdate() 33 | { 34 | _time += Time.deltaTime * _moveSpeed; 35 | var sin = Mathf.Sin(_time); 36 | var height = (sin + 1) / 2 * (_maxHeight - _minHeight) + _minHeight; 37 | var position = _basePosition; 38 | position.y = height; 39 | 40 | _animController.MoveCube(position, Space.Self); 41 | } 42 | 43 | public override void OnExit() 44 | { 45 | _animController.OnLeftClick -= HandleLeftClick; 46 | _animController.OnRightClick -= HandleRightClick; 47 | } 48 | 49 | private void HandleLeftClick() => OnLeftClick?.Invoke(); 50 | private void HandleRightClick() => OnRightClick?.Invoke(); 51 | } 52 | } -------------------------------------------------------------------------------- /Samples~/Animation/Source/States/MoveState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38e4d2793fea49bf80742e4bba7eb967 3 | timeCreated: 1707349281 -------------------------------------------------------------------------------- /Samples~/Animation/Source/States/RotateState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph; 4 | using UnityEngine; 5 | 6 | namespace Samples.Animation.Source.States 7 | { 8 | public class RotateState : State 9 | { 10 | [Transition] 11 | public event Action OnLeftClick; 12 | 13 | [Transition] 14 | public event Action OnRightClick; 15 | 16 | [SerializeField] private Vector3 _axis; 17 | [SerializeField] private float _angle; 18 | [SerializeField] private Space _space; 19 | 20 | private AnimationController _animController; 21 | private float _time; 22 | 23 | public override void OnEnter() 24 | { 25 | _time = Time.time; 26 | _animController = GameObject.GetComponent(); 27 | _animController.OnLeftClick += HandleLeftClick; 28 | _animController.OnRightClick += HandleRightClick; 29 | } 30 | 31 | public override void OnUpdate() 32 | { 33 | _animController.RotateCube(_axis, _angle * Time.deltaTime, _space); 34 | } 35 | 36 | public override void OnExit() 37 | { 38 | _animController.OnLeftClick -= HandleLeftClick; 39 | _animController.OnRightClick -= HandleRightClick; 40 | } 41 | 42 | private void HandleLeftClick() => OnLeftClick?.Invoke(); 43 | private void HandleRightClick() => OnRightClick?.Invoke(); 44 | } 45 | } -------------------------------------------------------------------------------- /Samples~/Animation/Source/States/RotateState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae191f285fb046f4838a3b0d809a567e 3 | timeCreated: 1707346220 -------------------------------------------------------------------------------- /Samples~/Animation/Source/States/ScaleState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nonatomic.VSM2.NodeGraph; 3 | using Nonatomic.VSM2.StateGraph; 4 | using UnityEngine; 5 | 6 | namespace Samples.Animation.Source.States 7 | { 8 | public class ScaleState : State 9 | { 10 | [Transition] 11 | public event Action LeftClick; 12 | 13 | [Transition] 14 | public event Action RightClick; 15 | 16 | [SerializeField] private float _scaleSpeed = 1.0f; 17 | [SerializeField] private float _maxScale = 2.0f; 18 | [SerializeField] private float _minScale = 0.5f; 19 | 20 | private AnimationController _animController; 21 | private float _time; 22 | private Vector3 _baseScale; 23 | 24 | public override void OnEnter() 25 | { 26 | _animController = GameObject.GetComponent(); 27 | _animController.OnLeftClick += HandleLeftClick; 28 | _animController.OnRightClick += HandleRightClick; 29 | _baseScale = _animController.Scale; 30 | } 31 | 32 | public override void OnUpdate() 33 | { 34 | _time += Time.deltaTime * _scaleSpeed; 35 | var sin = Mathf.Sin(_time); 36 | var scaleFactor = (sin + 1) / 2 * (_maxScale - _minScale) + _minScale; 37 | 38 | _animController.ScaleCube(_baseScale * scaleFactor); 39 | } 40 | 41 | public override void OnExit() 42 | { 43 | _animController.OnLeftClick -= HandleLeftClick; 44 | _animController.OnRightClick -= HandleRightClick; 45 | } 46 | 47 | private void HandleLeftClick() => LeftClick?.Invoke(); 48 | private void HandleRightClick() => RightClick?.Invoke(); 49 | } 50 | } -------------------------------------------------------------------------------- /Samples~/Animation/Source/States/ScaleState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75413189dc7f4714aa44cdb033422ed1 3 | timeCreated: 1707347996 -------------------------------------------------------------------------------- /Samples~/Animation/Source/com.nonatomic.vsm2.samples.animation.runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.nonatomic.vsm2.samples.animation.runtime", 3 | "rootNamespace": "", 4 | "references": [ 5 | "com.nonatomic.vsm2.runtime" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Samples~/Animation/Source/com.nonatomic.vsm2.samples.animation.runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c2751c6f2fc00c4d96529c5162a7f73 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21fbcfef4e39404e950ae96393f897fc 3 | timeCreated: 1726813380 -------------------------------------------------------------------------------- /Tests/EditMode.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91beac6c5edd4506b994e8079944ee50 3 | timeCreated: 1726813388 -------------------------------------------------------------------------------- /Tests/EditMode/com.nonatomic.vsm2.tests.editmode.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.nonatomic.vsm2.tests.editmode", 3 | "references": [ 4 | "com.unity.test-framework" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Tests/EditMode/com.nonatomic.vsm2.tests.editmode.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8eb8a758de0145eda8439212a0bba9cc 3 | timeCreated: 1726813449 -------------------------------------------------------------------------------- /Tests/PlayMode.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3dbfa3fa84394663914e5111f647da58 3 | timeCreated: 1726813397 -------------------------------------------------------------------------------- /Tests/PlayMode/com.nonatomic.vsm2.tests.playmode.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.nonatomic.vsm2.tests.playmode", 3 | "references": [ 4 | "com.unity.test-framework" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Tests/PlayMode/com.nonatomic.vsm2.tests.playmode.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17d054e8a966411ab40ee79f1ce95b2d 3 | timeCreated: 1726813464 -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.nonatomic.visualstatemachinev2", 3 | "version": "0.10.4-beta", 4 | "displayName": "Visual State Machine V2", 5 | "description": "Visual State Machine V2\n\nIMPORTANT NOTE: If you are upgrading to 0.9.0-beta and above from earlier versions, note that `OnEnter` methods now require an `[Enter]` attribute and that the base `OnEnter` method is no longer abstract but virtual.", 6 | "unity": "2022.3", 7 | "unityRelease": "1f1", 8 | "documentationUrl": "https://github.com/PaulNonatomic/VisualStateMachineV2/blob/develop/README.md", 9 | "changelogUrl": "https://github.com/PaulNonatomic/VisualStateMachineV2/blob/develop/CHANGELOG.md", 10 | "dependencies": { 11 | 12 | }, 13 | "keywords": [ 14 | "Unity", 15 | "Package", 16 | "Visual", 17 | "StateMachine" 18 | ], 19 | "author": { 20 | "name": "Nonatomic", 21 | "email": "paul@nonatomic.co.uk", 22 | "url": "https://nonatomic.co.uk/" 23 | }, 24 | "type": "tool", 25 | "repository": { 26 | "type": "git", 27 | "url": "git@github.com:PaulNonatomic/VisualStateMachineV2.git" 28 | }, 29 | "testables": [ 30 | "com.nonatomic.vsm2.tests.editmode", 31 | "com.nonatomic.vsm2.tests.playmode" 32 | ], 33 | "samples": [ 34 | { 35 | "displayName": "Traffic Light System", 36 | "description": "A Visual Traffic Light State Machine", 37 | "path": "Samples~/TrafficLight" 38 | } 39 | ] 40 | } 41 | 42 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f53a522a1341e2c459c9eac8b96508f9 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------