├── .gitignore
├── .vscode
└── settings.json
├── Assets
├── Global.uss
├── Global.uss.meta
├── Main.uxml
├── Main.uxml.meta
├── Panel Settings.asset
├── Panel Settings.asset.meta
├── Stateless.meta
├── Stateless
│ ├── LICENSE.md
│ ├── LICENSE.md.meta
│ ├── README.md
│ ├── README.md.meta
│ ├── Runtime.meta
│ ├── Runtime
│ │ ├── Stateless.dll
│ │ ├── Stateless.dll.meta
│ │ ├── Stateless.xml
│ │ └── Stateless.xml.meta
│ ├── Samples~
│ │ ├── Animations.meta
│ │ ├── Animations
│ │ │ ├── Chest Close Clip.anim
│ │ │ ├── Chest Close Clip.anim.meta
│ │ │ ├── Chest Open Clip.anim
│ │ │ └── Chest Open Clip.anim.meta
│ │ ├── Example 1.meta
│ │ ├── Example 1
│ │ │ ├── Chest.cs
│ │ │ ├── Chest.cs.meta
│ │ │ ├── Constants.cs
│ │ │ ├── Constants.cs.meta
│ │ │ ├── _Example 1.unity
│ │ │ ├── _Example 1.unity.meta
│ │ │ ├── _Example 1Settings.lighting
│ │ │ └── _Example 1Settings.lighting.meta
│ │ ├── Example 2.meta
│ │ ├── Example 2
│ │ │ ├── Chest.cs
│ │ │ ├── Chest.cs.meta
│ │ │ ├── Constants.cs
│ │ │ ├── Constants.cs.meta
│ │ │ ├── _Example 2.unity
│ │ │ ├── _Example 2.unity.meta
│ │ │ ├── _Example 2Settings.lighting
│ │ │ └── _Example 2Settings.lighting.meta
│ │ ├── Example 3.meta
│ │ ├── Example 3
│ │ │ ├── Chest.cs
│ │ │ ├── Chest.cs.meta
│ │ │ ├── ChestAnimation.cs
│ │ │ ├── ChestAnimation.cs.meta
│ │ │ ├── Constants.cs
│ │ │ ├── Constants.cs.meta
│ │ │ ├── _Example 3.unity
│ │ │ ├── _Example 3.unity.meta
│ │ │ ├── _Example 3Settings.lighting
│ │ │ └── _Example 3Settings.lighting.meta
│ │ ├── Example 4.meta
│ │ ├── Example 4
│ │ │ ├── Chest.cs
│ │ │ ├── Chest.cs.meta
│ │ │ ├── ChestAnimation.cs
│ │ │ ├── ChestAnimation.cs.meta
│ │ │ ├── Constants.cs
│ │ │ ├── Constants.cs.meta
│ │ │ ├── IInteractable.cs
│ │ │ ├── IInteractable.cs.meta
│ │ │ ├── InputMonitor.cs
│ │ │ ├── InputMonitor.cs.meta
│ │ │ ├── InteractionMonitor.cs
│ │ │ ├── InteractionMonitor.cs.meta
│ │ │ ├── _Example 4.unity
│ │ │ ├── _Example 4.unity.meta
│ │ │ ├── _Example 4Settings.lighting
│ │ │ └── _Example 4Settings.lighting.meta
│ │ ├── Player.meta
│ │ └── Player
│ │ │ ├── PlayerBase.cs
│ │ │ └── PlayerBase.cs.meta
│ ├── package.json
│ └── package.json.meta
├── UI Toolkit.meta
├── UI Toolkit
│ ├── UnityThemes.meta
│ └── UnityThemes
│ │ ├── UnityDefaultRuntimeTheme.tss
│ │ └── UnityDefaultRuntimeTheme.tss.meta
├── UniRx.meta
├── UniRx
│ ├── MessageBroker.meta
│ ├── MessageBroker
│ │ ├── Gbros.UniRx.MessageBroker.asmdef
│ │ ├── Gbros.UniRx.MessageBroker.asmdef.meta
│ │ ├── LICENSE.md
│ │ ├── LICENSE.md.meta
│ │ ├── README.md
│ │ ├── README.md.meta
│ │ ├── Samples~
│ │ │ ├── Example 1.meta
│ │ │ ├── Example 1
│ │ │ │ ├── ColorDisplay.cs
│ │ │ │ ├── ColorDisplay.cs.meta
│ │ │ │ ├── ColorGenerator.cs
│ │ │ │ ├── ColorGenerator.cs.meta
│ │ │ │ ├── ColorSwitchMessage.cs
│ │ │ │ ├── ColorSwitchMessage.cs.meta
│ │ │ │ ├── ColorSwitcher.cs
│ │ │ │ ├── ColorSwitcher.cs.meta
│ │ │ │ ├── Constants.cs
│ │ │ │ ├── Constants.cs.meta
│ │ │ │ ├── _Example 1.unity
│ │ │ │ └── _Example 1.unity.meta
│ │ │ ├── Example 2.meta
│ │ │ ├── Example 2
│ │ │ │ ├── ColorDisplay.cs
│ │ │ │ ├── ColorDisplay.cs.meta
│ │ │ │ ├── ColorGenerator.cs
│ │ │ │ ├── ColorGenerator.cs.meta
│ │ │ │ ├── ColorSwitchMessage.asset
│ │ │ │ ├── ColorSwitchMessage.asset.meta
│ │ │ │ ├── ColorSwitchMessage.cs
│ │ │ │ ├── ColorSwitchMessage.cs.meta
│ │ │ │ ├── ColorSwitchMessageEditor.cs
│ │ │ │ ├── ColorSwitchMessageEditor.cs.meta
│ │ │ │ ├── ColorSwitcher.cs
│ │ │ │ ├── ColorSwitcher.cs.meta
│ │ │ │ ├── Constants.cs
│ │ │ │ ├── Constants.cs.meta
│ │ │ │ ├── _Example 2.unity
│ │ │ │ └── _Example 2.unity.meta
│ │ │ ├── Example 3.meta
│ │ │ ├── Example 3
│ │ │ │ ├── AudioPlayer.cs
│ │ │ │ ├── AudioPlayer.cs.meta
│ │ │ │ ├── Constants.cs
│ │ │ │ ├── Constants.cs.meta
│ │ │ │ ├── Player.cs
│ │ │ │ ├── Player.cs.meta
│ │ │ │ ├── Zone.cs
│ │ │ │ ├── Zone.cs.meta
│ │ │ │ ├── ZoneDisplay.cs
│ │ │ │ ├── ZoneDisplay.cs.meta
│ │ │ │ ├── ZoneEnterMessage.asset
│ │ │ │ ├── ZoneEnterMessage.asset.meta
│ │ │ │ ├── ZoneEnterMessage.cs
│ │ │ │ ├── ZoneEnterMessage.cs.meta
│ │ │ │ ├── ZoneType.cs
│ │ │ │ ├── ZoneType.cs.meta
│ │ │ │ ├── _Example 3.unity
│ │ │ │ └── _Example 3.unity.meta
│ │ │ ├── Example 4.meta
│ │ │ ├── Example 4
│ │ │ │ ├── ActivateOnGameEvent.cs
│ │ │ │ ├── ActivateOnGameEvent.cs.meta
│ │ │ │ ├── Constants.cs
│ │ │ │ ├── Constants.cs.meta
│ │ │ │ ├── Dragon GameEventMessage.asset
│ │ │ │ ├── Dragon GameEventMessage.asset.meta
│ │ │ │ ├── GameEventMessage.asset
│ │ │ │ ├── GameEventMessage.asset.meta
│ │ │ │ ├── GameEventMessage.cs
│ │ │ │ ├── GameEventMessage.cs.meta
│ │ │ │ ├── GameManager.cs
│ │ │ │ ├── GameManager.cs.meta
│ │ │ │ ├── GameStartMessage.asset
│ │ │ │ ├── GameStartMessage.asset.meta
│ │ │ │ ├── GameStartMessage.cs
│ │ │ │ ├── GameStartMessage.cs.meta
│ │ │ │ ├── _Example 4.unity
│ │ │ │ └── _Example 4.unity.meta
│ │ │ ├── Player.meta
│ │ │ └── Player
│ │ │ │ ├── PlayerBase.cs
│ │ │ │ └── PlayerBase.cs.meta
│ │ ├── Scripts.meta
│ │ ├── Scripts
│ │ │ ├── IMessage.cs
│ │ │ ├── IMessage.cs.meta
│ │ │ ├── Message.cs
│ │ │ ├── Message.cs.meta
│ │ │ ├── MessageBrokerExtensions.cs
│ │ │ ├── MessageBrokerExtensions.cs.meta
│ │ │ ├── MessageEditor.cs
│ │ │ ├── MessageEditor.cs.meta
│ │ │ ├── Utilities.meta
│ │ │ └── Utilities
│ │ │ │ ├── ActivateOnMessage.cs
│ │ │ │ └── ActivateOnMessage.cs.meta
│ │ ├── package.json
│ │ └── package.json.meta
│ ├── PowerObservables.meta
│ └── PowerObservables
│ │ ├── Gbros.UniRx.PowerObservables.asmdef
│ │ ├── Gbros.UniRx.PowerObservables.asmdef.meta
│ │ ├── LICENSE.md
│ │ ├── LICENSE.md.meta
│ │ ├── README.md
│ │ ├── README.md.meta
│ │ ├── Samples~
│ │ ├── Example 1.meta
│ │ ├── Example 1
│ │ │ ├── Constants.cs
│ │ │ ├── Constants.cs.meta
│ │ │ ├── CountedInterval.cs
│ │ │ ├── CountedInterval.cs.meta
│ │ │ ├── _Example 1.unity
│ │ │ └── _Example 1.unity.meta
│ │ ├── Example 2.meta
│ │ └── Example 2
│ │ │ ├── Constants.cs
│ │ │ ├── Constants.cs.meta
│ │ │ ├── Countdown.cs
│ │ │ ├── Countdown.cs.meta
│ │ │ ├── _Example 2.unity
│ │ │ └── _Example 2.unity.meta
│ │ ├── Scripts.meta
│ │ ├── Scripts
│ │ ├── Countdown.cs
│ │ ├── Countdown.cs.meta
│ │ ├── CountedInterval.cs
│ │ ├── CountedInterval.cs.meta
│ │ ├── ObservableExtensions.cs
│ │ ├── ObservableExtensions.cs.meta
│ │ ├── PausableInterval.cs
│ │ ├── PausableInterval.cs.meta
│ │ ├── PowerObservable.cs
│ │ ├── PowerObservable.cs.meta
│ │ ├── TimerCountedInterval.cs
│ │ ├── TimerCountedInterval.cs.meta
│ │ ├── TimerInterval.cs
│ │ └── TimerInterval.cs.meta
│ │ ├── package.json
│ │ └── package.json.meta
├── Watchers.meta
└── Watchers
│ ├── Editor.meta
│ ├── Editor
│ ├── Extensions.meta
│ ├── Extensions
│ │ ├── ExpressionExtensions.cs
│ │ ├── ExpressionExtensions.cs.meta
│ │ ├── UIElementsExtensions.cs
│ │ ├── UIElementsExtensions.cs.meta
│ │ ├── UIElementsFunctionPropertyExtensions.cs
│ │ ├── UIElementsFunctionPropertyExtensions.cs.meta
│ │ ├── UIElementsObservablePropertyExtensions.cs
│ │ ├── UIElementsObservablePropertyExtensions.cs.meta
│ │ ├── UIElementsPropertyBindingExtensions.cs
│ │ ├── UIElementsPropertyBindingExtensions.cs.meta
│ │ ├── Utilities.cs
│ │ ├── Utilities.cs.meta
│ │ ├── WatcherExtensions.cs
│ │ ├── WatcherExtensions.cs.meta
│ │ ├── WatcherUIElementsFunctionPropertyExtensions.cs
│ │ ├── WatcherUIElementsFunctionPropertyExtensions.cs.meta
│ │ ├── WatcherUIElementsObservablePropertyExtensions.cs
│ │ ├── WatcherUIElementsObservablePropertyExtensions.cs.meta
│ │ ├── WatcherUIElementsSerializedPropertyExtensions.cs
│ │ └── WatcherUIElementsSerializedPropertyExtensions.cs.meta
│ ├── IWatcherElement.cs
│ ├── IWatcherElement.cs.meta
│ ├── Watcher.cs
│ ├── Watcher.cs.meta
│ ├── WatcherBoard.cs
│ ├── WatcherBoard.cs.meta
│ ├── WatcherCard.cs
│ ├── WatcherCard.cs.meta
│ ├── WatcherCardContainer.cs
│ ├── WatcherCardContainer.cs.meta
│ ├── WatcherEditor.cs
│ ├── WatcherEditor.cs.meta
│ ├── WatcherEditor.uss
│ ├── WatcherEditor.uss.meta
│ ├── WatcherEditor.uxml
│ ├── WatcherEditor.uxml.meta
│ ├── WatcherSelector.cs
│ ├── WatcherSelector.cs.meta
│ ├── WatcherSplitView.cs
│ ├── WatcherSplitView.cs.meta
│ ├── Watchers.cs
│ └── Watchers.cs.meta
│ ├── Examples.meta
│ ├── Examples~
│ ├── Example 1.meta
│ └── Example 1
│ │ ├── Constants.cs
│ │ ├── Constants.cs.meta
│ │ ├── SomeComponent.cs
│ │ ├── SomeComponent.cs.meta
│ │ ├── _Example 1.unity
│ │ └── _Example 1.unity.meta
│ ├── Gbros.Watchers.asmdef
│ ├── Gbros.Watchers.asmdef.meta
│ ├── LICENSE.md
│ ├── LICENSE.md.meta
│ ├── README.md
│ ├── README.md.meta
│ ├── package.json
│ └── package.json.meta
├── LICENSE
├── Packages
├── manifest.json
└── packages-lock.json
├── ProjectSettings
├── AudioManager.asset
├── ClusterInputManager.asset
├── DynamicsManager.asset
├── EditorBuildSettings.asset
├── EditorSettings.asset
├── GraphicsSettings.asset
├── InputManager.asset
├── MemorySettings.asset
├── NavMeshAreas.asset
├── PackageManagerSettings.asset
├── Physics2DSettings.asset
├── PresetManager.asset
├── ProjectSettings.asset
├── ProjectVersion.txt
├── QualitySettings.asset
├── SceneTemplateSettings.json
├── TagManager.asset
├── TimeManager.asset
├── UnityConnectSettings.asset
├── VFXManager.asset
└── VersionControlSettings.asset
├── README.md
├── UIElementsSchema
├── GlobalNamespace.xsd
├── UIElements.xsd
├── Unity.Profiling.Editor.xsd
├── Unity.UI.Builder.xsd
├── UnityEditor.Experimental.GraphView.xsd
├── UnityEditor.Overlays.xsd
├── UnityEditor.PackageManager.UI.Internal.xsd
├── UnityEditor.Search.xsd
├── UnityEditor.ShortcutManagement.xsd
├── UnityEditor.UIElements.Debugger.xsd
├── UnityEditor.UIElements.xsd
└── UnityEngine.UIElements.xsd
└── UserSettings
└── Layouts
├── CurrentMaximizeLayout.dwlt
├── default-2021.dwlt
└── default-2022.dwlt
/.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/master/Unity.gitignore
4 | #
5 | /[Ll]ibrary/
6 | /[Tt]emp/
7 | /[Oo]bj/
8 | /[Bb]uild/
9 | /[Bb]uilds/
10 | /[Ll]ogs/
11 | /[Mm]emoryCaptures/
12 | /[Uu]ser[Ssettings]/
13 |
14 | # Asset meta data should only be ignored when the corresponding asset is also ignored
15 | !/[Aa]ssets/**/*.meta
16 |
17 | # Uncomment this line if you wish to ignore the asset store tools plugin
18 | # /[Aa]ssets/AssetStoreTools*
19 |
20 | # Autogenerated Jetbrains Rider plugin
21 | [Aa]ssets/Plugins/Editor/JetBrains*
22 |
23 | # Visual Studio cache directory
24 | .vs/
25 |
26 | # Gradle cache directory
27 | .gradle/
28 |
29 | # Autogenerated VS/MD/Consulo solution and project files
30 | ExportedObj/
31 | .consulo/
32 | *.csproj
33 | *.unityproj
34 | *.sln
35 | *.suo
36 | *.tmp
37 | *.user
38 | *.userprefs
39 | *.pidb
40 | *.booproj
41 | *.svd
42 | *.pdb
43 | *.mdb
44 | *.opendb
45 | *.VC.db
46 |
47 | # Unity3D generated meta files
48 | *.pidb.meta
49 | *.pdb.meta
50 | *.mdb.meta
51 |
52 | # Unity3D generated file on crash reports
53 | sysinfo.txt
54 |
55 | # Builds
56 | *.apk
57 | *.unitypackage
58 |
59 | # Crashlytics generated file
60 | crashlytics-build.properties
61 |
62 |
63 | UserSettings/EditorUserSettings.asset
64 | **/[Ss]amples*
65 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.exclude":
3 | {
4 | "**/.DS_Store":true,
5 | "**/.git":true,
6 | "**/.gitignore":true,
7 | "**/.gitmodules":true,
8 | "**/*.booproj":true,
9 | "**/*.pidb":true,
10 | "**/*.suo":true,
11 | "**/*.user":true,
12 | "**/*.userprefs":true,
13 | "**/*.unityproj":true,
14 | "**/*.dll":true,
15 | "**/*.exe":true,
16 | "**/*.pdf":true,
17 | "**/*.mid":true,
18 | "**/*.midi":true,
19 | "**/*.wav":true,
20 | "**/*.gif":true,
21 | "**/*.ico":true,
22 | "**/*.jpg":true,
23 | "**/*.jpeg":true,
24 | "**/*.png":true,
25 | "**/*.psd":true,
26 | "**/*.tga":true,
27 | "**/*.tif":true,
28 | "**/*.tiff":true,
29 | "**/*.3ds":true,
30 | "**/*.3DS":true,
31 | "**/*.fbx":true,
32 | "**/*.FBX":true,
33 | "**/*.lxo":true,
34 | "**/*.LXO":true,
35 | "**/*.ma":true,
36 | "**/*.MA":true,
37 | "**/*.obj":true,
38 | "**/*.OBJ":true,
39 | "**/*.asset":true,
40 | "**/*.cubemap":true,
41 | "**/*.flare":true,
42 | "**/*.mat":true,
43 | "**/*.meta":true,
44 | "**/*.prefab":true,
45 | "**/*.unity":true,
46 | "build/":true,
47 | "Build/":true,
48 | "Library/":true,
49 | "library/":true,
50 | "obj/":true,
51 | "Obj/":true,
52 | "ProjectSettings/":true,
53 | "temp/":true,
54 | "Temp/":true
55 | }
56 | }
--------------------------------------------------------------------------------
/Assets/Global.uss:
--------------------------------------------------------------------------------
1 | Slot {
2 | margin: 5px;
3 | background-color: rgb(9, 19, 21);
4 | border-top-left-radius: 3px;
5 | border-bottom-left-radius: 3px;
6 | border-top-right-radius: 3px;
7 | border-bottom-right-radius: 3px;
8 | }
9 |
10 | Container {
11 | flex-shrink: 0;
12 | flex-grow: 1;
13 | flex-direction: row;
14 | flex-wrap: wrap;
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/Assets/Global.uss.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 88c17a75bbfa3e74d9d4b6c5a175dcf6
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 |
--------------------------------------------------------------------------------
/Assets/Main.uxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Assets/Main.uxml.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d565365729b99f94998d1f46cc995a3f
3 | ScriptedImporter:
4 | internalIDToNameTable: []
5 | externalObjects: {}
6 | serializedVersion: 2
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 | script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
11 |
--------------------------------------------------------------------------------
/Assets/Panel Settings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 19101, guid: 0000000000000000e000000000000000, type: 0}
13 | m_Name: Panel Settings
14 | m_EditorClassIdentifier:
15 | themeUss: {fileID: -4733365628477956816, guid: 3897c7ab566dcdd48971772ad6e15b27, type: 3}
16 | m_TargetTexture: {fileID: 0}
17 | m_ScaleMode: 1
18 | m_Scale: 1
19 | m_ReferenceDpi: 96
20 | m_FallbackDpi: 96
21 | m_ReferenceResolution: {x: 1200, y: 800}
22 | m_ScreenMatchMode: 0
23 | m_Match: 0
24 | m_SortingOrder: 0
25 | m_TargetDisplay: 0
26 | m_ClearDepthStencil: 1
27 | m_ClearColor: 0
28 | m_ColorClearValue: {r: 0, g: 0, b: 0, a: 0}
29 | m_DynamicAtlasSettings:
30 | m_MinAtlasSize: 64
31 | m_MaxAtlasSize: 4096
32 | m_MaxSubTextureSize: 64
33 | m_ActiveFilters: 31
34 | m_AtlasBlitShader: {fileID: 9101, guid: 0000000000000000f000000000000000, type: 0}
35 | m_RuntimeShader: {fileID: 9100, guid: 0000000000000000f000000000000000, type: 0}
36 | m_RuntimeWorldShader: {fileID: 9102, guid: 0000000000000000f000000000000000, type: 0}
37 | textSettings: {fileID: 0}
38 |
--------------------------------------------------------------------------------
/Assets/Panel Settings.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6a51e592ec19a2648a714fe9c4ac9833
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 25cc6b31abec5b347b8a509b7d042ad0
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Gbros Games Studio
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 |
--------------------------------------------------------------------------------
/Assets/Stateless/LICENSE.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 662da728214b82d4bb48db9699cf19c7
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Stateless/README.md:
--------------------------------------------------------------------------------
1 | # [Stateless in Unity](https://www.gbrosgames.com/posts/Stateless-in-Unity)
2 |
3 | Blog post resources of [Stateless](https://github.com/dotnet-state-machine/stateless) library
4 |
5 | ## Package Installation
6 |
7 | Edit manifest.json file in your Unity Packages directory
8 |
9 | ```
10 | {
11 | "dependencies": {
12 | "com.gbros.tools.stateless": "https://github.com/GbrosGames/Tools.git?path=Assets/Stateless"
13 |
14 | }
15 | ```
16 |
17 | Or [install](https://docs.unity3d.com/2020.2/Documentation/Manual/upm-ui-giturl.html) via url
18 |
19 | ```
20 | https://github.com/GbrosGames/Tools.git?path=Assets/Stateless
21 | ```
22 |
23 | ## Examples
24 |
25 | You can import examples inside UnityPackage Menager > Gbros - Stateless
26 |
--------------------------------------------------------------------------------
/Assets/Stateless/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1cc4ee45e125ec34c865185d137ec022
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Stateless/Runtime.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2c51f7287d68ec046bfeee47868f8a64
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Runtime/Stateless.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GbrosGames/Tools/a93912bfdd777bc0e3deb9b6b15f93c960317103/Assets/Stateless/Runtime/Stateless.dll
--------------------------------------------------------------------------------
/Assets/Stateless/Runtime/Stateless.dll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dbf559f88c7feb041aac0b47a8937335
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | defineConstraints: []
9 | isPreloaded: 0
10 | isOverridable: 0
11 | isExplicitlyReferenced: 0
12 | validateReferences: 1
13 | platformData:
14 | - first:
15 | : Any
16 | second:
17 | enabled: 0
18 | settings:
19 | Exclude Editor: 0
20 | Exclude Linux64: 0
21 | Exclude OSXUniversal: 0
22 | Exclude Win: 0
23 | Exclude Win64: 0
24 | - first:
25 | Any:
26 | second:
27 | enabled: 1
28 | settings: {}
29 | - first:
30 | Editor: Editor
31 | second:
32 | enabled: 1
33 | settings:
34 | CPU: AnyCPU
35 | DefaultValueInitialized: true
36 | OS: AnyOS
37 | - first:
38 | Standalone: Linux64
39 | second:
40 | enabled: 1
41 | settings:
42 | CPU: None
43 | - first:
44 | Standalone: OSXUniversal
45 | second:
46 | enabled: 1
47 | settings:
48 | CPU: None
49 | - first:
50 | Standalone: Win
51 | second:
52 | enabled: 1
53 | settings:
54 | CPU: x86
55 | - first:
56 | Standalone: Win64
57 | second:
58 | enabled: 1
59 | settings:
60 | CPU: x86_64
61 | - first:
62 | Windows Store Apps: WindowsStoreApps
63 | second:
64 | enabled: 0
65 | settings:
66 | CPU: AnyCPU
67 | userData:
68 | assetBundleName:
69 | assetBundleVariant:
70 |
--------------------------------------------------------------------------------
/Assets/Stateless/Runtime/Stateless.xml.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ce4a58a989e0c614d8c1ca193797680d
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Animations.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 83077a0a1c3c07441a5301f0f08fc5be
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Animations/Chest Close Clip.anim.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 568202721773c2a46aaa64d33f787e27
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Animations/Chest Open Clip.anim.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 27b38f053a2a000458341e9037862246
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 1.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 01adbf787bb5ed1469f958e01cf7b376
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 1/Chest.cs:
--------------------------------------------------------------------------------
1 | using Stateless;
2 | using UnityEngine;
3 |
4 | namespace Gbros.StatelessSamples.Example1
5 | {
6 | [AddComponentMenu(Constants.ComponentPath + nameof(Chest))]
7 | public class Chest : MonoBehaviour
8 | {
9 | public enum State { Opened, Closed }
10 |
11 | public State CurrentState => stateMachine.State;
12 |
13 | #region SerializedFields
14 | [SerializeField] AnimationClip openClip;
15 | [SerializeField] AnimationClip closeClip;
16 | #endregion SerializedFields
17 |
18 | private StateMachine stateMachine;
19 | private Animation animation;
20 |
21 | private void Awake()
22 | {
23 | animation = GetComponent();
24 |
25 | stateMachine = new StateMachine(State.Closed);
26 |
27 | stateMachine
28 | .Configure(State.Opened)
29 | .OnEntry(OnOpened)
30 | .Permit(KeyCode.Space, State.Closed);
31 |
32 | stateMachine
33 | .Configure(State.Closed)
34 | .OnEntry(OnClosed)
35 | .Permit(KeyCode.Space, State.Opened);
36 | }
37 |
38 | private void Update()
39 | {
40 | if (!Input.GetKeyDown(KeyCode.Space)) return;
41 | ToggleState();
42 | }
43 |
44 | public void ToggleState() => stateMachine.Fire(KeyCode.Space);
45 |
46 | private void OnClosed()
47 | {
48 | animation.clip = closeClip;
49 | animation.Play();
50 | // play close sound
51 | }
52 |
53 | private void OnOpened()
54 | {
55 | animation.clip = openClip;
56 | animation.Play();
57 | // play open sound
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 1/Chest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5bb0fbb8b81ccc74184f5b8baa333ec9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 1/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.StatelessSamples.Example1
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_StatelessSamples/Example 1/";
6 | }
7 | }
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 1/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c94630a1fdba3214ca18bb58a45233c2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 1/_Example 1.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8c2e421413e314049a96702767b776ea
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 1/_Example 1Settings.lighting:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!850595691 &4890085278179872738
4 | LightingSettings:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_Name: _Example 1Settings
10 | serializedVersion: 2
11 | m_GIWorkflowMode: 1
12 | m_EnableBakedLightmaps: 0
13 | m_EnableRealtimeLightmaps: 0
14 | m_RealtimeEnvironmentLighting: 1
15 | m_BounceScale: 1
16 | m_AlbedoBoost: 1
17 | m_IndirectOutputScale: 1
18 | m_UsingShadowmask: 1
19 | m_BakeBackend: 1
20 | m_LightmapMaxSize: 1024
21 | m_BakeResolution: 40
22 | m_Padding: 2
23 | m_TextureCompression: 1
24 | m_AO: 0
25 | m_AOMaxDistance: 1
26 | m_CompAOExponent: 1
27 | m_CompAOExponentDirect: 0
28 | m_ExtractAO: 0
29 | m_MixedBakeMode: 2
30 | m_LightmapsBakeMode: 1
31 | m_FilterMode: 1
32 | m_LightmapParameters: {fileID: 0}
33 | m_ExportTrainingData: 0
34 | m_TrainingDataDestination: TrainingData
35 | m_RealtimeResolution: 2
36 | m_ForceWhiteAlbedo: 0
37 | m_ForceUpdates: 0
38 | m_FinalGather: 0
39 | m_FinalGatherRayCount: 256
40 | m_FinalGatherFiltering: 1
41 | m_PVRCulling: 1
42 | m_PVRSampling: 1
43 | m_PVRDirectSampleCount: 32
44 | m_PVRSampleCount: 512
45 | m_PVREnvironmentSampleCount: 256
46 | m_PVREnvironmentReferencePointCount: 2048
47 | m_LightProbeSampleCountMultiplier: 4
48 | m_PVRBounces: 2
49 | m_PVRRussianRouletteStartBounce: 2
50 | m_PVREnvironmentMIS: 1
51 | m_PVRFilteringMode: 1
52 | m_PVRDenoiserTypeDirect: 1
53 | m_PVRDenoiserTypeIndirect: 1
54 | m_PVRDenoiserTypeAO: 1
55 | m_PVRFilterTypeDirect: 0
56 | m_PVRFilterTypeIndirect: 0
57 | m_PVRFilterTypeAO: 0
58 | m_PVRFilteringGaussRadiusDirect: 1
59 | m_PVRFilteringGaussRadiusIndirect: 5
60 | m_PVRFilteringGaussRadiusAO: 2
61 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
62 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
63 | m_PVRFilteringAtrousPositionSigmaAO: 1
64 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 1/_Example 1Settings.lighting.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b83d41ce68b948d449242ca0b7534163
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 2.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c62b04766116ee04ca8f8997a300f16c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 2/Chest.cs:
--------------------------------------------------------------------------------
1 | using Stateless;
2 | using UnityEngine;
3 |
4 | namespace Gbros.StatelessSamples.Example2
5 | {
6 | [AddComponentMenu(Constants.ComponentPath + nameof(Chest))]
7 | public class Chest : MonoBehaviour
8 | {
9 | public enum State { Opened, Closed }
10 | public enum Trigger { Open, Close }
11 |
12 | private StateMachine stateMachine;
13 | public State CurrentState => stateMachine.State;
14 |
15 | #region SerializedFields
16 | [SerializeField] AnimationClip openClip;
17 | [SerializeField] AnimationClip closeClip;
18 | #endregion SerializedFields
19 |
20 | private Animation animation;
21 |
22 | private void Awake()
23 | {
24 | animation = GetComponent();
25 |
26 | stateMachine = new StateMachine(State.Closed);
27 |
28 | stateMachine
29 | .Configure(State.Opened)
30 | .OnEntry(OnOpened)
31 | .Permit(Trigger.Close, State.Closed);
32 |
33 | stateMachine
34 | .Configure(State.Closed)
35 | .OnEntry(OnClosed)
36 | .Permit(Trigger.Open, State.Opened);
37 | }
38 |
39 | private void Update()
40 | {
41 | if (Input.GetMouseButtonDown(0))
42 | {
43 | Open();
44 | return;
45 | }
46 |
47 | if (Input.GetMouseButtonDown(1))
48 | {
49 | Close();
50 | return;
51 | }
52 | }
53 |
54 | public void Open()
55 | {
56 | if (!stateMachine.CanFire(Trigger.Open)) return;
57 | stateMachine.Fire(Trigger.Open);
58 | }
59 | public void Close()
60 | {
61 | if (!stateMachine.CanFire(Trigger.Close)) return;
62 | stateMachine.Fire(Trigger.Close);
63 | }
64 |
65 | private void OnClosed()
66 | {
67 | animation.clip = closeClip;
68 | animation.Play();
69 | // play close sound
70 | }
71 |
72 | private void OnOpened()
73 | {
74 | animation.clip = openClip;
75 | animation.Play();
76 | // play open sound
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 2/Chest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 916eeb54bca61ca4baa5e3a08a57fd54
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 2/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.StatelessSamples.Example2
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_StatelessSamples/Example 2/";
6 | }
7 | }
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 2/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: adedc27ce3ff658478d7240acecd2aea
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 2/_Example 2.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 22e30e9197d56bb4e9a1a9ad7731c952
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 2/_Example 2Settings.lighting:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!850595691 &4890085278179872738
4 | LightingSettings:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_Name: _Example 2Settings
10 | serializedVersion: 2
11 | m_GIWorkflowMode: 1
12 | m_EnableBakedLightmaps: 0
13 | m_EnableRealtimeLightmaps: 0
14 | m_RealtimeEnvironmentLighting: 1
15 | m_BounceScale: 1
16 | m_AlbedoBoost: 1
17 | m_IndirectOutputScale: 1
18 | m_UsingShadowmask: 1
19 | m_BakeBackend: 1
20 | m_LightmapMaxSize: 1024
21 | m_BakeResolution: 40
22 | m_Padding: 2
23 | m_TextureCompression: 1
24 | m_AO: 0
25 | m_AOMaxDistance: 1
26 | m_CompAOExponent: 1
27 | m_CompAOExponentDirect: 0
28 | m_ExtractAO: 0
29 | m_MixedBakeMode: 2
30 | m_LightmapsBakeMode: 1
31 | m_FilterMode: 1
32 | m_LightmapParameters: {fileID: 0}
33 | m_ExportTrainingData: 0
34 | m_TrainingDataDestination: TrainingData
35 | m_RealtimeResolution: 2
36 | m_ForceWhiteAlbedo: 0
37 | m_ForceUpdates: 0
38 | m_FinalGather: 0
39 | m_FinalGatherRayCount: 256
40 | m_FinalGatherFiltering: 1
41 | m_PVRCulling: 1
42 | m_PVRSampling: 1
43 | m_PVRDirectSampleCount: 32
44 | m_PVRSampleCount: 512
45 | m_PVREnvironmentSampleCount: 256
46 | m_PVREnvironmentReferencePointCount: 2048
47 | m_LightProbeSampleCountMultiplier: 4
48 | m_PVRBounces: 2
49 | m_PVRRussianRouletteStartBounce: 2
50 | m_PVREnvironmentMIS: 1
51 | m_PVRFilteringMode: 1
52 | m_PVRDenoiserTypeDirect: 1
53 | m_PVRDenoiserTypeIndirect: 1
54 | m_PVRDenoiserTypeAO: 1
55 | m_PVRFilterTypeDirect: 0
56 | m_PVRFilterTypeIndirect: 0
57 | m_PVRFilterTypeAO: 0
58 | m_PVRFilteringGaussRadiusDirect: 1
59 | m_PVRFilteringGaussRadiusIndirect: 5
60 | m_PVRFilteringGaussRadiusAO: 2
61 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
62 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
63 | m_PVRFilteringAtrousPositionSigmaAO: 1
64 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 2/_Example 2Settings.lighting.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bf3d5eb7b5d2b7844bbc90d2c47926f9
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: aefd9da3c72097445b83846cb4c32e53
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3/Chest.cs:
--------------------------------------------------------------------------------
1 | using Stateless;
2 | using System;
3 | using UnityEngine;
4 |
5 | namespace Gbros.StatelessSamples.Example3
6 | {
7 | [AddComponentMenu(Constants.ComponentPath + nameof(Chest))]
8 | public class Chest : MonoBehaviour
9 | {
10 | public enum State { Opened, Closed }
11 | public enum Trigger { Open, Close }
12 |
13 | public State CurrentState => stateMachine.State;
14 |
15 | public event Action Opened;
16 | public event Action Closed;
17 |
18 | private StateMachine stateMachine;
19 |
20 | private void Awake()
21 | {
22 | stateMachine = new StateMachine(State.Closed);
23 |
24 | stateMachine
25 | .Configure(State.Opened)
26 | .OnEntry(OnChestOpened)
27 | .Permit(Trigger.Close, State.Closed);
28 |
29 | stateMachine
30 | .Configure(State.Closed)
31 | .OnEntry(OnChestClosed)
32 | .Permit(Trigger.Open, State.Opened);
33 | }
34 |
35 | private void Update()
36 | {
37 | if (Input.GetMouseButtonDown(0))
38 | {
39 | Open();
40 | return;
41 | }
42 |
43 | if (Input.GetMouseButtonDown(1))
44 | {
45 | Close();
46 | return;
47 | }
48 | }
49 |
50 | public void Open()
51 | {
52 | if (!stateMachine.CanFire(Trigger.Open)) return;
53 | stateMachine.Fire(Trigger.Open);
54 | }
55 | public void Close()
56 | {
57 | if (!stateMachine.CanFire(Trigger.Close)) return;
58 | stateMachine.Fire(Trigger.Close);
59 | }
60 |
61 | private void OnChestClosed() => Closed?.Invoke();
62 | private void OnChestOpened() => Opened?.Invoke();
63 | }
64 | }
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3/Chest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7ef683fbe0b0bdd4a86a4418e48b35d7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3/ChestAnimation.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace Gbros.StatelessSamples.Example3
4 | {
5 | [AddComponentMenu(Constants.ComponentPath + nameof(ChestAnimation))]
6 | [RequireComponent(typeof(Chest))]
7 | public class ChestAnimation : MonoBehaviour
8 | {
9 | #region SerializedFields
10 | [SerializeField] AnimationClip chestOpenClip;
11 | [SerializeField] AnimationClip chestCloseClip;
12 | #endregion SerializedFields
13 |
14 | private Chest chest;
15 | private Animation animation;
16 |
17 | private void Awake()
18 | {
19 | chest = GetComponent();
20 | animation = GetComponent();
21 | }
22 |
23 | private void OnEnable()
24 | {
25 | chest.Closed += OnChestClosed;
26 | chest.Opened += OnChestOpened;
27 | }
28 | private void OnDisable()
29 | {
30 | chest.Closed -= OnChestClosed;
31 | chest.Opened -= OnChestOpened;
32 | }
33 |
34 | private void OnChestClosed()
35 | {
36 | animation.clip = chestCloseClip;
37 | animation.Play();
38 | }
39 | private void OnChestOpened()
40 | {
41 | animation.clip = chestOpenClip;
42 | animation.Play();
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3/ChestAnimation.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6523a0fa6f78202499a019d51a4120c2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.StatelessSamples.Example3
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_StatelessSamples/Example 3/";
6 | }
7 | }
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9d7f5a2b1fc706a4f9e84b38e010c113
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3/_Example 3.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: aaaa6f15d6ef86349bbaa7879543c139
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3/_Example 3Settings.lighting:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!850595691 &4890085278179872738
4 | LightingSettings:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_Name: _Example 3Settings
10 | serializedVersion: 2
11 | m_GIWorkflowMode: 1
12 | m_EnableBakedLightmaps: 0
13 | m_EnableRealtimeLightmaps: 0
14 | m_RealtimeEnvironmentLighting: 1
15 | m_BounceScale: 1
16 | m_AlbedoBoost: 1
17 | m_IndirectOutputScale: 1
18 | m_UsingShadowmask: 1
19 | m_BakeBackend: 1
20 | m_LightmapMaxSize: 1024
21 | m_BakeResolution: 40
22 | m_Padding: 2
23 | m_TextureCompression: 1
24 | m_AO: 0
25 | m_AOMaxDistance: 1
26 | m_CompAOExponent: 1
27 | m_CompAOExponentDirect: 0
28 | m_ExtractAO: 0
29 | m_MixedBakeMode: 2
30 | m_LightmapsBakeMode: 1
31 | m_FilterMode: 1
32 | m_LightmapParameters: {fileID: 0}
33 | m_ExportTrainingData: 0
34 | m_TrainingDataDestination: TrainingData
35 | m_RealtimeResolution: 2
36 | m_ForceWhiteAlbedo: 0
37 | m_ForceUpdates: 0
38 | m_FinalGather: 0
39 | m_FinalGatherRayCount: 256
40 | m_FinalGatherFiltering: 1
41 | m_PVRCulling: 1
42 | m_PVRSampling: 1
43 | m_PVRDirectSampleCount: 32
44 | m_PVRSampleCount: 512
45 | m_PVREnvironmentSampleCount: 256
46 | m_PVREnvironmentReferencePointCount: 2048
47 | m_LightProbeSampleCountMultiplier: 4
48 | m_PVRBounces: 2
49 | m_PVRRussianRouletteStartBounce: 2
50 | m_PVREnvironmentMIS: 1
51 | m_PVRFilteringMode: 1
52 | m_PVRDenoiserTypeDirect: 1
53 | m_PVRDenoiserTypeIndirect: 1
54 | m_PVRDenoiserTypeAO: 1
55 | m_PVRFilterTypeDirect: 0
56 | m_PVRFilterTypeIndirect: 0
57 | m_PVRFilterTypeAO: 0
58 | m_PVRFilteringGaussRadiusDirect: 1
59 | m_PVRFilteringGaussRadiusIndirect: 5
60 | m_PVRFilteringGaussRadiusAO: 2
61 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
62 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
63 | m_PVRFilteringAtrousPositionSigmaAO: 1
64 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 3/_Example 3Settings.lighting.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 830dd566795f5c84c864aeb53b10add3
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e035acc56a28225449f0e9d7c5e3a182
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/Chest.cs:
--------------------------------------------------------------------------------
1 | using Stateless;
2 | using System;
3 | using UnityEngine;
4 |
5 | namespace Gbros.StatelessSamples.Example4
6 | {
7 | [AddComponentMenu(Constants.ComponentPath + nameof(Chest))]
8 | public class Chest : MonoBehaviour, IInteractable
9 | {
10 | public enum State { Opened, Closed }
11 | public enum Trigger { Open, Close }
12 |
13 | public State CurrentState => stateMachine.State;
14 |
15 | public event Action Opened;
16 | public event Action Closed;
17 |
18 | private StateMachine stateMachine;
19 |
20 | private void Awake()
21 | {
22 | stateMachine = new StateMachine(State.Closed);
23 |
24 | stateMachine
25 | .Configure(State.Opened)
26 | .OnEntry(OnChestOpened)
27 | .Permit(Trigger.Close, State.Closed);
28 |
29 | stateMachine
30 | .Configure(State.Closed)
31 | .OnEntry(OnChestClosed)
32 | .Permit(Trigger.Open, State.Opened);
33 | }
34 |
35 |
36 | public void Open()
37 | {
38 | if (!stateMachine.CanFire(Trigger.Open)) return;
39 | stateMachine.Fire(Trigger.Open);
40 | }
41 | public void Close()
42 | {
43 | if (!stateMachine.CanFire(Trigger.Close)) return;
44 | stateMachine.Fire(Trigger.Close);
45 | }
46 |
47 | private void OnChestClosed() => Closed?.Invoke();
48 | private void OnChestOpened() => Opened?.Invoke();
49 |
50 | public void StartInteraction() => Open();
51 | public void ExitInteraction() => Close();
52 | }
53 | }
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/Chest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2b2b721b778a1b74c9cb4a417580456f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/ChestAnimation.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace Gbros.StatelessSamples.Example4
4 | {
5 | [AddComponentMenu(Constants.ComponentPath + nameof(ChestAnimation))]
6 | [RequireComponent(typeof(Chest))]
7 | public class ChestAnimation : MonoBehaviour
8 | {
9 | #region SerializedFields
10 | [SerializeField] AnimationClip chestOpenClip;
11 | [SerializeField] AnimationClip chestCloseClip;
12 | #endregion SerializedFields
13 |
14 | private Chest chest;
15 | private Animation animation;
16 |
17 | private void Awake()
18 | {
19 | chest = GetComponent();
20 | animation = GetComponent();
21 | }
22 |
23 | private void OnEnable()
24 | {
25 | chest.Closed += OnChestClosed;
26 | chest.Opened += OnChestOpened;
27 | }
28 | private void OnDisable()
29 | {
30 | chest.Closed -= OnChestClosed;
31 | chest.Opened -= OnChestOpened;
32 | }
33 |
34 | private void OnChestClosed()
35 | {
36 | animation.clip = chestCloseClip;
37 | animation.Play();
38 | }
39 | private void OnChestOpened()
40 | {
41 | animation.clip = chestOpenClip;
42 | animation.Play();
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/ChestAnimation.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 45be486b73458774497ec47edc83e28a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.StatelessSamples.Example4
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_StatelessSamples/Example 4/";
6 | }
7 | }
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 29405538729e2c84b92ee1ae21fa121f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/IInteractable.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.StatelessSamples.Example4
2 | {
3 | public interface IInteractable
4 | {
5 | void StartInteraction();
6 | void ExitInteraction();
7 | }
8 | }
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/IInteractable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e84f9b483fe3be8459aede9a7fda0f17
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/InputMonitor.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System;
3 |
4 | namespace Gbros.StatelessSamples.Example4
5 | {
6 | [AddComponentMenu(Constants.ComponentPath + nameof(InputMonitor))]
7 | public class InputMonitor : MonoBehaviour
8 | {
9 | public static Action LeftMouseButtonClick;
10 |
11 | private void Update()
12 | {
13 | if (Input.GetMouseButtonDown(0)) LeftMouseButtonClick?.Invoke();
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/InputMonitor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f8d3242f15ea95e46a019291d821b5e8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/InteractionMonitor.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Linq;
3 | using System.Collections.Generic;
4 | using System;
5 |
6 | namespace Gbros.StatelessSamples.Example4
7 | {
8 | [AddComponentMenu(Constants.ComponentPath + nameof(InteractionMonitor))]
9 | public class InteractionMonitor : MonoBehaviour
10 | {
11 | private List interactablesInRange = new List();
12 |
13 | private void OnEnable() => InputMonitor.LeftMouseButtonClick += Interact;
14 | private void OnDisable() => InputMonitor.LeftMouseButtonClick -= Interact;
15 |
16 | private void Interact()
17 | {
18 | if (!interactablesInRange.Any()) return;
19 |
20 | var interactable = interactablesInRange.Last();
21 | interactable.StartInteraction();
22 | interactablesInRange.Remove(interactable);
23 | }
24 |
25 | private void OnTriggerEnter2D(Collider2D other)
26 | {
27 | var interactable = other.GetComponentInParent();
28 | if (interactable == null) return;
29 |
30 | interactablesInRange.Add(interactable);
31 | }
32 |
33 | private void OnTriggerExit2D(Collider2D collision)
34 | {
35 | var interactableOutOfRange = collision.GetComponentInParent();
36 | if (interactableOutOfRange == null) return;
37 |
38 | interactableOutOfRange.ExitInteraction();
39 | interactablesInRange.Remove(interactableOutOfRange);
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/InteractionMonitor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4d08bd4d6818230489a604ec9bc34efe
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/_Example 4.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 488ab72edf6ec984d92661ae20f1b183
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/_Example 4Settings.lighting:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!850595691 &4890085278179872738
4 | LightingSettings:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_Name: _Example 4Settings
10 | serializedVersion: 3
11 | m_GIWorkflowMode: 1
12 | m_EnableBakedLightmaps: 0
13 | m_EnableRealtimeLightmaps: 0
14 | m_RealtimeEnvironmentLighting: 1
15 | m_BounceScale: 1
16 | m_AlbedoBoost: 1
17 | m_IndirectOutputScale: 1
18 | m_UsingShadowmask: 1
19 | m_BakeBackend: 1
20 | m_LightmapMaxSize: 1024
21 | m_BakeResolution: 40
22 | m_Padding: 2
23 | m_TextureCompression: 1
24 | m_AO: 0
25 | m_AOMaxDistance: 1
26 | m_CompAOExponent: 1
27 | m_CompAOExponentDirect: 0
28 | m_ExtractAO: 0
29 | m_MixedBakeMode: 2
30 | m_LightmapsBakeMode: 1
31 | m_FilterMode: 1
32 | m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
33 | m_ExportTrainingData: 0
34 | m_TrainingDataDestination: TrainingData
35 | m_RealtimeResolution: 2
36 | m_ForceWhiteAlbedo: 0
37 | m_ForceUpdates: 0
38 | m_FinalGather: 0
39 | m_FinalGatherRayCount: 256
40 | m_FinalGatherFiltering: 1
41 | m_PVRCulling: 1
42 | m_PVRSampling: 1
43 | m_PVRDirectSampleCount: 32
44 | m_PVRSampleCount: 512
45 | m_PVREnvironmentSampleCount: 256
46 | m_PVREnvironmentReferencePointCount: 2048
47 | m_LightProbeSampleCountMultiplier: 4
48 | m_PVRBounces: 2
49 | m_PVRMinBounces: 1
50 | m_PVREnvironmentMIS: 1
51 | m_PVRFilteringMode: 1
52 | m_PVRDenoiserTypeDirect: 1
53 | m_PVRDenoiserTypeIndirect: 1
54 | m_PVRDenoiserTypeAO: 1
55 | m_PVRFilterTypeDirect: 0
56 | m_PVRFilterTypeIndirect: 0
57 | m_PVRFilterTypeAO: 0
58 | m_PVRFilteringGaussRadiusDirect: 1
59 | m_PVRFilteringGaussRadiusIndirect: 5
60 | m_PVRFilteringGaussRadiusAO: 2
61 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
62 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
63 | m_PVRFilteringAtrousPositionSigmaAO: 1
64 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Example 4/_Example 4Settings.lighting.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e362d74b2fd1f554e83702d400ff74d3
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Player.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 92e76a8292b84154f82b52399de95a07
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Player/PlayerBase.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.StatelessSamples
5 | {
6 | [RequireComponent(typeof(Rigidbody2D))]
7 | public class PlayerBase : MonoBehaviour
8 | {
9 | private Rigidbody2D rigidBody;
10 | void Awake()
11 | {
12 | rigidBody = GetComponent();
13 | rigidBody.isKinematic = true;
14 | }
15 |
16 | void Update()
17 | {
18 | var screenDistance = Camera.main.WorldToScreenPoint(transform.position).z;
19 | var newPosition = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenDistance));
20 | transform.position = new Vector3(newPosition.x, newPosition.y, newPosition.z);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Assets/Stateless/Samples~/Player/PlayerBase.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f4e41674f6ec38c4ca29819f889b5e4c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stateless/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "com.gbros.tools.stateless",
3 | "displayName": "Gbros - Stateless",
4 | "description": "Resources for blog post about Stateless Library used in Unity.\nStateless.dll attached to this project is under Apache 2.0 License.\nVisit stateless project repository for more information https://github.com/dotnet-state-machine/stateless ",
5 | "license": "MIT",
6 | "version": "1.0.0",
7 | "references": [
8 | "Stateless"
9 | ],
10 | "keywords": [
11 | "Stateless",
12 | "State",
13 | "Design Pattern",
14 | "Gbros"
15 | ],
16 | "category": "Tutorial",
17 | "repository": {
18 | "type": "git",
19 | "url": "https://github.com/GbrosGames/Tools.git?path=Assets/Stateless"
20 | },
21 | "author": "Gbros Games Studio (https://github.com/GbrosGames)",
22 | "samples": [
23 | {
24 | "displayName": "Samples",
25 | "description": "Pack of examples how to use Stateless library",
26 | "path": "Samples~"
27 | }
28 | ],
29 | "type": "sample"
30 | }
--------------------------------------------------------------------------------
/Assets/Stateless/package.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d5e288bfeacf77343abd3d52203db829
3 | PackageManifestImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UI Toolkit.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 27c4823403fa5254eb492015d3b56be8
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UI Toolkit/UnityThemes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2d593ff19365f224181992a79e3616f7
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UI Toolkit/UnityThemes/UnityDefaultRuntimeTheme.tss:
--------------------------------------------------------------------------------
1 | @import url("unity-theme://default");
--------------------------------------------------------------------------------
/Assets/UI Toolkit/UnityThemes/UnityDefaultRuntimeTheme.tss.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3897c7ab566dcdd48971772ad6e15b27
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 |
--------------------------------------------------------------------------------
/Assets/UniRx.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e7253c202b0ce5f45bc3477be577d2a8
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3840a666bdea60243914519d7840fa48
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Gbros.UniRx.MessageBroker.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Gbros.UniRx.MessageBroker",
3 | "rootNamespace": "Gbros.UniRx",
4 | "references": [
5 | "GUID:560b04d1a97f54a4e82edc0cbbb69285"
6 | ],
7 | "includePlatforms": [],
8 | "excludePlatforms": [],
9 | "allowUnsafeCode": false,
10 | "overrideReferences": false,
11 | "precompiledReferences": [],
12 | "autoReferenced": true,
13 | "defineConstraints": [],
14 | "versionDefines": [],
15 | "noEngineReferences": false
16 | }
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Gbros.UniRx.MessageBroker.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 33d54bfd20ce30d448fbebf35af373ea
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Gbros Games Studio
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 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/LICENSE.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0617b586cbbed9c4ba1e4444101539b7
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/README.md:
--------------------------------------------------------------------------------
1 | # [BLOG](https://github.com/GbrosGames/Blog) - [UniRx](https://github.com/neuecc/UniRx) - MessageBroker
2 |
3 | Usefull UniRx tools and blog post resources. See more on our [blog post](https://www.gbrosgames.com/posts/UniRx-Series-Part-1-MessageBroker)
4 |
5 | ## Package Installation
6 |
7 | Since unity doesn't support git dependencies in package.json you have to [install UniRx](https://github.com/neuecc/UniRx#upm-package) manually.
8 |
9 | Edit manifest.json file in your Unity Packages directory
10 |
11 |
12 | ```
13 | {
14 | "dependencies": {
15 | "com.gbros.tools.unirx.messagebroker": "https://github.com/GbrosGames/Tools.git?path=Assets/UniRx/MessageBroker",
16 | "com.neuecc.unirx": "https://github.com/neuecc/UniRx.git?path=Assets/Plugins/UniRx/Scripts"
17 | }
18 | }
19 | ```
20 |
21 | Or [install](https://docs.unity3d.com/2020.2/Documentation/Manual/upm-ui-giturl.html) via url
22 |
23 | ```
24 | https://github.com/GbrosGames/Tools.git?path=Assets/UniRx/MessageBroker
25 | ```
26 | ```
27 | https://github.com/neuecc/UniRx.git?path=Assets/Plugins/UniRx/Scripts
28 | ```
29 |
30 |
31 | ## Examples
32 |
33 | You can import examples inside UnityPackage Menager > Gbros - UniRx - MessageBroker
34 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f3b3af3c8e3ef6b43a39e81fa94c03fb
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8d669c8f8ce21424ca538e6a7b69f6d8
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/ColorDisplay.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 | using UnityEngine.UI;
4 |
5 | namespace Gbros.UniRx.MessageBrokerSamples.Example1
6 | {
7 | [AddComponentMenu(Constants.ComponentPath + nameof(ColorDisplay))]
8 | [RequireComponent(typeof(Text))]
9 | public class ColorDisplay : MonoBehaviour
10 | {
11 | private Text text;
12 | private void Awake()
13 | {
14 | text = GetComponent();
15 |
16 | MessageBroker
17 | .Default
18 | .Receive()
19 | .Subscribe(Display)
20 | .AddTo(this);
21 | }
22 |
23 | private void Display(ColorSwitchMessage message)
24 | {
25 | text.text = $"{message.Color}";
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/ColorDisplay.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 40a4bdb766451f546bce0c12ccf9329b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/ColorGenerator.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx.MessageBrokerSamples.Example1
5 | {
6 | [AddComponentMenu(Constants.ComponentPath + nameof(ColorGenerator))]
7 | public class ColorGenerator : MonoBehaviour
8 | {
9 | private void Update()
10 | {
11 | if (Input.GetKeyDown(KeyCode.Space))
12 | {
13 | var message = new ColorSwitchMessage(Random.ColorHSV());
14 | MessageBroker.Default.Publish(message);
15 | }
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/ColorGenerator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 156464144cc1673498a4321283108f05
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/ColorSwitchMessage.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace Gbros.UniRx.MessageBrokerSamples.Example1
4 | {
5 | [AddComponentMenu(Constants.ComponentPath + nameof(ColorSwitchMessage))]
6 | public class ColorSwitchMessage
7 | {
8 | public Color Color { get; }
9 |
10 | public ColorSwitchMessage(Color color)
11 | {
12 | Color = color;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/ColorSwitchMessage.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 01f2b7af0cbe4ff4da9b12c47960811c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/ColorSwitcher.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx.MessageBrokerSamples.Example1
5 | {
6 | [AddComponentMenu(Constants.ComponentPath + nameof(ColorSwitcher))]
7 | [RequireComponent(typeof(SpriteRenderer))]
8 | public class ColorSwitcher : MonoBehaviour
9 | {
10 | private SpriteRenderer spriteShapeRenderer;
11 |
12 | private void Awake()
13 | {
14 | spriteShapeRenderer = GetComponent();
15 |
16 | MessageBroker.Default
17 | .Receive()
18 | .Subscribe(SwitchColor)
19 | .AddTo(this);
20 | }
21 |
22 | private void SwitchColor(ColorSwitchMessage message)
23 | {
24 | spriteShapeRenderer.color = message.Color;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/ColorSwitcher.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0e2bbd7999ddc5f47a93176db917b0d7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.UniRx.MessageBrokerSamples.Example1
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_MessageBrokerSamples/Example 1/";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 499440baccb6b0047817d79ae4843fa1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 1/_Example 1.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ecd9259d933e5bb49966a69f0dcff858
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ad0845cad40307546880af84a6c14557
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorDisplay.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 | using UnityEngine.UI;
4 |
5 | namespace Gbros.UniRx.MessageBrokerSamples.Example2
6 | {
7 | [RequireComponent(typeof(Text))]
8 | [AddComponentMenu(Constants.ComponentPath + nameof(ColorDisplay))]
9 | public class ColorDisplay : MonoBehaviour
10 | {
11 | private Text text;
12 | private void Awake()
13 | {
14 | text = GetComponent();
15 |
16 | MessageBroker
17 | .Default
18 | .Receive()
19 | .Subscribe(Display)
20 | .AddTo(this);
21 | }
22 |
23 | private void Display(ColorSwitchMessage message)
24 | {
25 | text.text = $"{message.Color}";
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorDisplay.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3ed97a332a79dcc4e97e70bf42f2ec67
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorGenerator.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx.MessageBrokerSamples.Example2
5 | {
6 | [AddComponentMenu(Constants.ComponentPath + nameof(ColorGenerator))]
7 | public class ColorGenerator : MonoBehaviour
8 | {
9 | private void Update()
10 | {
11 | if (Input.GetKeyDown(KeyCode.Space))
12 | {
13 | var message = ColorSwitchMessage.Create(Random.ColorHSV());
14 | message.Publish();
15 | }
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorGenerator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b963826676230f64b849a46979e63d82
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorSwitchMessage.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: fdad8e05dbf154746961813c504dd7ee, type: 3}
13 | m_Name: ColorSwitchMessage
14 | m_EditorClassIdentifier:
15 | color: {r: 0.08362639, g: 1, b: 0, a: 1}
16 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorSwitchMessage.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f331d6a2704f93f4196dd3db213d0a2a
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorSwitchMessage.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx.MessageBrokerSamples.Example2
5 | {
6 | [CreateAssetMenu(fileName = nameof(ColorSwitchMessage), menuName = Constants.ComponentPath + nameof(ColorSwitchMessage))]
7 | public class ColorSwitchMessage : ScriptableObject
8 | {
9 | [SerializeField] private Color color = default;
10 | public Color Color => color;
11 |
12 | public static ColorSwitchMessage Create(Color color)
13 | {
14 | var message = CreateInstance();
15 | message.color = color;
16 | return message;
17 | }
18 |
19 | public void Publish()
20 | {
21 | MessageBroker.Default.Publish(this);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorSwitchMessage.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fdad8e05dbf154746961813c504dd7ee
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorSwitchMessageEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx.MessageBrokerSamples.Example2
5 | {
6 | [CustomEditor(typeof(ColorSwitchMessage))]
7 | public class ColorSwitchMessageEditor : Editor
8 | {
9 | public override void OnInspectorGUI()
10 | {
11 | DrawDefaultInspector();
12 |
13 | if (!Application.isPlaying) return;
14 |
15 | if (GUILayout.Button(nameof(ColorSwitchMessage.Publish)))
16 | {
17 | var message = (ColorSwitchMessage)target;
18 | message.Publish();
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorSwitchMessageEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 521f0c38ce3615649b90b379573c9233
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorSwitcher.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx.MessageBrokerSamples.Example2
5 | {
6 | [RequireComponent(typeof(SpriteRenderer))]
7 | [AddComponentMenu(Constants.ComponentPath + nameof(ColorSwitcher))]
8 | public class ColorSwitcher : MonoBehaviour
9 | {
10 | private SpriteRenderer spriteRenderer;
11 |
12 | private void Awake()
13 | {
14 | spriteRenderer = GetComponent();
15 |
16 | MessageBroker.Default
17 | .Receive()
18 | .Subscribe(SwitchColor)
19 | .AddTo(this);
20 | }
21 |
22 | private void SwitchColor(ColorSwitchMessage request)
23 | {
24 | spriteRenderer.color = request.Color;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/ColorSwitcher.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 089387c02be527d428cadf0992f1d979
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.UniRx.MessageBrokerSamples.Example2
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_MessageBrokerSamples/Example 2/";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1461b80980a5e554dbf2eada388bf564
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 2/_Example 2.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3e97814db4f715e4d8c1e2622f87c19c
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 71c7640890567d0419c2cbab46299ec6
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/AudioPlayer.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx.MessageBrokerSamples.Example3
5 | {
6 | [AddComponentMenu(Constants.ComponentPath + nameof(AudioPlayer))]
7 | public class AudioPlayer : MonoBehaviour
8 | {
9 | void Awake()
10 | {
11 | MessageBroker
12 | .Default
13 | .ReceiveMessage()
14 | .Subscribe(PlaySound)
15 | .AddTo(this);
16 | }
17 |
18 | private void PlaySound(ZoneEnterMessage message)
19 | {
20 | Debug.Log($"Playing {message.ZoneType} sound");
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/AudioPlayer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1498ae383d07a3f40ad6f1b02d7c1493
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.UniRx.MessageBrokerSamples.Example3
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_MessageBrokerSamples/Example 3/";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 656bc56e5ac09eb4ebae94d3a409a6f4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/Player.cs:
--------------------------------------------------------------------------------
1 | using Gbros.UniRx;
2 | using UniRx;
3 | using UnityEngine;
4 |
5 | namespace Gbros.UniRx.MessageBrokerSamples.Example3
6 | {
7 | [AddComponentMenu(Constants.ComponentPath + nameof(Player))]
8 | public class Player : PlayerBase
9 | {
10 | private void OnTriggerEnter2D(Collider2D collision)
11 | {
12 | var areaTrigger = collision.GetComponent();
13 | if (areaTrigger == null) return;
14 |
15 | var message = ZoneEnterMessage.Create(areaTrigger.ZoneType);
16 | message.Publish();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/Player.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1a95acccf5296d44cbf56ef2de642cce
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/Zone.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace Gbros.UniRx.MessageBrokerSamples.Example3
4 | {
5 | [AddComponentMenu(Constants.ComponentPath + nameof(Zone))]
6 | public class Zone : MonoBehaviour
7 | {
8 | [SerializeField] ZoneType zoneType = default;
9 | public ZoneType ZoneType => zoneType;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/Zone.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 51cc6dfdccfd1174886d1feaa1dd8e87
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/ZoneDisplay.cs:
--------------------------------------------------------------------------------
1 | using Gbros.UniRx;
2 | using System;
3 | using UniRx;
4 | using UnityEngine;
5 | using UnityEngine.UI;
6 |
7 | namespace Gbros.UniRx.MessageBrokerSamples.Example3
8 | {
9 | [RequireComponent(typeof(Text))]
10 | [AddComponentMenu(Constants.ComponentPath + nameof(ZoneDisplay))]
11 | public class ZoneDisplay : MonoBehaviour
12 | {
13 | [SerializeField] float notificationDuration = 2f;
14 |
15 | private IObservable whenPlayerEntersNewZone;
16 | private Text text;
17 |
18 | private void Awake()
19 | {
20 | text = GetComponent();
21 |
22 | whenPlayerEntersNewZone = MessageBroker.Default.ReceiveMessage();
23 | whenPlayerEntersNewZone.Subscribe(Display).AddTo(this);
24 | }
25 |
26 | private void Display(ZoneEnterMessage request)
27 | {
28 | text.text = $"Entering {request.ZoneType} zone";
29 |
30 | Observable
31 | .Timer(TimeSpan.FromSeconds(notificationDuration))
32 | .TakeUntil(whenPlayerEntersNewZone)
33 | .Subscribe(_ =>
34 | {
35 | text.text = string.Empty;
36 | })
37 | .AddTo(this);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/ZoneDisplay.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b3785008f46f0f0448eaf37a9d161104
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/ZoneEnterMessage.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: a426da4e5ab05e7489793929c8b6b4e8, type: 3}
13 | m_Name: ZoneEnterMessage
14 | m_EditorClassIdentifier:
15 | zoneType: 2
16 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/ZoneEnterMessage.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4d4725d278af14e42b014b163a554c56
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/ZoneEnterMessage.cs:
--------------------------------------------------------------------------------
1 | using Gbros.UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx.MessageBrokerSamples.Example3
5 | {
6 | [CreateAssetMenu(fileName = nameof(ZoneEnterMessage), menuName = Constants.ComponentPath + nameof(ZoneEnterMessage))]
7 | public class ZoneEnterMessage : Message
8 | {
9 | [SerializeField] ZoneType zoneType = default;
10 | public ZoneType ZoneType => zoneType;
11 | public static ZoneEnterMessage Create(ZoneType zoneType)
12 | {
13 | var message = CreateInstance();
14 | message.zoneType = zoneType;
15 | return message;
16 | }
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/ZoneEnterMessage.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a426da4e5ab05e7489793929c8b6b4e8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/ZoneType.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.UniRx.MessageBrokerSamples.Example3
2 | {
3 | public enum ZoneType
4 | {
5 | Default,
6 | Danger,
7 | HiddenTreasure
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/ZoneType.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f84283b40460ee8439edff7802ad995b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 3/_Example 3.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2cda990e2423bbf4892e6590ba056729
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 49163c284b204c84e87a5f19a78f124f
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/ActivateOnGameEvent.cs:
--------------------------------------------------------------------------------
1 | using Gbros.UniRx;
2 | using UnityEngine;
3 | using System;
4 | using Gbros.UniRx.Utilities;
5 |
6 | namespace Gbros.UniRx.MessageBrokerSamples.Example4
7 | {
8 | [CreateAssetMenu(fileName = nameof(ActivateOnGameEvent), menuName = "_" + nameof(ActivateOnGameEvent))]
9 | public class ActivateOnGameEvent : ActivateOnMessage
10 | {
11 | protected override Func predicate => incomingMessage => incomingMessage.Name == message.Name;
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/ActivateOnGameEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5e84633d4c2fd824c8c7101d49a6a535
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.UniRx.MessageBrokerSamples.Example4
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_MessageBrokerSamples/Example 4/";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3d5900df9436fce4984832fa5ba342b8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/Dragon GameEventMessage.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: a724451960469b44190db0a61279fb20, type: 3}
13 | m_Name: Dragon GameEventMessage
14 | m_EditorClassIdentifier:
15 | name: Dragon
16 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/Dragon GameEventMessage.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 64a60c66369445445adf8a15e969d007
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameEventMessage.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: a724451960469b44190db0a61279fb20, type: 3}
13 | m_Name: GameEventMessage
14 | m_EditorClassIdentifier:
15 | name:
16 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameEventMessage.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 736e550021d923440a81b49db8039de8
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameEventMessage.cs:
--------------------------------------------------------------------------------
1 | using Gbros.UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx.MessageBrokerSamples.Example4
5 | {
6 | [CreateAssetMenu(fileName = nameof(GameEventMessage), menuName = Constants.ComponentPath + nameof(GameEventMessage))]
7 | public class GameEventMessage : Message
8 | {
9 | [SerializeField] string name = default;
10 | public string Name => name;
11 |
12 | public static GameEventMessage Create(string name)
13 | {
14 | var instance = CreateInstance();
15 | instance.name = name;
16 | return instance;
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameEventMessage.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a724451960469b44190db0a61279fb20
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 | using UnityEngine;
4 |
5 | namespace Gbros.UniRx.MessageBrokerSamples.Example4
6 | {
7 | public class GameManager : MonoBehaviour
8 | {
9 | [SerializeField] int startAfterSeconds = 3;
10 | void Start()
11 | {
12 | Observable
13 | .Interval(TimeSpan.FromSeconds(1)) // tick every seconds
14 | .Take(startAfterSeconds) // limit ticks
15 | .Select(second => startAfterSeconds - second) // decrease time left by second every interval
16 | .Subscribe(GameStarter) // subscribe to observable with custom GameStarter observer
17 | .AddTo(this); // dispose if component is destroyed during countdown
18 | }
19 |
20 | private IObserver GameStarter
21 | => Observer.Create( // base method to create custom observable
22 | onNext: secondsLeft => Debug.Log($"Start in {secondsLeft}"), // every tick we are log time left to start the game
23 | onCompleted: GameStartMessage.Create().Publish); // after given time we are publishing GameStartMessage to every receivers
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameManager.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 52cdcf0191868344b9a83c16d5f064bf
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameStartMessage.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: 3e4e77a472424544da2dd7537481e682, type: 3}
13 | m_Name: GameStartMessage
14 | m_EditorClassIdentifier:
15 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameStartMessage.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b5cae238d3b68b24b955fb85b6be9d12
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameStartMessage.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace Gbros.UniRx.MessageBrokerSamples.Example4
4 | {
5 | [CreateAssetMenu(fileName = nameof(GameStartMessage), menuName = Constants.ComponentPath + nameof(GameStartMessage))]
6 | public class GameStartMessage : Message
7 | {
8 | public static GameStartMessage Create() => CreateInstance();
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/GameStartMessage.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3e4e77a472424544da2dd7537481e682
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Example 4/_Example 4.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4d24d6be66f86824da5ce07797716a80
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Player.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2c6b81737b4fa0541a07259aa3e800c0
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Player/PlayerBase.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx
5 | {
6 | [RequireComponent(typeof(Rigidbody2D))]
7 | public class PlayerBase : MonoBehaviour
8 | {
9 | private Rigidbody2D rigidBody;
10 | void Awake()
11 | {
12 | rigidBody = GetComponent();
13 | rigidBody.isKinematic = true;
14 | }
15 |
16 | void Update()
17 | {
18 | var screenDistance = Camera.main.WorldToScreenPoint(transform.position).z;
19 | var newPosition = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenDistance));
20 | transform.position = new Vector3(newPosition.x, newPosition.y, newPosition.z);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Samples~/Player/PlayerBase.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ae2b109f61f8c474db6e446a4fe435e7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f2c1ac22d9019c44ababeb766b2b3316
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/IMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.UniRx
2 | {
3 | public interface IMessage
4 | {
5 | void Publish();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/IMessage.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7a43e303fa85d794680fa573856788c4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/Message.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 | using UnityEngine;
4 |
5 | namespace Gbros.UniRx
6 | {
7 | ///
8 | /// Base class for ScriptableObject requests.
9 | /// If you want to call MessageBroker from MonoBehaviours, call them directly -> Message.Create()
10 | /// ScriptableObject can't have constructors, so try to add every Message through static Create method.
11 | ///
12 | public abstract class Message : ScriptableObject, IMessage
13 | {
14 | public void Publish()
15 | {
16 | MessageBroker.Default.PublishMessage(this);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/Message.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 82db710cc64521847970806a40361fcf
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/MessageBrokerExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 |
4 | namespace Gbros.UniRx
5 | {
6 | public static class MessageBrokerExtensions
7 | {
8 | public static IObservable ReceiveMessage(this IMessageBroker messageBroker)
9 | => messageBroker.Receive().OfType();
10 |
11 | public static void PublishMessage(this IMessageBroker messageBroker, T message) where T : IMessage
12 | => messageBroker.Publish(message);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/MessageBrokerExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 25dd663ceca766949b83f46a0a8f6839
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/MessageEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | namespace Gbros.UniRx
5 | {
6 | [CustomEditor(typeof(Message), editorForChildClasses: true)]
7 | public class MessageEditor : Editor
8 | {
9 | public override void OnInspectorGUI()
10 | {
11 | DrawDefaultInspector();
12 |
13 | if (!Application.isPlaying) return;
14 |
15 | if (!(target is IMessage message)) return;
16 |
17 | if (GUILayout.Button(nameof(IMessage.Publish)))
18 | {
19 | message.Publish();
20 | }
21 | }
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/MessageEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e9de9049dbed9d14a9a8d036b15f7ec5
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/Utilities.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 684ca461f91e91145b571625b9ca924c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/Utilities/ActivateOnMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 | using UnityEngine;
4 |
5 | namespace Gbros.UniRx.Utilities
6 | {
7 | ///
8 | /// Activates game object when receive Message
9 | ///
10 | public abstract class ActivateOnMessage : MonoBehaviour where T : Message
11 | {
12 | [SerializeField] protected T message;
13 | protected virtual Func predicate => incomingMessage => incomingMessage.GetType() == message?.GetType();
14 |
15 | public virtual void Awake()
16 | {
17 | this.gameObject.SetActive(false);
18 |
19 | MessageBroker.Default.ReceiveMessage()
20 | .Where(predicate)
21 | .Subscribe(x => gameObject.SetActive(true))
22 | .AddTo(this);
23 | }
24 | }
25 |
26 | public class ActivateOnMessage : ActivateOnMessage { }
27 | }
28 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/Scripts/Utilities/ActivateOnMessage.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0cdeb374eba83b348ab2d11e9ecdcb39
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "com.gbros.tools.unirx.messagebroker",
3 | "displayName": "Gbros - UniRx - MessageBroker",
4 | "description": "Usefull UniRx tools and blog post resources. See more on our blog post - https://www.gbrosgames.com/blog",
5 | "license": "MIT",
6 | "version": "1.0.0",
7 | "keywords": [
8 | "UniRx",
9 | "MessageBroker",
10 | "Messaging system",
11 | "Gbros"
12 | ],
13 | "category": "Tutorial",
14 | "repository": {
15 | "type": "git",
16 | "url": "https://github.com/GbrosGames/Tools.git?path=Assets/UniRx/MessageBroker"
17 | },
18 | "author": "Gbros Games Studio (https://github.com/GbrosGames)",
19 | "samples": [
20 | {
21 | "displayName": "Samples",
22 | "description": "Pack of examples how to use UniRx library",
23 | "path": "Samples~"
24 | }
25 | ],
26 | "type": "sample",
27 | "dependencies": {
28 | "com.unity.2d.sprite": "1.0.0"
29 | }
30 | }
--------------------------------------------------------------------------------
/Assets/UniRx/MessageBroker/package.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8c0d065ca46f1e849b7cc02dd4c186b0
3 | PackageManifestImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8fff724808938fb47aa2ac96ae0d9bd8
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Gbros.UniRx.PowerObservables.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Gbros.UniRx.PowerObservables",
3 | "rootNamespace": "Gbros.UniRx",
4 | "references": [
5 | "GUID:560b04d1a97f54a4e82edc0cbbb69285"
6 | ],
7 | "includePlatforms": [],
8 | "excludePlatforms": [],
9 | "allowUnsafeCode": false,
10 | "overrideReferences": false,
11 | "precompiledReferences": [],
12 | "autoReferenced": true,
13 | "defineConstraints": [],
14 | "versionDefines": [],
15 | "noEngineReferences": false
16 | }
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Gbros.UniRx.PowerObservables.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 72dda4a81f0a3da43b0e20291f5f4959
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Gbros Games Studio
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 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/LICENSE.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6591119bf7948db48bf8989bddc150c4
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/README.md:
--------------------------------------------------------------------------------
1 | # [BLOG](https://github.com/GbrosGames/Blog) - [UniRx](https://github.com/neuecc/UniRx) - PowerObservables
2 |
3 | Usefull UniRx tools and blog post resources. See more on our [blog post](https://www.gbrosgames.com/posts/UniRx-PowerObservables/)
4 |
5 | ## Package Installation
6 |
7 | Since unity doesn't support git dependencies in package.json you have to [install UniRx](https://github.com/neuecc/UniRx#upm-package) manually.
8 |
9 | Edit manifest.json file in your Unity Packages directory
10 |
11 |
12 | ```
13 | {
14 | "dependencies": {
15 | "com.gbros.tools.unirx.powerobservables": "https://github.com/GbrosGames/Tools.git?path=Assets/UniRx/PowerObservables",
16 | "com.neuecc.unirx": "https://github.com/neuecc/UniRx.git?path=Assets/Plugins/UniRx/Scripts"
17 | }
18 | }
19 | ```
20 |
21 | Or [install](https://docs.unity3d.com/2020.2/Documentation/Manual/upm-ui-giturl.html) via url
22 |
23 | ```
24 | https://github.com/GbrosGames/Tools.git?path=Assets/UniRx/PowerObservables
25 | ```
26 | ```
27 | https://github.com/neuecc/UniRx.git?path=Assets/Plugins/UniRx/Scripts
28 | ```
29 |
30 |
31 | ## Examples
32 |
33 | You can import examples inside UnityPackage Menager > Gbros - UniRx - PowerObservables
34 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 721e9d4027b9a484693707b54ed6fe11
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 1.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bdebd20bdfd081b43be4eadc91957454
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 1/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.UniRx.PowerObservablesSamples.Example1
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_PowerObservablesSamples/Example 1/";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 1/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a466e4fbfd37929439668178fb46e488
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 1/CountedInterval.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 | using UnityEngine;
3 | using UnityEngine.Assertions;
4 | using UnityEngine.UI;
5 |
6 | namespace Gbros.UniRx.PowerObservablesSamples.Example1
7 | {
8 | [RequireComponent(typeof(Text))]
9 | [AddComponentMenu(Constants.ComponentPath + nameof(CountedInterval))]
10 | public class CountedInterval : MonoBehaviour
11 | {
12 | [SerializeField] private BoolReactiveProperty pause = new BoolReactiveProperty();
13 | [SerializeField] private Text hintText;
14 | private Text text; // UI text component reference
15 |
16 | void Awake()
17 | {
18 | text = GetComponent(); // get text component reference so we can display time
19 |
20 | Assert.IsNotNull(hintText, "Hint text is null. Drag and drop component with text to display value"); // validate that serialize field is correctly refferenced
21 |
22 | PowerObservable.CountedInterval(pause) // Create Counted Interval and pass pause Observable to be able to pause/unpause stream
23 | .Select(time => $"TIME {time}") // Select formatted text from string
24 | .SubscribeToText(text) // subscribe to text component reference. Every interval tick subscribe method will be called and refresh UI
25 | .AddTo(this); // dispose subscription on component destroy
26 |
27 | pause.Select(isPaused => $"SPACEBAR - " + (isPaused ? "UNPAUSE" : "PAUSE")) // Select formatted text from string
28 | .SubscribeToText(hintText) // subscribe to hint text to refresh UI every pause value changed
29 | .AddTo(this);
30 | }
31 |
32 | private void OnEnable()
33 | {
34 | pause.Value = false; // resume on enable
35 | }
36 |
37 | private void OnDisable()
38 | {
39 | pause.Value = true; // pause on disable
40 | }
41 |
42 | void Update()
43 | {
44 | if (!Input.GetKeyDown(KeyCode.Space)) return; // return if spacebar is not pressed
45 |
46 | pause.Value = !pause.Value; // toggle pause
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 1/CountedInterval.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 281448fd2d591f340902c807489e5769
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 1/_Example 1.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 712c01c3c477f484d8d127b5d4f35d4a
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 2.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b9ba3165a5f1cea4e8e2a3b6886b0877
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 2/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace Gbros.UniRx.PowerObservablesSamples.Example2
2 | {
3 | public class Constants
4 | {
5 | public const string ComponentPath = "_PowerObservablesSamples/Example 2/";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 2/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 14736397d18bf884aaa6c0f9fb772ba9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 2/Countdown.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 | using UnityEngine;
4 | using UnityEngine.Assertions;
5 | using UnityEngine.UI;
6 |
7 | namespace Gbros.UniRx.PowerObservablesSamples.Example1
8 | {
9 | [RequireComponent(typeof(Text))]
10 | [AddComponentMenu(Constants.ComponentPath + nameof(Countdown))]
11 | public class Countdown : MonoBehaviour
12 | {
13 | [SerializeField] float Time = 5f; // Initial Time in seconds
14 | [SerializeField] private Text hintText;
15 | private Text text; // UI text component reference
16 | private CompositeDisposable disposables = new CompositeDisposable(); // initialize holder for subscription
17 |
18 | void Awake()
19 | {
20 | text = GetComponent(); // get text component reference so we can display time
21 |
22 | Assert.IsNotNull(hintText, "Hint text is null. Drag and drop component with text to display value"); // validate that serialize field is correctly refferenced
23 |
24 | disposables.AddTo(this); // dispose disposables on destroy
25 | }
26 |
27 | private void StartTimer()
28 | {
29 | text.text = TimeSpan.FromSeconds(Time).ToString(); // update UI countdown text
30 | hintText.text = "SPACEBAR - RESTART"; // update UI hint text
31 |
32 | disposables.Clear(); // clear container from disposables and dispose previous subscriptions
33 |
34 | PowerObservable.Countdown(Time) // Create Countdown and pass initial time
35 | .Subscribe(OnTick, OnComplete) // Call OnTick method every tick, and call OnComplete method when countdown is done
36 | .AddTo(disposables); // dispose subscription on component destroy if compontent is destroyed
37 | }
38 |
39 | private void OnTick(TimeSpan time)
40 | {
41 | text.text = time.ToString(); // update UI text every tick to its value
42 | }
43 |
44 | private void OnComplete()
45 | {
46 | text.text = "Done!"; // update UI text when countdown's done
47 | hintText.text = "SPACEBAR - START"; // update UI hint text
48 | }
49 |
50 | private void Update()
51 | {
52 | if (!Input.GetKeyDown(KeyCode.Space)) return; // reteurn if spacebar is not pressed
53 |
54 | StartTimer(); // start or restart timer
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 2/Countdown.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 83582a1bfd39af54d819cbd2af83673e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Samples~/Example 2/_Example 2.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: acc51d93bd0d7b44c950660b29cdaf80
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 44ea4bf93e02e6e49b49414a5d730fed
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/Countdown.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 |
4 | namespace Gbros.UniRx
5 | {
6 | public partial class PowerObservable
7 | {
8 | ///
9 | /// Returns an observable sequence that produces a differed time value for certain duration. Completes when there is no time left.
10 | ///
11 | /// Start time
12 | /// Tick in seconds
13 | /// Scheduler
14 | ///
15 | public static IObservable Countdown(float initialTime, float tick = DefaultTick, IScheduler scheduler = null)
16 | {
17 | scheduler ??= DefaultScheduler;
18 | return Observable.Interval(TimeSpan.FromSeconds(tick), scheduler)
19 | .Scan(TimeSpan.FromSeconds(initialTime), (result, item) => result -= TimeSpan.FromSeconds(tick))
20 | .TakeWhile(timeLeft => timeLeft > TimeSpan.Zero);
21 | }
22 |
23 | ///
24 | /// Returns an observable sequence that produces a differed time value for certain duration with ability to pause and resume. Completes when there is no time left.
25 | ///
26 | /// Start time
27 | /// Tick in seconds
28 | /// Scheduler
29 | ///
30 | public static IObservable Countdown(IObservable pause, float initialTime, float tick = DefaultTick, IScheduler scheduler = null)
31 | => PausableInterval(pause, tick, scheduler)
32 | .Scan(TimeSpan.FromSeconds(initialTime), (result, intervalTick) => result -= intervalTick)
33 | .TakeWhile(timeLeft => timeLeft > TimeSpan.Zero);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/Countdown.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f6ee1304d7cac6e469d736980012d0ec
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/CountedInterval.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 |
4 | namespace Gbros.UniRx
5 | {
6 | public partial class PowerObservable
7 | {
8 | ///
9 | /// Returns an observable sequence with aggregated time since subscribe
10 | ///
11 | /// Tick in seconds
12 | /// Scheduler
13 | ///
14 | public static IObservable CountedInterval(float tick = DefaultTick, IScheduler scheduler = null)
15 | {
16 | scheduler ??= DefaultScheduler;
17 | return Observable
18 | .Interval(TimeSpan.FromSeconds(tick), scheduler)
19 | .Scan(TimeSpan.Zero, (result, item) => result += TimeSpan.FromSeconds(tick));
20 | }
21 |
22 | ///
23 | /// Returns an observable sequence with aggregated time since subscribe with pause option
24 | ///
25 | /// Pause sequence
26 | /// Tick in seconds
27 | /// Scheduler
28 | ///
29 | public static IObservable CountedInterval(IObservable pause, float tick = DefaultTick, IScheduler scheduler = null)
30 | => PausableInterval(pause, tick, scheduler)
31 | .Scan(TimeSpan.Zero, (result, intervalTick) => result += intervalTick);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/CountedInterval.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 16892539de1819f47acd33afd611dccd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/ObservableExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 |
4 | namespace Gbros.UniRx
5 | {
6 | public static class ObservableExtensions
7 | {
8 | ///
9 | /// Pause or resume observable wheter value is true or false
10 | ///
11 | ///
12 | ///
13 | ///
14 | ///
15 | public static IObservable WithPause(this IObservable observable, IObservable pause)
16 | => observable.WithLatestFrom(pause.StartWith(false), (value, isPaused) => (value, isPaused))
17 | .Where(x => !x.isPaused)
18 | .Select(x => x.value);
19 | }
20 | }
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/ObservableExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bdcd4be456fa17f4c8ddfc8e32dfb92d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/PausableInterval.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 |
4 | namespace Gbros.UniRx
5 | {
6 | public partial class PowerObservable
7 | {
8 | ///
9 | /// Returns an observable sequence with aggregated time since subscribe
10 | ///
11 | /// Pause sequence
12 | /// Tick in seconds
13 | /// Scheduler
14 | ///
15 | public static IObservable PausableInterval(IObservable pause, float tick = DefaultTick, IScheduler scheduler = null)
16 | {
17 | scheduler ??= DefaultScheduler;
18 |
19 | return Observable.Interval(TimeSpan.FromSeconds(tick), scheduler)
20 | .Select(_ => TimeSpan.FromSeconds(tick))
21 | .WithPause(pause);
22 | }
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/PausableInterval.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ac9fb0ce02630284f9db4c8cf06bb910
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/PowerObservable.cs:
--------------------------------------------------------------------------------
1 | using UniRx;
2 |
3 | namespace Gbros.UniRx
4 | {
5 | public partial class PowerObservable
6 | {
7 | ///
8 | /// Default Tick in Seconds
9 | ///
10 | public const int DefaultTick = 1;
11 |
12 | ///
13 | /// Default Scheduler - Main Thread
14 | ///
15 | ///
16 | public static IScheduler DefaultScheduler { get; } = Scheduler.MainThread;
17 | }
18 | }
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/PowerObservable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b5cb46e88f891304fb1554e0827be5a9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/TimerCountedInterval.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 |
4 | namespace Gbros.UniRx
5 | {
6 | public partial class PowerObservable
7 | {
8 | ///
9 | /// Returns an observable sequence with aggregated time since subscribe. Lasts for certain duration.
10 | ///
11 | /// Duration of sequence
12 | /// Tick in seconds
13 | /// Scheduler
14 | ///
15 | public static IObservable TimerCountedInterval(float duration, float tick = DefaultTick, IScheduler scheduler = null)
16 | {
17 | scheduler ??= DefaultScheduler;
18 | return CountedInterval(tick, scheduler).Take(TimeSpan.FromSeconds(duration), scheduler);
19 | }
20 |
21 | ///
22 | /// Returns an observable sequence with aggregated time since subscribe. Lasts for certain duration.
23 | ///
24 | /// Pause sequence
25 | /// Duration of sequence
26 | /// Tick in seconds
27 | /// Scheduler
28 | ///
29 | public static IObservable TimerCountedInterval(IObservable pause, float duration, float tick = DefaultTick, IScheduler scheduler = null)
30 | {
31 | scheduler ??= DefaultScheduler;
32 | return CountedInterval(pause, tick, scheduler).Take(TimeSpan.FromSeconds(duration), scheduler);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/TimerCountedInterval.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8d7b2107540752049a84721431abdd49
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/TimerInterval.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UniRx;
3 |
4 | namespace Gbros.UniRx
5 | {
6 | public partial class PowerObservable
7 | {
8 | ///
9 | /// Returns an observable sequence that produces a value after each period for certain duration
10 | ///
11 | /// Duration of sequence
12 | /// Tick in seconds
13 | /// Scheduler
14 | ///
15 | public static IObservable TimerInterval(float duration, float tick = DefaultTick, IScheduler scheduler = null)
16 | {
17 | scheduler ??= DefaultScheduler;
18 | return Observable.Interval(TimeSpan.FromSeconds(tick), scheduler)
19 | .Select(_ => TimeSpan.FromSeconds(tick))
20 | .Take(TimeSpan.FromSeconds(duration), scheduler);
21 | }
22 |
23 | ///
24 | /// Returns an observable sequence that produces a value after each period for certain duration with ability to pause.
25 | ///
26 | /// Pause sequence
27 | /// Duration of sequence
28 | /// Tick in seconds
29 | /// Scheduler
30 | ///
31 | public static IObservable TimerInterval(IObservable pause, float duration, float tick = DefaultTick, IScheduler scheduler = null)
32 | {
33 | scheduler ??= DefaultScheduler;
34 | return PausableInterval(pause, tick, scheduler).Take(TimeSpan.FromSeconds(duration), scheduler);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/Scripts/TimerInterval.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 653fa23f87805ee498d08232a96766e6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "com.gbros.tools.unirx.powerobservables",
3 | "displayName": "Gbros - UniRx - PowerObservables",
4 | "description": "Usefull UniRx tools and blog post resources. See more on our blog post - https://www.gbrosgames.com/blog",
5 | "license": "MIT",
6 | "version": "1.0.1",
7 | "keywords": [
8 | "UniRx",
9 | "Gbros"
10 | ],
11 | "category": "Utilities",
12 | "repository": {
13 | "type": "git",
14 | "url": "https://github.com/GbrosGames/Tools.git?path=Assets/UniRx/PowerObservables"
15 | },
16 | "author": "Gbros Games Studio (https://github.com/GbrosGames)",
17 | "samples": [
18 | {
19 | "displayName": "Samples",
20 | "description": "Pack of examples how to use UniRx library",
21 | "path": "Samples~",
22 | "dependencies": {
23 | "com.unity.2d.sprite": "1.0.0"
24 | }
25 | }
26 | ],
27 | "type": "sample"
28 | }
--------------------------------------------------------------------------------
/Assets/UniRx/PowerObservables/package.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cbf38e14661af514db0ac351a37c3b12
3 | PackageManifestImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Watchers.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 27e4327bfb1e5d349abb2a81f8625286
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Watchers/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6aa0da6fca1d9b340bc8c8dc233e2d0a
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Watchers/Editor/Extensions.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 355ee14619b90924b9efa0c3dfa7b9b5
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Watchers/Editor/Extensions/ExpressionExtensions.cs:
--------------------------------------------------------------------------------
1 | #if UNITY_EDITOR
2 | using System;
3 | using System.Linq.Expressions;
4 |
5 | namespace Gbros.Watchers
6 | {
7 | public static class ExpressionExtensions
8 | {
9 | public static string GetName(this Expression expression) => expression.Body switch
10 | {
11 | MemberExpression memberExpression => memberExpression.Member.Name,
12 | UnaryExpression unaryExpression when unaryExpression.Operand is MemberExpression memberExpression => memberExpression.Member.Name,
13 | _ => throw new NotImplementedException(expression.GetType().ToString())
14 | };
15 | }
16 | }
17 | #endif
--------------------------------------------------------------------------------
/Assets/Watchers/Editor/Extensions/ExpressionExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e163c6f803b081745a86244d28345a84
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Watchers/Editor/Extensions/UIElementsExtensions.cs:
--------------------------------------------------------------------------------
1 | #if UNITY_EDITOR
2 | using System;
3 | using UnityEngine.UIElements;
4 | using UnityEditor;
5 | using UnityEditor.Experimental.GraphView;
6 |
7 | namespace Gbros.Watchers
8 | {
9 | public static class UIElementsExtensions
10 | {
11 | public static bool TryQ(this VisualElement element, out T result, string name = null, params string[] classes) where T : VisualElement
12 | {
13 | result = element.Q(name, classes);
14 | return result is not null;
15 | }
16 | public static bool TryQ(this VisualElement element, out T result, string name = null, string className = null) where T : VisualElement
17 | {
18 | result = element.Q(name, className);
19 | return result is not null;
20 | }
21 |
22 | public static VisualElement QUnityTextInput(this VisualElement element) => element.Q("unity-text-input");
23 | public static VisualElement QTitle(this Node node) => node.Q("title");
24 | public static Label QTitleLabel(this Node node) => node.QTitle().Q