From b87465d80ff630bb86d3a2cafb38559cc7bbf79f Mon Sep 17 00:00:00 2001 From: "JSD\\13999" <1399945104@qq.com> Date: Thu, 18 Jun 2026 12:20:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor(scope):=20=E6=94=B6=E6=9D=9F=E6=9E=B6?= =?UTF-8?q?=E6=9E=84=E4=BD=9C=E7=94=A8=E5=9F=9F=E5=AE=B9=E5=99=A8=E8=BE=B9?= =?UTF-8?q?=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- My project/Assets/FlowScope/Addressables.meta | 8 - .../AddressablesResourceBackend.cs | 47 - .../AddressablesResourceBackend.cs.meta | 11 - .../AddressablesResourceService.cs | 38 - .../AddressablesResourceService.cs.meta | 11 - .../FlowScope.Addressables.asmdef | 18 - .../FlowScope.Addressables.asmdef.meta | 7 - .../Assets/FlowScope/Runtime/Audio.meta | 8 - .../FlowScope/Runtime/Audio/AudioHandle.cs | 25 - .../Runtime/Audio/AudioHandle.cs.meta | 11 - .../FlowScope/Runtime/Audio/AudioService.cs | 392 ------ .../Runtime/Audio/AudioService.cs.meta | 11 - .../Runtime/Audio/AudioServiceConfig.cs | 8 - .../Runtime/Audio/AudioServiceConfig.cs.meta | 11 - .../FlowScope/Runtime/Audio/IAudioHandle.cs | 8 - .../Runtime/Audio/IAudioHandle.cs.meta | 11 - .../FlowScope/Runtime/Audio/IAudioService.cs | 25 - .../Runtime/Audio/IAudioService.cs.meta | 11 - .../Assets/FlowScope/Runtime/Common.meta | 8 - .../FlowScope/Runtime/Common/ResultLog.cs | 22 - .../Runtime/Common/ResultLog.cs.meta | 11 - .../Assets/FlowScope/Runtime/Config.meta | 8 - .../Runtime/Config/FileConfigSource.cs | 31 - .../Runtime/Config/FileConfigSource.cs.meta | 11 - .../FlowScope/Runtime/Config/IConfigParser.cs | 14 - .../Runtime/Config/IConfigParser.cs.meta | 11 - .../Runtime/Config/IConfigProvider.cs | 13 - .../Runtime/Config/IConfigProvider.cs.meta | 11 - .../FlowScope/Runtime/Config/IConfigRow.cs | 7 - .../Runtime/Config/IConfigRow.cs.meta | 11 - .../FlowScope/Runtime/Config/IConfigSource.cs | 14 - .../Runtime/Config/IConfigSource.cs.meta | 11 - .../Runtime/Config/InMemoryConfigSource.cs | 37 - .../Config/InMemoryConfigSource.cs.meta | 11 - .../Runtime/Config/JsonConfigParser.cs | 16 - .../Runtime/Config/JsonConfigParser.cs.meta | 11 - .../Runtime/Config/JsonConfigProvider.cs | 166 --- .../Runtime/Config/JsonConfigProvider.cs.meta | 11 - .../Runtime/Core/Container/Container.cs | 64 +- .../Core/Container/GeneratedFactories.cs | 43 - .../Core/Container/GeneratedFactories.cs.meta | 11 - .../Core/Container/InjectableAttribute.cs | 9 - .../Container/InjectableAttribute.cs.meta | 11 - .../Container/ReflectionFactoryBuilder.cs | 62 - .../ReflectionFactoryBuilder.cs.meta | 11 - My project/Assets/FlowScope/Runtime/Data.meta | 8 - .../Data/ReactivePropertyJsonConverter.cs | 731 ---------- .../ReactivePropertyJsonConverter.cs.meta | 11 - My project/Assets/FlowScope/Runtime/Flow.meta | 8 - .../FlowScope/Runtime/Flow/FeatureBase.cs | 31 - .../Runtime/Flow/FeatureBase.cs.meta | 11 - .../FlowScope/Runtime/Flow/FeatureContext.cs | 27 - .../Runtime/Flow/FeatureContext.cs.meta | 11 - .../Assets/FlowScope/Runtime/Flow/GameFlow.cs | 285 ---- .../FlowScope/Runtime/Flow/GameFlow.cs.meta | 11 - .../FlowScope/Runtime/Flow/GameFlowState.cs | 13 - .../Runtime/Flow/GameFlowState.cs.meta | 11 - .../Assets/FlowScope/Runtime/Flow/IFeature.cs | 12 - .../FlowScope/Runtime/Flow/IFeature.cs.meta | 11 - .../Runtime/FlowScope.Runtime.asmdef | 4 +- .../Assets/FlowScope/Runtime/Resources.meta | 8 - .../Runtime/Resources/IResourceBackend.cs | 18 - .../Resources/IResourceBackend.cs.meta | 11 - .../Runtime/Resources/IResourceGroup.cs | 10 - .../Runtime/Resources/IResourceGroup.cs.meta | 11 - .../Runtime/Resources/IResourceHandle.cs | 11 - .../Runtime/Resources/IResourceHandle.cs.meta | 11 - .../Runtime/Resources/IResourceService.cs | 21 - .../Resources/IResourceService.cs.meta | 11 - .../Runtime/Resources/ResourceEntry.cs | 74 -- .../Runtime/Resources/ResourceEntry.cs.meta | 11 - .../Runtime/Resources/ResourceGroup.cs | 44 - .../Runtime/Resources/ResourceGroup.cs.meta | 11 - .../Runtime/Resources/ResourceHandle.cs | 51 - .../Runtime/Resources/ResourceHandle.cs.meta | 11 - .../Runtime/Resources/ResourceService.cs | 239 ---- .../Runtime/Resources/ResourceService.cs.meta | 11 - My project/Assets/FlowScope/Runtime/Save.meta | 8 - .../FlowScope/Runtime/Save/FileSaveStorage.cs | 93 -- .../Runtime/Save/FileSaveStorage.cs.meta | 11 - .../FlowScope/Runtime/Save/ISaveMigration.cs | 11 - .../Runtime/Save/ISaveMigration.cs.meta | 11 - .../FlowScope/Runtime/Save/ISaveService.cs | 13 - .../Runtime/Save/ISaveService.cs.meta | 11 - .../Runtime/Save/JsonSaveSerializer.cs | 119 -- .../Runtime/Save/JsonSaveSerializer.cs.meta | 11 - .../Runtime/Save/PlayerPrefsSaveStorage.cs | 55 - .../Save/PlayerPrefsSaveStorage.cs.meta | 11 - .../FlowScope/Runtime/Save/SaveEnvelope.cs | 8 - .../Runtime/Save/SaveEnvelope.cs.meta | 11 - .../Runtime/Save/SaveMigrationRegistry.cs | 74 -- .../Save/SaveMigrationRegistry.cs.meta | 11 - .../FlowScope/Runtime/Save/SaveService.cs | 81 -- .../Runtime/Save/SaveService.cs.meta | 11 - My project/Assets/FlowScope/Runtime/UI.meta | 8 - .../FlowScope/Runtime/UI/IUIPreloadService.cs | 16 - .../Runtime/UI/IUIPreloadService.cs.meta | 11 - .../Runtime/UI/IUIScreenNavigator.cs | 19 - .../Runtime/UI/IUIScreenNavigator.cs.meta | 11 - .../FlowScope/Runtime/UI/PanelStrategy.cs | 8 - .../Runtime/UI/PanelStrategy.cs.meta | 11 - .../Assets/FlowScope/Runtime/UI/UILayer.cs | 73 - .../FlowScope/Runtime/UI/UILayer.cs.meta | 11 - .../Assets/FlowScope/Runtime/UI/UIManager.cs | 266 ---- .../FlowScope/Runtime/UI/UIManager.cs.meta | 11 - .../FlowScope/Runtime/UI/UIPanelAttribute.cs | 42 - .../Runtime/UI/UIPanelAttribute.cs.meta | 11 - .../FlowScope/Runtime/UI/UIPanelBase.cs | 31 - .../FlowScope/Runtime/UI/UIPanelBase.cs.meta | 11 - .../FlowScope/Runtime/UI/UIPanelRecord.cs | 28 - .../Runtime/UI/UIPanelRecord.cs.meta | 11 - .../FlowScope/Runtime/UI/UIPreloadService.cs | 89 -- .../Runtime/UI/UIPreloadService.cs.meta | 11 - .../FlowScope/Runtime/UI/UIScreenNavigator.cs | 50 - .../Runtime/UI/UIScreenNavigator.cs.meta | 11 - My project/Assets/FlowScope/Samples.meta | 8 - .../Assets/FlowScope/Samples/MainMenuP0.meta | 8 - .../FlowScope/Samples/MainMenuP0/Configs.meta | 8 - .../MainMenuP0/Configs/player_start.json | 3 - .../MainMenuP0/Configs/player_start.json.meta | 7 - .../FlowScope.Samples.MainMenuP0.asmdef | 17 - .../FlowScope.Samples.MainMenuP0.asmdef.meta | 7 - .../FlowScope/Samples/MainMenuP0/Prefabs.meta | 8 - .../MainMenuP0/Prefabs/MainMenuPanel.prefab | 453 ------- .../Prefabs/MainMenuPanel.prefab.meta | 7 - .../FlowScope/Samples/MainMenuP0/Scenes.meta | 8 - .../MainMenuP0/Scenes/MainMenuP0.unity | 440 ------- .../MainMenuP0/Scenes/MainMenuP0.unity.meta | 7 - .../FlowScope/Samples/MainMenuP0/Scripts.meta | 8 - .../MainMenuP0/Scripts/GameBootstrap.cs | 225 ---- .../MainMenuP0/Scripts/GameBootstrap.cs.meta | 11 - .../MainMenuP0/Scripts/MainMenuFeature.cs | 45 - .../Scripts/MainMenuFeature.cs.meta | 11 - .../MainMenuP0/Scripts/MainMenuPanel.cs | 62 - .../MainMenuP0/Scripts/MainMenuPanel.cs.meta | 11 - .../MainMenuP0/Scripts/MainMenuViewModel.cs | 24 - .../Scripts/MainMenuViewModel.cs.meta | 11 - .../Samples/MainMenuP0/Scripts/PlayerData.cs | 9 - .../MainMenuP0/Scripts/PlayerData.cs.meta | 11 - .../FlowScope/Tests/EditMode/Config.meta | 8 - .../EditMode/Config/ConfigExtensionTests.cs | 91 -- .../Config/ConfigExtensionTests.cs.meta | 11 - .../Config/JsonConfigProviderTests.cs | 114 -- .../Config/JsonConfigProviderTests.cs.meta | 11 - .../EditMode/Core/Container/ContainerTests.cs | 56 +- .../Assets/FlowScope/Tests/EditMode/Data.meta | 8 - .../EditMode/Data/DataSerializationTests.cs | 86 -- .../Data/DataSerializationTests.cs.meta | 11 - .../Assets/FlowScope/Tests/EditMode/Flow.meta | 8 - .../Tests/EditMode/Flow/FeatureBaseTests.cs | 89 -- .../EditMode/Flow/FeatureBaseTests.cs.meta | 11 - .../Tests/EditMode/Flow/GameFlowTests.cs | 340 ----- .../Tests/EditMode/Flow/GameFlowTests.cs.meta | 11 - .../EditMode/FlowScope.Tests.EditMode.asmdef | 4 +- .../FlowScope/Tests/EditMode/Resources.meta | 8 - .../EditMode/Resources/ResourceGroupTests.cs | 56 - .../Resources/ResourceGroupTests.cs.meta | 11 - .../Resources/ResourceServiceBackendTests.cs | 220 ---- .../ResourceServiceBackendTests.cs.meta | 11 - .../Assets/FlowScope/Tests/EditMode/Save.meta | 8 - .../Tests/EditMode/Save/SaveMigrationTests.cs | 69 - .../EditMode/Save/SaveMigrationTests.cs.meta | 11 - .../Tests/EditMode/Save/SaveServiceTests.cs | 140 -- .../EditMode/Save/SaveServiceTests.cs.meta | 11 - .../Assets/FlowScope/Tests/PlayMode.meta | 8 - .../FlowScope/Tests/PlayMode/Audio.meta | 8 - .../Tests/PlayMode/Audio/AudioServiceTests.cs | 394 ------ .../PlayMode/Audio/AudioServiceTests.cs.meta | 11 - .../PlayMode/FlowScope.Tests.PlayMode.asmdef | 25 - .../FlowScope.Tests.PlayMode.asmdef.meta | 7 - .../FlowScope/Tests/PlayMode/Resources.meta | 8 - .../AddressablesResourceBackendTests.cs | 16 - .../AddressablesResourceBackendTests.cs.meta | 11 - .../FlowScope/Tests/PlayMode/Samples.meta | 8 - .../Tests/PlayMode/Samples/MainMenuP0Tests.cs | 156 --- .../PlayMode/Samples/MainMenuP0Tests.cs.meta | 11 - .../Assets/FlowScope/Tests/PlayMode/UI.meta | 8 - .../Tests/PlayMode/UI/UIManagerTests.cs | 361 ----- .../Tests/PlayMode/UI/UIManagerTests.cs.meta | 11 - .../PlayMode/UI/UIPreloadServiceTests.cs | 115 -- .../PlayMode/UI/UIPreloadServiceTests.cs.meta | 11 - .../PlayMode/UI/UIScreenNavigatorTests.cs | 156 --- .../UI/UIScreenNavigatorTests.cs.meta | 11 - .../Tests/PlayMode/UI/UITestHelpers.cs | 104 -- .../Tests/PlayMode/UI/UITestHelpers.cs.meta | 11 - ...scope-feature-architecture-requirements.md | 578 ++++++++ ...ure-scope-container-implementation-spec.md | 778 +++++++++++ ...ure-scope-container-implementation-plan.md | 1170 +++++++++++++++++ 188 files changed, 2531 insertions(+), 8605 deletions(-) delete mode 100644 My project/Assets/FlowScope/Addressables.meta delete mode 100644 My project/Assets/FlowScope/Addressables/AddressablesResourceBackend.cs delete mode 100644 My project/Assets/FlowScope/Addressables/AddressablesResourceBackend.cs.meta delete mode 100644 My project/Assets/FlowScope/Addressables/AddressablesResourceService.cs delete mode 100644 My project/Assets/FlowScope/Addressables/AddressablesResourceService.cs.meta delete mode 100644 My project/Assets/FlowScope/Addressables/FlowScope.Addressables.asmdef delete mode 100644 My project/Assets/FlowScope/Addressables/FlowScope.Addressables.asmdef.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Audio.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/AudioHandle.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/AudioHandle.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/AudioService.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/AudioService.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/AudioServiceConfig.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/AudioServiceConfig.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/IAudioHandle.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/IAudioHandle.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/IAudioService.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Audio/IAudioService.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Common.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Common/ResultLog.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Common/ResultLog.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Config.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Config/FileConfigSource.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Config/FileConfigSource.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Config/IConfigParser.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Config/IConfigParser.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Config/IConfigProvider.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Config/IConfigProvider.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Config/IConfigRow.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Config/IConfigRow.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Config/IConfigSource.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Config/IConfigSource.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Config/InMemoryConfigSource.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Config/InMemoryConfigSource.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Config/JsonConfigParser.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Config/JsonConfigParser.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Config/JsonConfigProvider.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Config/JsonConfigProvider.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Core/Container/GeneratedFactories.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Core/Container/GeneratedFactories.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Core/Container/InjectableAttribute.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Core/Container/InjectableAttribute.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Core/Container/ReflectionFactoryBuilder.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Core/Container/ReflectionFactoryBuilder.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Data.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Data/ReactivePropertyJsonConverter.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Data/ReactivePropertyJsonConverter.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Flow.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/FeatureBase.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/FeatureBase.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/FeatureContext.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/FeatureContext.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/GameFlow.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/GameFlow.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/GameFlowState.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/GameFlowState.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/IFeature.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Flow/IFeature.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Resources.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/IResourceBackend.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/IResourceBackend.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/IResourceGroup.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/IResourceGroup.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/IResourceHandle.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/IResourceHandle.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/IResourceService.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/IResourceService.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/ResourceEntry.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/ResourceEntry.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/ResourceGroup.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/ResourceGroup.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/ResourceHandle.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/ResourceHandle.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/ResourceService.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Resources/ResourceService.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Save.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Save/FileSaveStorage.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Save/FileSaveStorage.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Save/ISaveMigration.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Save/ISaveMigration.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Save/ISaveService.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Save/ISaveService.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Save/JsonSaveSerializer.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Save/JsonSaveSerializer.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Save/PlayerPrefsSaveStorage.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Save/PlayerPrefsSaveStorage.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Save/SaveEnvelope.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Save/SaveEnvelope.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Save/SaveMigrationRegistry.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Save/SaveMigrationRegistry.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/Save/SaveService.cs delete mode 100644 My project/Assets/FlowScope/Runtime/Save/SaveService.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/IUIPreloadService.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/IUIPreloadService.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/IUIScreenNavigator.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/IUIScreenNavigator.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/PanelStrategy.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/PanelStrategy.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UILayer.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UILayer.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIManager.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIManager.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIPanelAttribute.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIPanelAttribute.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIPanelBase.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIPanelBase.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIPanelRecord.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIPanelRecord.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIPreloadService.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIPreloadService.cs.meta delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIScreenNavigator.cs delete mode 100644 My project/Assets/FlowScope/Runtime/UI/UIScreenNavigator.cs.meta delete mode 100644 My project/Assets/FlowScope/Samples.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Configs.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Configs/player_start.json delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Configs/player_start.json.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/FlowScope.Samples.MainMenuP0.asmdef delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/FlowScope.Samples.MainMenuP0.asmdef.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs/MainMenuPanel.prefab delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs/MainMenuPanel.prefab.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scenes.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scenes/MainMenuP0.unity delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scenes/MainMenuP0.unity.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/GameBootstrap.cs delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/GameBootstrap.cs.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/MainMenuFeature.cs delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/MainMenuFeature.cs.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/MainMenuPanel.cs delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/MainMenuPanel.cs.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/MainMenuViewModel.cs delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/MainMenuViewModel.cs.meta delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/PlayerData.cs delete mode 100644 My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/PlayerData.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Config.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Config/ConfigExtensionTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Config/ConfigExtensionTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Config/JsonConfigProviderTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Config/JsonConfigProviderTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Data.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Data/DataSerializationTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Data/DataSerializationTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Flow.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Flow/FeatureBaseTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Flow/FeatureBaseTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Flow/GameFlowTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Flow/GameFlowTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Resources.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Resources/ResourceGroupTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Resources/ResourceGroupTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Resources/ResourceServiceBackendTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Resources/ResourceServiceBackendTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Save.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Save/SaveMigrationTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Save/SaveMigrationTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Save/SaveServiceTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/EditMode/Save/SaveServiceTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/Audio.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/Audio/AudioServiceTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/Audio/AudioServiceTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/FlowScope.Tests.PlayMode.asmdef delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/FlowScope.Tests.PlayMode.asmdef.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/Resources.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/Resources/AddressablesResourceBackendTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/Resources/AddressablesResourceBackendTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/Samples.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/Samples/MainMenuP0Tests.cs delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/Samples/MainMenuP0Tests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/UI.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/UI/UIManagerTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/UI/UIManagerTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/UI/UIPreloadServiceTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/UI/UIPreloadServiceTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/UI/UIScreenNavigatorTests.cs delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/UI/UIScreenNavigatorTests.cs.meta delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/UI/UITestHelpers.cs delete mode 100644 My project/Assets/FlowScope/Tests/PlayMode/UI/UITestHelpers.cs.meta create mode 100644 docs/requirements/scope-feature-architecture-requirements.md create mode 100644 docs/specs/architecture-scope-container-implementation-spec.md create mode 100644 docs/superpowers/plans/2026-06-17-architecture-scope-container-implementation-plan.md diff --git a/My project/Assets/FlowScope/Addressables.meta b/My project/Assets/FlowScope/Addressables.meta deleted file mode 100644 index 2fb5190..0000000 --- a/My project/Assets/FlowScope/Addressables.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e74ee61e34d742b9b44057032c6431bb -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Addressables/AddressablesResourceBackend.cs b/My project/Assets/FlowScope/Addressables/AddressablesResourceBackend.cs deleted file mode 100644 index 8ef9b1b..0000000 --- a/My project/Assets/FlowScope/Addressables/AddressablesResourceBackend.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using FlowScope.Resources; -using UnityAddressables = UnityEngine.AddressableAssets.Addressables; - -namespace FlowScope.Addressables -{ - public sealed class AddressablesResourceBackend : IResourceBackend - { - public string Name => "Addressables"; - - public async Task LoadAsync(string key, CancellationToken cancellationToken) - where T : class - { - var handle = UnityAddressables.LoadAssetAsync(key); - await WaitWithCancellation(handle.Task, cancellationToken); - return handle.Result; - } - - public void Release(string key, T asset) - where T : class - { - UnityAddressables.Release(asset); - } - - private static async Task WaitWithCancellation(Task task, CancellationToken cancellationToken) - { - if (!cancellationToken.CanBeCanceled) - { - await task; - return; - } - - var cancellation = new TaskCompletionSource(); - using (cancellationToken.Register(() => cancellation.TrySetResult(true))) - { - if (await Task.WhenAny(task, cancellation.Task) == cancellation.Task) - { - throw new OperationCanceledException(cancellationToken); - } - } - - await task; - } - } -} diff --git a/My project/Assets/FlowScope/Addressables/AddressablesResourceBackend.cs.meta b/My project/Assets/FlowScope/Addressables/AddressablesResourceBackend.cs.meta deleted file mode 100644 index d8f38df..0000000 --- a/My project/Assets/FlowScope/Addressables/AddressablesResourceBackend.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f65b4f61d3a34358bf48957eb3a14dd7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Addressables/AddressablesResourceService.cs b/My project/Assets/FlowScope/Addressables/AddressablesResourceService.cs deleted file mode 100644 index d715a0c..0000000 --- a/My project/Assets/FlowScope/Addressables/AddressablesResourceService.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using FlowScope.Addressables; - -namespace FlowScope.Resources -{ - public sealed class AddressablesResourceService : IResourceService, ICompletedResourceService - { - private readonly ResourceService _inner; - - public AddressablesResourceService() - : this(new AddressablesResourceBackend()) - { - } - - public AddressablesResourceService(IResourceBackend backend) - { - _inner = new ResourceService(backend); - } - - public Task> LoadAsync(string key, CancellationToken cancellationToken) - where T : class - { - return _inner.LoadAsync(key, cancellationToken); - } - - public IResourceGroup CreateGroup() - { - return _inner.CreateGroup(); - } - - public bool TryLoadCompleted(string key, out IResourceHandle handle) - where T : class - { - return _inner.TryLoadCompleted(key, out handle); - } - } -} diff --git a/My project/Assets/FlowScope/Addressables/AddressablesResourceService.cs.meta b/My project/Assets/FlowScope/Addressables/AddressablesResourceService.cs.meta deleted file mode 100644 index b66f952..0000000 --- a/My project/Assets/FlowScope/Addressables/AddressablesResourceService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 62c87792aac14414b46ac0eb3e716f25 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Addressables/FlowScope.Addressables.asmdef b/My project/Assets/FlowScope/Addressables/FlowScope.Addressables.asmdef deleted file mode 100644 index ab7704a..0000000 --- a/My project/Assets/FlowScope/Addressables/FlowScope.Addressables.asmdef +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "FlowScope.Addressables", - "rootNamespace": "FlowScope.Addressables", - "references": [ - "FlowScope.Runtime", - "Unity.Addressables", - "Unity.ResourceManager" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} diff --git a/My project/Assets/FlowScope/Addressables/FlowScope.Addressables.asmdef.meta b/My project/Assets/FlowScope/Addressables/FlowScope.Addressables.asmdef.meta deleted file mode 100644 index b4194a7..0000000 --- a/My project/Assets/FlowScope/Addressables/FlowScope.Addressables.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 917e69d4247b4f548a5951d84e7d35db -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Audio.meta b/My project/Assets/FlowScope/Runtime/Audio.meta deleted file mode 100644 index ac38d9b..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: faa0e59581ea46ed8994f743336decdc -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Audio/AudioHandle.cs b/My project/Assets/FlowScope/Runtime/Audio/AudioHandle.cs deleted file mode 100644 index 1d8c61d..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/AudioHandle.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace FlowScope.Audio -{ - public sealed class AudioHandle : IAudioHandle - { - private readonly Func _isPlaying; - private readonly Action _stop; - - internal AudioHandle(Func isPlaying, Action stop) - { - _isPlaying = isPlaying ?? throw new ArgumentNullException(nameof(isPlaying)); - _stop = stop ?? throw new ArgumentNullException(nameof(stop)); - } - - public bool IsPlaying => _isPlaying(); - - public void Stop(float fadeOut = 0f) - { - _stop(fadeOut); - } - - internal static AudioHandle Stopped { get; } = new AudioHandle(() => false, _ => { }); - } -} diff --git a/My project/Assets/FlowScope/Runtime/Audio/AudioHandle.cs.meta b/My project/Assets/FlowScope/Runtime/Audio/AudioHandle.cs.meta deleted file mode 100644 index 270aa05..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/AudioHandle.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9e7da42c17284465ab9a68bec5387f19 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Audio/AudioService.cs b/My project/Assets/FlowScope/Runtime/Audio/AudioService.cs deleted file mode 100644 index f3ea89d..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/AudioService.cs +++ /dev/null @@ -1,392 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using FlowScope.Resources; -using UnityEngine; - -namespace FlowScope.Audio -{ - public sealed class AudioService : MonoBehaviour, IAudioService - { - private readonly List _sfxSlots = new(); - private IResourceService _resources; - private AudioServiceConfig _config; - private AudioSource _bgmSource; - private IResourceHandle _bgmResource; - private Coroutine _bgmFade; - private float _bgmVolume = 1f; - private float _sfxVolume = 1f; - private bool _mute; - private int _playSequence; - - public AudioService Initialize(IResourceService resources, AudioServiceConfig config = null) - { - _resources = resources ?? throw new ArgumentNullException(nameof(resources)); - _config = config ?? new AudioServiceConfig(); - if (_config.SfxPoolSize < 0) - { - _config.SfxPoolSize = 0; - } - - return this; - } - - public IAudioHandle PlayBgm(string key, bool loop = true, float fadeIn = 0f) - { - EnsureInitialized(); - var clipHandle = LoadClipIfCompleted(key); - return PlayBgm(clipHandle, loop, fadeIn); - } - - public async Task PlayBgmAsync( - string key, - bool loop = true, - float fadeIn = 0f, - CancellationToken cancellationToken = default) - { - EnsureInitialized(); - var clipHandle = await LoadClipAsync(key, cancellationToken); - return PlayBgm(clipHandle, loop, fadeIn); - } - - public IAudioHandle PlaySfx(string key) - { - EnsureInitialized(); - var clipHandle = LoadClipIfCompleted(key); - var slot = GetSfxSlot(key); - if (slot == null) - { - clipHandle.Dispose(); - return AudioHandle.Stopped; - } - - return PlaySfx(slot, clipHandle); - } - - public async Task PlaySfxAsync( - string key, - CancellationToken cancellationToken = default) - { - EnsureInitialized(); - var clipHandle = await LoadClipAsync(key, cancellationToken); - var slot = GetSfxSlot(key); - if (slot == null) - { - clipHandle.Dispose(); - return AudioHandle.Stopped; - } - - return PlaySfx(slot, clipHandle); - } - - public void StopBgm(float fadeOut = 0f) - { - StopBgmSource(_bgmSource, fadeOut); - } - - public void SetBgmVolume(float volume) - { - _bgmVolume = Mathf.Clamp01(volume); - if (_bgmSource != null) - { - _bgmSource.volume = EffectiveBgmVolume; - } - } - - public void SetSfxVolume(float volume) - { - _sfxVolume = Mathf.Clamp01(volume); - foreach (var slot in _sfxSlots) - { - if (slot.Source != null) - { - slot.Source.volume = EffectiveSfxVolume; - } - } - } - - public void SetMute(bool mute) - { - _mute = mute; - if (_bgmSource != null) - { - _bgmSource.volume = EffectiveBgmVolume; - } - - foreach (var slot in _sfxSlots) - { - if (slot.Source != null) - { - slot.Source.volume = EffectiveSfxVolume; - } - } - } - - private IAudioHandle PlayBgm(IResourceHandle clipHandle, bool loop, float fadeIn) - { - StopBgm(); - _bgmSource = gameObject.AddComponent(); - _bgmResource = clipHandle; - _bgmSource.clip = clipHandle.Asset; - _bgmSource.loop = loop; - _bgmSource.volume = fadeIn > 0f ? 0f : EffectiveBgmVolume; - _bgmSource.Play(); - - if (fadeIn > 0f) - { - _bgmFade = StartCoroutine(FadeVolume(_bgmSource, 0f, EffectiveBgmVolume, fadeIn, null)); - } - - var source = _bgmSource; - return new AudioHandle( - () => source != null && source.isPlaying, - fadeOut => StopBgmSource(source, fadeOut)); - } - - private IAudioHandle PlaySfx(SfxSlot slot, IResourceHandle clipHandle) - { - slot.Release(); - slot.Resource = clipHandle; - slot.Source.clip = clipHandle.Asset; - slot.Source.loop = false; - slot.Source.volume = EffectiveSfxVolume; - slot.Sequence = ++_playSequence; - slot.Source.Play(); - - return new AudioHandle( - () => slot.Source != null && slot.Source.isPlaying, - fadeOut => StopSfxSlot(slot, fadeOut)); - } - - private float EffectiveBgmVolume => _mute ? 0f : _bgmVolume; - private float EffectiveSfxVolume => _mute ? 0f : _sfxVolume; - - private void Update() - { - foreach (var slot in _sfxSlots) - { - if (slot.Source != null && !slot.Source.isPlaying) - { - slot.Release(); - } - } - } - - private void OnDestroy() - { - StopBgm(); - foreach (var slot in _sfxSlots) - { - slot.Release(); - } - } - - private IResourceHandle LoadClipIfCompleted(string key) - { - try - { - if (!(_resources is ICompletedResourceService completedResources) || - !completedResources.TryLoadCompleted(key, out IResourceHandle handle)) - { - throw new InvalidOperationException( - $"Audio clip is not loaded synchronously: {key}. Use PlayBgmAsync or PlaySfxAsync."); - } - - return ValidateLoadedClip(key, handle); - } - catch (Exception exception) - { - throw new InvalidOperationException($"Failed to load audio clip '{key}'.", exception); - } - } - - private async Task> LoadClipAsync( - string key, - CancellationToken cancellationToken) - { - try - { - var handle = await _resources.LoadAsync(key, cancellationToken); - return ValidateLoadedClip(key, handle); - } - catch (OperationCanceledException) - { - throw; - } - catch (Exception exception) - { - throw new InvalidOperationException($"Failed to load audio clip '{key}'.", exception); - } - } - - private static IResourceHandle ValidateLoadedClip( - string key, - IResourceHandle handle) - { - if (handle == null || handle.Asset == null) - { - handle?.Dispose(); - throw new InvalidOperationException($"Audio clip is missing: {key}"); - } - - return handle; - } - - private SfxSlot GetSfxSlot(string key) - { - foreach (var slot in _sfxSlots) - { - if (slot.Source != null && !slot.Source.isPlaying) - { - return slot; - } - } - - if (_sfxSlots.Count < _config.SfxPoolSize) - { - var source = gameObject.AddComponent(); - var slot = new SfxSlot(source); - _sfxSlots.Add(slot); - return slot; - } - - if (_config.ReuseOldestWhenExhausted && _sfxSlots.Count > 0) - { - var oldest = _sfxSlots[0]; - foreach (var slot in _sfxSlots) - { - if (slot.Sequence < oldest.Sequence) - { - oldest = slot; - } - } - - oldest.Source.Stop(); - return oldest; - } - - Debug.LogWarning($"SFX pool exhausted, skipped key: {key}"); - return null; - } - - private void StopBgmSource(AudioSource source, float fadeOut) - { - if (source == null || source != _bgmSource) - { - return; - } - - if (_bgmFade != null) - { - StopCoroutine(_bgmFade); - _bgmFade = null; - } - - if (fadeOut > 0f && source.isPlaying) - { - _bgmFade = StartCoroutine(FadeVolume( - source, - source.volume, - 0f, - fadeOut, - () => CompleteBgmStop(source))); - return; - } - - CompleteBgmStop(source); - } - - private void CompleteBgmStop(AudioSource source) - { - if (source == null || source != _bgmSource) - { - return; - } - - source.Stop(); - source.volume = 0f; - Destroy(source); - _bgmSource = null; - _bgmFade = null; - _bgmResource?.Dispose(); - _bgmResource = null; - } - - private void StopSfxSlot(SfxSlot slot, float fadeOut) - { - if (slot?.Source == null || !slot.Source.isPlaying) - { - return; - } - - if (fadeOut > 0f) - { - StartCoroutine(FadeVolume( - slot.Source, - slot.Source.volume, - 0f, - fadeOut, - () => - { - slot.Source.Stop(); - slot.Release(); - })); - return; - } - - slot.Source.Stop(); - slot.Release(); - } - - private IEnumerator FadeVolume( - AudioSource source, - float from, - float to, - float duration, - Action complete) - { - var elapsed = 0f; - while (elapsed < duration && source != null) - { - elapsed += Time.deltaTime; - source.volume = Mathf.Lerp(from, to, Mathf.Clamp01(elapsed / duration)); - yield return null; - } - - if (source != null) - { - source.volume = to; - } - - complete?.Invoke(); - } - - private void EnsureInitialized() - { - if (_resources == null) - { - throw new InvalidOperationException("AudioService must be initialized before use."); - } - } - - private sealed class SfxSlot - { - public SfxSlot(AudioSource source) - { - Source = source; - } - - public AudioSource Source { get; } - public IResourceHandle Resource { get; set; } - public int Sequence { get; set; } - - public void Release() - { - Resource?.Dispose(); - Resource = null; - } - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Audio/AudioService.cs.meta b/My project/Assets/FlowScope/Runtime/Audio/AudioService.cs.meta deleted file mode 100644 index 05968b6..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/AudioService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9e81e8f0ce1a42e6a3b09bf74893b6b6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Audio/AudioServiceConfig.cs b/My project/Assets/FlowScope/Runtime/Audio/AudioServiceConfig.cs deleted file mode 100644 index d5430ca..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/AudioServiceConfig.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace FlowScope.Audio -{ - public sealed class AudioServiceConfig - { - public int SfxPoolSize = 10; - public bool ReuseOldestWhenExhausted = true; - } -} diff --git a/My project/Assets/FlowScope/Runtime/Audio/AudioServiceConfig.cs.meta b/My project/Assets/FlowScope/Runtime/Audio/AudioServiceConfig.cs.meta deleted file mode 100644 index 886ea73..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/AudioServiceConfig.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 276b2d62e26a4edcaaeba1a96a3c2917 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Audio/IAudioHandle.cs b/My project/Assets/FlowScope/Runtime/Audio/IAudioHandle.cs deleted file mode 100644 index 5bc19f4..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/IAudioHandle.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace FlowScope.Audio -{ - public interface IAudioHandle - { - void Stop(float fadeOut = 0f); - bool IsPlaying { get; } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Audio/IAudioHandle.cs.meta b/My project/Assets/FlowScope/Runtime/Audio/IAudioHandle.cs.meta deleted file mode 100644 index efcdb8e..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/IAudioHandle.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 780afa085183438eaa9b372219113d62 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Audio/IAudioService.cs b/My project/Assets/FlowScope/Runtime/Audio/IAudioService.cs deleted file mode 100644 index 7bf8038..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/IAudioService.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Audio -{ - public interface IAudioService - { - IAudioHandle PlayBgm(string key, bool loop = true, float fadeIn = 0f); - Task PlayBgmAsync( - string key, - bool loop = true, - float fadeIn = 0f, - CancellationToken cancellationToken = default); - - IAudioHandle PlaySfx(string key); - Task PlaySfxAsync( - string key, - CancellationToken cancellationToken = default); - - void StopBgm(float fadeOut = 0f); - void SetBgmVolume(float volume); - void SetSfxVolume(float volume); - void SetMute(bool mute); - } -} diff --git a/My project/Assets/FlowScope/Runtime/Audio/IAudioService.cs.meta b/My project/Assets/FlowScope/Runtime/Audio/IAudioService.cs.meta deleted file mode 100644 index a7da8dc..0000000 --- a/My project/Assets/FlowScope/Runtime/Audio/IAudioService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2763bff6b4ca4ac2ae5b9e5f764ad984 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Common.meta b/My project/Assets/FlowScope/Runtime/Common.meta deleted file mode 100644 index 51e39c3..0000000 --- a/My project/Assets/FlowScope/Runtime/Common.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 76e811c4a8bd4f6497926d5befb64b83 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Common/ResultLog.cs b/My project/Assets/FlowScope/Runtime/Common/ResultLog.cs deleted file mode 100644 index 1944e35..0000000 --- a/My project/Assets/FlowScope/Runtime/Common/ResultLog.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; - -namespace FlowScope.Common -{ - public sealed class ResultLog - { - private readonly List _warnings = new(); - private readonly List _errors = new(); - - public IReadOnlyList Warnings => _warnings; - public IReadOnlyList Errors => _errors; - public bool HasErrors => _errors.Count > 0; - - public void AddWarning(string message) => _warnings.Add(message); - public void AddError(string message) => _errors.Add(message); - public void Clear() - { - _warnings.Clear(); - _errors.Clear(); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Common/ResultLog.cs.meta b/My project/Assets/FlowScope/Runtime/Common/ResultLog.cs.meta deleted file mode 100644 index d1c7401..0000000 --- a/My project/Assets/FlowScope/Runtime/Common/ResultLog.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a4063b7b41014f9399532dd3cc83e68f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Config.meta b/My project/Assets/FlowScope/Runtime/Config.meta deleted file mode 100644 index 5d6f27b..0000000 --- a/My project/Assets/FlowScope/Runtime/Config.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2f421e0a585f4a279d8db9410eb82711 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Config/FileConfigSource.cs b/My project/Assets/FlowScope/Runtime/Config/FileConfigSource.cs deleted file mode 100644 index be05e9a..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/FileConfigSource.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Config -{ - public sealed class FileConfigSource : IConfigSource - { - private readonly string _rootPath; - - public FileConfigSource(string rootPath, string name = "File") - { - _rootPath = string.IsNullOrWhiteSpace(rootPath) - ? throw new ArgumentException("Config root path is required.", nameof(rootPath)) - : rootPath; - Name = string.IsNullOrWhiteSpace(name) - ? throw new ArgumentException("Config source name is required.", nameof(name)) - : name; - } - - public string Name { get; } - - public Task LoadTextAsync(string fileName, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - var path = Path.Combine(_rootPath, fileName); - return Task.Run(() => File.ReadAllText(path), cancellationToken); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Config/FileConfigSource.cs.meta b/My project/Assets/FlowScope/Runtime/Config/FileConfigSource.cs.meta deleted file mode 100644 index 1fbea3e..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/FileConfigSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8d50cd860ba849a1aa7647deba4e71db -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Config/IConfigParser.cs b/My project/Assets/FlowScope/Runtime/Config/IConfigParser.cs deleted file mode 100644 index b620c14..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/IConfigParser.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; - -namespace FlowScope.Config -{ - public interface IConfigParser - { - string Format { get; } - - IReadOnlyList ParseRows( - string fileName, - string text) - where T : class, IConfigRow; - } -} diff --git a/My project/Assets/FlowScope/Runtime/Config/IConfigParser.cs.meta b/My project/Assets/FlowScope/Runtime/Config/IConfigParser.cs.meta deleted file mode 100644 index 90e757e..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/IConfigParser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0d22229e25964ea29b3c6d153507b1db -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Config/IConfigProvider.cs b/My project/Assets/FlowScope/Runtime/Config/IConfigProvider.cs deleted file mode 100644 index 7d3ce88..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/IConfigProvider.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Config -{ - public interface IConfigProvider - { - Task LoadAllAsync(CancellationToken cancellationToken); - T Get(int id) where T : class, IConfigRow; - IReadOnlyList GetAll() where T : class, IConfigRow; - } -} diff --git a/My project/Assets/FlowScope/Runtime/Config/IConfigProvider.cs.meta b/My project/Assets/FlowScope/Runtime/Config/IConfigProvider.cs.meta deleted file mode 100644 index 2ae68b0..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/IConfigProvider.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: af3d9a24ab0e4c6ebe3bf906cfd9e2bb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Config/IConfigRow.cs b/My project/Assets/FlowScope/Runtime/Config/IConfigRow.cs deleted file mode 100644 index 58fef28..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/IConfigRow.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FlowScope.Config -{ - public interface IConfigRow - { - int Id { get; } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Config/IConfigRow.cs.meta b/My project/Assets/FlowScope/Runtime/Config/IConfigRow.cs.meta deleted file mode 100644 index 420e72b..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/IConfigRow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 20d7e0e8230e4df1b5afa8000ef26fea -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Config/IConfigSource.cs b/My project/Assets/FlowScope/Runtime/Config/IConfigSource.cs deleted file mode 100644 index 4fec809..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/IConfigSource.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Config -{ - public interface IConfigSource - { - string Name { get; } - - Task LoadTextAsync( - string fileName, - CancellationToken cancellationToken); - } -} diff --git a/My project/Assets/FlowScope/Runtime/Config/IConfigSource.cs.meta b/My project/Assets/FlowScope/Runtime/Config/IConfigSource.cs.meta deleted file mode 100644 index e84d3af..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/IConfigSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 708db2a1c26743f3994b5d8beb1a03f8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Config/InMemoryConfigSource.cs b/My project/Assets/FlowScope/Runtime/Config/InMemoryConfigSource.cs deleted file mode 100644 index 55ad6a2..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/InMemoryConfigSource.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Config -{ - public sealed class InMemoryConfigSource : IConfigSource - { - private readonly Dictionary _files; - - public InMemoryConfigSource( - IReadOnlyDictionary files, - string name = "InMemory") - { - _files = files != null - ? new Dictionary(files) - : throw new ArgumentNullException(nameof(files)); - Name = string.IsNullOrWhiteSpace(name) - ? throw new ArgumentException("Config source name is required.", nameof(name)) - : name; - } - - public string Name { get; } - - public Task LoadTextAsync(string fileName, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - if (!_files.TryGetValue(fileName, out var text)) - { - throw new InvalidOperationException($"Config file is missing: {fileName}"); - } - - return Task.FromResult(text); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Config/InMemoryConfigSource.cs.meta b/My project/Assets/FlowScope/Runtime/Config/InMemoryConfigSource.cs.meta deleted file mode 100644 index dcdce36..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/InMemoryConfigSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 607d9b20e7f04565929ea5876e5c25e1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Config/JsonConfigParser.cs b/My project/Assets/FlowScope/Runtime/Config/JsonConfigParser.cs deleted file mode 100644 index 2cb4263..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/JsonConfigParser.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using FlowScope.Data; - -namespace FlowScope.Config -{ - public sealed class JsonConfigParser : IConfigParser - { - public string Format => "json"; - - public IReadOnlyList ParseRows(string fileName, string text) - where T : class, IConfigRow - { - return ReactivePropertyJsonConverter.DeserializeArray(text); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Config/JsonConfigParser.cs.meta b/My project/Assets/FlowScope/Runtime/Config/JsonConfigParser.cs.meta deleted file mode 100644 index cf41d48..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/JsonConfigParser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f60f8a8e66394f26a20ed6f5ef314c63 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Config/JsonConfigProvider.cs b/My project/Assets/FlowScope/Runtime/Config/JsonConfigProvider.cs deleted file mode 100644 index 1e495b4..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/JsonConfigProvider.cs +++ /dev/null @@ -1,166 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Config -{ - public sealed class JsonConfigProvider : IConfigProvider - { - private readonly IReadOnlyList _mappings; - private readonly Dictionary _rowsByType = new(); - - public JsonConfigProvider(IReadOnlyList mappings) - { - _mappings = mappings ?? throw new ArgumentNullException(nameof(mappings)); - } - - public static ConfigMapping Mapping(string fileName, Func> loadTextAsync) - where T : class, IConfigRow - { - return Mapping( - fileName, - new DelegateConfigSource(fileName, loadTextAsync), - new JsonConfigParser()); - } - - public static ConfigMapping Mapping( - string fileName, - IConfigSource source, - IConfigParser parser) - where T : class, IConfigRow - { - return new ConfigMapping(typeof(T), fileName, source, parser); - } - - public async Task LoadAllAsync(CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - var loadedRows = new Dictionary(); - - foreach (var mapping in _mappings) - { - cancellationToken.ThrowIfCancellationRequested(); - string json; - try - { - json = await mapping.Source.LoadTextAsync(mapping.FileName, cancellationToken); - } - catch (OperationCanceledException) - { - throw; - } - catch (Exception exception) - { - throw new InvalidOperationException( - $"Failed to load config file '{mapping.FileName}' from source '{mapping.Source.Name}'.", - exception); - } - - try - { - loadedRows[mapping.RowType] = mapping.Parse(json); - } - catch (Exception exception) when (exception is not OperationCanceledException) - { - throw new InvalidOperationException( - $"Failed to parse config file '{mapping.FileName}': {exception.GetBaseException().Message}", - exception); - } - } - - _rowsByType.Clear(); - foreach (var pair in loadedRows) - { - _rowsByType[pair.Key] = pair.Value; - } - } - - public T Get(int id) where T : class, IConfigRow - { - return _rowsByType.TryGetValue(typeof(T), out var table) && - table is Dictionary rows && - rows.TryGetValue(id, out var row) - ? row - : null; - } - - public IReadOnlyList GetAll() where T : class, IConfigRow - { - if (!_rowsByType.TryGetValue(typeof(T), out var table) || table is not Dictionary rows) - { - return Array.Empty(); - } - - return new List(rows.Values); - } - - public sealed class ConfigMapping - { - private readonly MethodInfo _parseRowsMethod; - - internal ConfigMapping( - Type rowType, - string fileName, - IConfigSource source, - IConfigParser parser) - { - RowType = rowType ?? throw new ArgumentNullException(nameof(rowType)); - FileName = string.IsNullOrWhiteSpace(fileName) - ? throw new ArgumentException("Config file name is required.", nameof(fileName)) - : fileName; - Source = source ?? throw new ArgumentNullException(nameof(source)); - Parser = parser ?? throw new ArgumentNullException(nameof(parser)); - _parseRowsMethod = typeof(IConfigParser) - .GetMethod(nameof(IConfigParser.ParseRows)) - .MakeGenericMethod(rowType); - } - - public Type RowType { get; } - public string FileName { get; } - public IConfigSource Source { get; } - public IConfigParser Parser { get; } - - internal object Parse(string json) - { - var rows = (System.Collections.IEnumerable)_parseRowsMethod.Invoke( - Parser, - new object[] { FileName, json }); - var byIdType = typeof(Dictionary<,>).MakeGenericType(typeof(int), RowType); - var byId = (System.Collections.IDictionary)Activator.CreateInstance(byIdType); - foreach (IConfigRow row in rows) - { - if (byId.Contains(row.Id)) - { - throw new InvalidOperationException($"Duplicate config id {row.Id} for {RowType.Name}."); - } - - byId.Add(row.Id, row); - } - - return byId; - } - } - - private sealed class DelegateConfigSource : IConfigSource - { - private readonly Func> _loadTextAsync; - - public DelegateConfigSource( - string fileName, - Func> loadTextAsync) - { - Name = fileName; - _loadTextAsync = loadTextAsync ?? throw new ArgumentNullException(nameof(loadTextAsync)); - } - - public string Name { get; } - - public Task LoadTextAsync(string fileName, CancellationToken cancellationToken) - { - return _loadTextAsync(cancellationToken); - } - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Config/JsonConfigProvider.cs.meta b/My project/Assets/FlowScope/Runtime/Config/JsonConfigProvider.cs.meta deleted file mode 100644 index 08df55f..0000000 --- a/My project/Assets/FlowScope/Runtime/Config/JsonConfigProvider.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0b6c05d7a1d74798901d3efcc51cb7c4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Core/Container/Container.cs b/My project/Assets/FlowScope/Runtime/Core/Container/Container.cs index 7443ce8..d0fd9f4 100644 --- a/My project/Assets/FlowScope/Runtime/Core/Container/Container.cs +++ b/My project/Assets/FlowScope/Runtime/Core/Container/Container.cs @@ -99,28 +99,6 @@ namespace FlowScope.Container return RegisterBuiltFactory(new ServiceKey(serviceType, name), implementationType); } - public void RegisterType() - where TImplementation : TInterface - { - ThrowIfDisposed(); - - RegisterType(typeof(TInterface), typeof(TImplementation)); - } - - public void RegisterType() - { - ThrowIfDisposed(); - - RegisterType(typeof(TImplementation), typeof(TImplementation)); - } - - public void RegisterAssembly() - { - ThrowIfDisposed(); - - GeneratedFactories.RegisterAssembly(this); - } - public T Resolve() { return Resolve(null); @@ -233,25 +211,6 @@ namespace FlowScope.Container return ResolveRegistration(key, registration); } - internal void RegisterFactory(Type serviceType, Func factory) - { - ThrowIfDisposed(); - - if (serviceType == null) - { - throw new ArgumentNullException(nameof(serviceType)); - } - - if (factory == null) - { - throw new ArgumentNullException(nameof(factory)); - } - - RegisterLocal( - new ServiceKey(serviceType, null), - ContainerRegistration.ForFactory(this, factory, ServiceLifetime.Singleton)); - } - internal void RegisterBuilt(ServiceKey serviceKey, ContainerRegistration registration) { ThrowIfDisposed(); @@ -263,32 +222,11 @@ namespace FlowScope.Container _ownedDisposables.Add(disposable); } - private void RegisterType(Type serviceType, Type implementationType) - { - if (!serviceType.IsAssignableFrom(implementationType)) - { - throw new InvalidOperationException($"{FormatType(implementationType)} cannot be assigned to {FormatType(serviceType)}."); - } - - if (!GeneratedFactories.TryGetFactory(implementationType, out var factory)) - { - throw new InvalidOperationException( - $"No generated factory registered for {FormatType(implementationType)}. Use GeneratedFactories.Register, ReflectionFactoryBuilder.RegisterType, or RegisterFactory before resolving this type."); - } - - RegisterFactory(serviceType, factory); - } - private ContainerRegistrationBuilder RegisterBuiltFactory( ServiceKey serviceKey, Type implementationType) { - Func factory; - if (!GeneratedFactories.TryGetFactory(implementationType, out factory)) - { - factory = BuildFactory(implementationType); - } - + var factory = BuildFactory(implementationType); return new ContainerRegistrationBuilder(this, serviceKey, factory); } diff --git a/My project/Assets/FlowScope/Runtime/Core/Container/GeneratedFactories.cs b/My project/Assets/FlowScope/Runtime/Core/Container/GeneratedFactories.cs deleted file mode 100644 index c786b9c..0000000 --- a/My project/Assets/FlowScope/Runtime/Core/Container/GeneratedFactories.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace FlowScope.Container -{ - public static class GeneratedFactories - { - private static readonly Dictionary> Factories = new Dictionary>(); - - public static void Register(Func factory) - { - if (factory == null) - { - throw new ArgumentNullException(nameof(factory)); - } - - Factories[typeof(TImplementation)] = c => factory(c); - } - - public static bool TryGetFactory(Type implementationType, out Func factory) - { - if (implementationType == null) - { - throw new ArgumentNullException(nameof(implementationType)); - } - - return Factories.TryGetValue(implementationType, out factory); - } - - public static void RegisterAssembly(Container container) - { - if (container == null) - { - throw new ArgumentNullException(nameof(container)); - } - - foreach (var pair in Factories) - { - container.RegisterFactory(pair.Key, pair.Value); - } - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Core/Container/GeneratedFactories.cs.meta b/My project/Assets/FlowScope/Runtime/Core/Container/GeneratedFactories.cs.meta deleted file mode 100644 index 4a88501..0000000 --- a/My project/Assets/FlowScope/Runtime/Core/Container/GeneratedFactories.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fc50e3c76ee147b59d2663e872ced1a0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Core/Container/InjectableAttribute.cs b/My project/Assets/FlowScope/Runtime/Core/Container/InjectableAttribute.cs deleted file mode 100644 index 72b4ff4..0000000 --- a/My project/Assets/FlowScope/Runtime/Core/Container/InjectableAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace FlowScope.Container -{ - [AttributeUsage(AttributeTargets.Class)] - public sealed class InjectableAttribute : Attribute - { - } -} diff --git a/My project/Assets/FlowScope/Runtime/Core/Container/InjectableAttribute.cs.meta b/My project/Assets/FlowScope/Runtime/Core/Container/InjectableAttribute.cs.meta deleted file mode 100644 index 9cc5a56..0000000 --- a/My project/Assets/FlowScope/Runtime/Core/Container/InjectableAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 039257eaaf6c4ac198a3504795b52df0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Core/Container/ReflectionFactoryBuilder.cs b/My project/Assets/FlowScope/Runtime/Core/Container/ReflectionFactoryBuilder.cs deleted file mode 100644 index 6f802d4..0000000 --- a/My project/Assets/FlowScope/Runtime/Core/Container/ReflectionFactoryBuilder.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; - -namespace FlowScope.Container -{ - public static class ReflectionFactoryBuilder - { - public static void RegisterType(Container container) - { - if (container == null) - { - throw new ArgumentNullException(nameof(container)); - } - - container.RegisterFactory(typeof(TImplementation), BuildFactory(typeof(TImplementation))); - } - - public static void RegisterType(Container container) - where TImplementation : TInterface - { - if (container == null) - { - throw new ArgumentNullException(nameof(container)); - } - - container.RegisterFactory(typeof(TInterface), BuildFactory(typeof(TImplementation))); - } - - public static Func BuildFactory(Type implementationType) - { - if (implementationType == null) - { - throw new ArgumentNullException(nameof(implementationType)); - } - - if (!Attribute.IsDefined(implementationType, typeof(InjectableAttribute))) - { - throw new InvalidOperationException($"{FormatType(implementationType)} must be marked with InjectableAttribute for reflection registration."); - } - - var constructors = implementationType.GetConstructors(BindingFlags.Public | BindingFlags.Instance); - if (constructors.Length != 1) - { - throw new InvalidOperationException($"{FormatType(implementationType)} must declare exactly one public constructor."); - } - - var constructor = constructors[0]; - var parameters = constructor.GetParameters(); - - return container => - { - var arguments = parameters - .Select(parameter => container.Resolve(parameter.ParameterType)) - .ToArray(); - return constructor.Invoke(arguments); - }; - } - - private static string FormatType(Type type) => type.FullName ?? type.Name; - } -} diff --git a/My project/Assets/FlowScope/Runtime/Core/Container/ReflectionFactoryBuilder.cs.meta b/My project/Assets/FlowScope/Runtime/Core/Container/ReflectionFactoryBuilder.cs.meta deleted file mode 100644 index 68d1a48..0000000 --- a/My project/Assets/FlowScope/Runtime/Core/Container/ReflectionFactoryBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1d2827e4c16e4b4ea60a84f709d54665 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Data.meta b/My project/Assets/FlowScope/Runtime/Data.meta deleted file mode 100644 index c9cbd31..0000000 --- a/My project/Assets/FlowScope/Runtime/Data.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 67eb0ac45b8b4cf8bafcb604dd6e0e11 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Data/ReactivePropertyJsonConverter.cs b/My project/Assets/FlowScope/Runtime/Data/ReactivePropertyJsonConverter.cs deleted file mode 100644 index 1fa94dc..0000000 --- a/My project/Assets/FlowScope/Runtime/Data/ReactivePropertyJsonConverter.cs +++ /dev/null @@ -1,731 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Reflection; -using System.Text; - -namespace FlowScope.Data -{ - public static class ReactivePropertyJsonConverter - { - public static string SerializeObject(object value) - { - return SimpleJson.Write(ToJsonValue(value)); - } - - public static T DeserializeObject(string json) - { - var instance = (T)Activator.CreateInstance(typeof(T), true); - PopulateObject(json, instance); - return instance; - } - - public static void PopulateObject(string json, object target) - { - if (target == null) - { - throw new ArgumentNullException(nameof(target)); - } - - if (SimpleJson.Parse(json) is not Dictionary values) - { - throw new InvalidOperationException($"JSON root must be an object for {target.GetType().Name}."); - } - - PopulateFromDictionary(values, target); - } - - public static IReadOnlyList DeserializeArray(string json) where T : class - { - if (SimpleJson.Parse(json) is not List rows) - { - throw new InvalidOperationException("JSON root must be an array."); - } - - var results = new List(rows.Count); - foreach (var row in rows) - { - if (row is not Dictionary rowValues) - { - throw new InvalidOperationException($"JSON row must be an object for {typeof(T).Name}."); - } - - var instance = (T)Activator.CreateInstance(typeof(T), true); - PopulateFromDictionary(rowValues, instance); - results.Add(instance); - } - - return results; - } - - internal static object ToJsonValue(object value) - { - if (value == null) - { - return null; - } - - var type = value.GetType(); - if (IsSimple(type)) - { - return value; - } - - if (TryGetReactivePropertyValue(value, out var reactiveValue)) - { - return ToJsonValue(reactiveValue); - } - - if (IsReactiveCollection(type) || value is IEnumerable && value is not string) - { - var array = new List(); - foreach (var item in (IEnumerable)value) - { - array.Add(ToJsonValue(item)); - } - - return array; - } - - var result = new Dictionary(); - foreach (var property in GetSerializableProperties(type)) - { - result[property.Name] = ToJsonValue(property.GetValue(value)); - } - - foreach (var field in GetSerializableFields(type)) - { - result[field.Name] = ToJsonValue(field.GetValue(value)); - } - - return result; - } - - internal static object ConvertValue(object value, Type targetType, string fieldName) - { - if (value == null) - { - if (targetType.IsValueType && Nullable.GetUnderlyingType(targetType) == null) - { - throw new InvalidOperationException($"Field '{fieldName}' cannot be null."); - } - - return null; - } - - var nullableType = Nullable.GetUnderlyingType(targetType); - if (nullableType != null) - { - return ConvertValue(value, nullableType, fieldName); - } - - if (targetType == typeof(string)) - { - if (value is string text) - { - return text; - } - - throw TypeMismatch(fieldName, targetType, value); - } - - if (targetType == typeof(bool)) - { - if (value is bool boolValue) - { - return boolValue; - } - - throw TypeMismatch(fieldName, targetType, value); - } - - if (targetType.IsEnum) - { - if (value is string enumName) - { - return Enum.Parse(targetType, enumName); - } - - return Enum.ToObject(targetType, Convert.ToInt32(value, CultureInfo.InvariantCulture)); - } - - if (IsNumeric(targetType)) - { - if (value is string || value is bool) - { - throw TypeMismatch(fieldName, targetType, value); - } - - return Convert.ChangeType(value, targetType, CultureInfo.InvariantCulture); - } - - if (value is Dictionary nested) - { - var instance = Activator.CreateInstance(targetType, true); - PopulateFromDictionary(nested, instance); - return instance; - } - - throw TypeMismatch(fieldName, targetType, value); - } - - private static void PopulateFromDictionary(IReadOnlyDictionary values, object target) - { - var members = GetWritableMembers(target.GetType()); - foreach (var pair in values) - { - if (!members.TryGetValue(pair.Key, out var member)) - { - continue; - } - - PopulateMember(target, member, pair.Value, pair.Key); - } - } - - private static void PopulateMember(object target, MemberInfo member, object value, string fieldName) - { - var memberType = GetMemberType(member); - var currentValue = GetMemberValue(member, target); - - if (IsReactiveProperty(memberType)) - { - var valueProperty = memberType.GetProperty("Value", BindingFlags.Instance | BindingFlags.Public); - var converted = ConvertValue(value, valueProperty.PropertyType, fieldName); - valueProperty.SetValue(currentValue, converted); - return; - } - - if (IsReactiveCollection(memberType) || IsMutableCollection(memberType, currentValue)) - { - PopulateCollection(currentValue, memberType, value, fieldName); - return; - } - - if (CanSet(member)) - { - SetMemberValue(member, target, ConvertValue(value, memberType, fieldName)); - } - } - - private static void PopulateCollection(object collection, Type collectionType, object value, string fieldName) - { - if (value is not List rows) - { - throw TypeMismatch(fieldName, collectionType, value); - } - - var itemType = GetCollectionItemType(collectionType); - collectionType.GetMethod("Clear", Type.EmptyTypes)?.Invoke(collection, Array.Empty()); - var addMethod = collectionType.GetMethod("Add", new[] { itemType }); - if (addMethod == null) - { - throw new InvalidOperationException($"Field '{fieldName}' collection does not expose Add."); - } - - foreach (var row in rows) - { - addMethod.Invoke(collection, new[] { ConvertValue(row, itemType, fieldName) }); - } - } - - private static Dictionary GetWritableMembers(Type type) - { - var members = new Dictionary(StringComparer.OrdinalIgnoreCase); - foreach (var property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)) - { - if (property.GetIndexParameters().Length == 0) - { - members[property.Name] = property; - } - } - - foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.Public)) - { - members[field.Name] = field; - } - - return members; - } - - private static IEnumerable GetSerializableProperties(Type type) - { - foreach (var property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)) - { - if (property.GetIndexParameters().Length == 0 && property.CanRead) - { - yield return property; - } - } - } - - private static IEnumerable GetSerializableFields(Type type) - { - return type.GetFields(BindingFlags.Instance | BindingFlags.Public); - } - - private static Type GetMemberType(MemberInfo member) - { - return member switch - { - PropertyInfo property => property.PropertyType, - FieldInfo field => field.FieldType, - _ => throw new NotSupportedException(member.MemberType.ToString()) - }; - } - - private static object GetMemberValue(MemberInfo member, object target) - { - return member switch - { - PropertyInfo property => property.GetValue(target), - FieldInfo field => field.GetValue(target), - _ => null - }; - } - - private static void SetMemberValue(MemberInfo member, object target, object value) - { - switch (member) - { - case PropertyInfo property: - property.SetValue(target, value); - break; - case FieldInfo field: - field.SetValue(target, value); - break; - } - } - - private static bool CanSet(MemberInfo member) - { - return member switch - { - PropertyInfo property => property.CanWrite, - FieldInfo field => !field.IsInitOnly, - _ => false - }; - } - - private static bool TryGetReactivePropertyValue(object value, out object reactiveValue) - { - reactiveValue = null; - if (!IsReactiveProperty(value.GetType())) - { - return false; - } - - reactiveValue = value.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public)?.GetValue(value); - return true; - } - - private static bool IsReactiveProperty(Type type) - { - return type.IsGenericType && type.GetGenericTypeDefinition().FullName == "R3.ReactiveProperty`1"; - } - - private static bool IsReactiveCollection(Type type) - { - return type.IsGenericType && type.GetGenericTypeDefinition().FullName == "R3.ReactiveCollection`1"; - } - - private static bool IsMutableCollection(Type type, object value) - { - return value != null && - type != typeof(string) && - GetCollectionItemType(type) != null && - type.GetMethod("Clear", Type.EmptyTypes) != null; - } - - private static Type GetCollectionItemType(Type type) - { - if (type.IsArray) - { - return type.GetElementType(); - } - - if (type.IsGenericType && type.GetGenericArguments().Length == 1) - { - return type.GetGenericArguments()[0]; - } - - foreach (var interfaceType in type.GetInterfaces()) - { - if (interfaceType.IsGenericType && - interfaceType.GetGenericTypeDefinition() == typeof(ICollection<>)) - { - return interfaceType.GetGenericArguments()[0]; - } - } - - return null; - } - - private static bool IsSimple(Type type) - { - type = Nullable.GetUnderlyingType(type) ?? type; - return type.IsPrimitive || type.IsEnum || type == typeof(string) || type == typeof(decimal); - } - - private static bool IsNumeric(Type type) - { - type = Nullable.GetUnderlyingType(type) ?? type; - return type == typeof(byte) || type == typeof(sbyte) || - type == typeof(short) || type == typeof(ushort) || - type == typeof(int) || type == typeof(uint) || - type == typeof(long) || type == typeof(ulong) || - type == typeof(float) || type == typeof(double) || - type == typeof(decimal); - } - - private static InvalidOperationException TypeMismatch(string fieldName, Type targetType, object value) - { - return new InvalidOperationException( - $"Field '{fieldName}' expected {targetType.Name}, but JSON value was {value.GetType().Name}."); - } - - internal static class SimpleJson - { - public static object Parse(string json) - { - var parser = new Parser(json); - var value = parser.ParseValue(); - parser.SkipWhitespace(); - if (!parser.IsEnd) - { - throw new FormatException("Unexpected trailing JSON content."); - } - - return value; - } - - public static string Write(object value) - { - var builder = new StringBuilder(); - WriteValue(builder, value); - return builder.ToString(); - } - - private static void WriteValue(StringBuilder builder, object value) - { - switch (value) - { - case null: - builder.Append("null"); - break; - case string text: - WriteString(builder, text); - break; - case bool boolValue: - builder.Append(boolValue ? "true" : "false"); - break; - case IDictionary map: - WriteObject(builder, map); - break; - case IEnumerable array: - WriteArray(builder, array); - break; - case float or double or decimal: - builder.Append(Convert.ToString(value, CultureInfo.InvariantCulture)); - break; - default: - if (value.GetType().IsEnum) - { - WriteString(builder, value.ToString()); - } - else - { - builder.Append(Convert.ToString(value, CultureInfo.InvariantCulture)); - } - - break; - } - } - - private static void WriteObject(StringBuilder builder, IDictionary map) - { - builder.Append('{'); - var first = true; - foreach (var pair in map) - { - if (!first) - { - builder.Append(','); - } - - first = false; - WriteString(builder, pair.Key); - builder.Append(':'); - WriteValue(builder, pair.Value); - } - - builder.Append('}'); - } - - private static void WriteArray(StringBuilder builder, IEnumerable values) - { - builder.Append('['); - var first = true; - foreach (var value in values) - { - if (!first) - { - builder.Append(','); - } - - first = false; - WriteValue(builder, value); - } - - builder.Append(']'); - } - - private static void WriteString(StringBuilder builder, string value) - { - builder.Append('"'); - foreach (var character in value) - { - switch (character) - { - case '"': - builder.Append("\\\""); - break; - case '\\': - builder.Append("\\\\"); - break; - case '\n': - builder.Append("\\n"); - break; - case '\r': - builder.Append("\\r"); - break; - case '\t': - builder.Append("\\t"); - break; - default: - builder.Append(character); - break; - } - } - - builder.Append('"'); - } - - private sealed class Parser - { - private readonly string _json; - private int _index; - - public Parser(string json) - { - _json = json ?? throw new ArgumentNullException(nameof(json)); - } - - public bool IsEnd => _index >= _json.Length; - - public object ParseValue() - { - SkipWhitespace(); - if (IsEnd) - { - throw new FormatException("Unexpected end of JSON."); - } - - return _json[_index] switch - { - '{' => ParseObject(), - '[' => ParseArray(), - '"' => ParseString(), - 't' => ParseLiteral("true", true), - 'f' => ParseLiteral("false", false), - 'n' => ParseLiteral("null", null), - _ => ParseNumber() - }; - } - - public void SkipWhitespace() - { - while (!IsEnd && char.IsWhiteSpace(_json[_index])) - { - _index++; - } - } - - private Dictionary ParseObject() - { - Expect('{'); - var map = new Dictionary(StringComparer.OrdinalIgnoreCase); - SkipWhitespace(); - if (TryConsume('}')) - { - return map; - } - - while (true) - { - SkipWhitespace(); - var key = ParseString(); - SkipWhitespace(); - Expect(':'); - map[key] = ParseValue(); - SkipWhitespace(); - if (TryConsume('}')) - { - return map; - } - - Expect(','); - } - } - - private List ParseArray() - { - Expect('['); - var array = new List(); - SkipWhitespace(); - if (TryConsume(']')) - { - return array; - } - - while (true) - { - array.Add(ParseValue()); - SkipWhitespace(); - if (TryConsume(']')) - { - return array; - } - - Expect(','); - } - } - - private string ParseString() - { - Expect('"'); - var builder = new StringBuilder(); - while (!IsEnd) - { - var character = _json[_index++]; - if (character == '"') - { - return builder.ToString(); - } - - if (character != '\\') - { - builder.Append(character); - continue; - } - - if (IsEnd) - { - throw new FormatException("Unexpected end of JSON escape sequence."); - } - - var escaped = _json[_index++]; - builder.Append(escaped switch - { - '"' => '"', - '\\' => '\\', - '/' => '/', - 'b' => '\b', - 'f' => '\f', - 'n' => '\n', - 'r' => '\r', - 't' => '\t', - _ => throw new FormatException($"Unsupported JSON escape '\\{escaped}'.") - }); - } - - throw new FormatException("Unterminated JSON string."); - } - - private object ParseNumber() - { - var start = _index; - if (!IsEnd && _json[_index] == '-') - { - _index++; - } - - while (!IsEnd && char.IsDigit(_json[_index])) - { - _index++; - } - - var isFloatingPoint = false; - if (!IsEnd && _json[_index] == '.') - { - isFloatingPoint = true; - _index++; - while (!IsEnd && char.IsDigit(_json[_index])) - { - _index++; - } - } - - if (!IsEnd && (_json[_index] == 'e' || _json[_index] == 'E')) - { - isFloatingPoint = true; - _index++; - if (!IsEnd && (_json[_index] == '+' || _json[_index] == '-')) - { - _index++; - } - - while (!IsEnd && char.IsDigit(_json[_index])) - { - _index++; - } - } - - var text = _json.Substring(start, _index - start); - if (string.IsNullOrEmpty(text) || text == "-") - { - throw new FormatException("Invalid JSON number."); - } - - return isFloatingPoint - ? double.Parse(text, CultureInfo.InvariantCulture) - : long.Parse(text, CultureInfo.InvariantCulture); - } - - private object ParseLiteral(string literal, object value) - { - if (_index + literal.Length > _json.Length || - string.CompareOrdinal(_json, _index, literal, 0, literal.Length) != 0) - { - throw new FormatException($"Invalid JSON literal near index {_index}."); - } - - _index += literal.Length; - return value; - } - - private bool TryConsume(char expected) - { - if (!IsEnd && _json[_index] == expected) - { - _index++; - return true; - } - - return false; - } - - private void Expect(char expected) - { - if (IsEnd || _json[_index] != expected) - { - throw new FormatException($"Expected '{expected}' near index {_index}."); - } - - _index++; - } - } - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Data/ReactivePropertyJsonConverter.cs.meta b/My project/Assets/FlowScope/Runtime/Data/ReactivePropertyJsonConverter.cs.meta deleted file mode 100644 index c89b997..0000000 --- a/My project/Assets/FlowScope/Runtime/Data/ReactivePropertyJsonConverter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0c9f18f342e54f8d9a4dbdc61b74a2d1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Flow.meta b/My project/Assets/FlowScope/Runtime/Flow.meta deleted file mode 100644 index 250b3ec..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 87d135bef01743c29768ef28ce8acf69 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Flow/FeatureBase.cs b/My project/Assets/FlowScope/Runtime/Flow/FeatureBase.cs deleted file mode 100644 index 5c01986..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/FeatureBase.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Threading.Tasks; - -namespace FlowScope.Flow -{ - public abstract class FeatureBase : IFeature - { - protected FeatureContext Context { get; private set; } - - public virtual Task LoadAsync(FeatureContext context) - { - Context = context; - return Task.CompletedTask; - } - - public virtual Task EnterAsync(FeatureContext context) - { - return Task.CompletedTask; - } - - public virtual Task ExitAsync(FeatureContext context) - { - context?.Disposables.Clear(); - return Task.CompletedTask; - } - - public virtual void Dispose() - { - Context = null; - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Flow/FeatureBase.cs.meta b/My project/Assets/FlowScope/Runtime/Flow/FeatureBase.cs.meta deleted file mode 100644 index 7ba1d72..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/FeatureBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a5f4e3fb56394e719bff30e8edd4abaa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Flow/FeatureContext.cs b/My project/Assets/FlowScope/Runtime/Flow/FeatureContext.cs deleted file mode 100644 index d9e5d4e..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/FeatureContext.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Threading; -using FlowScope.Resources; -using R3; -using ContainerType = FlowScope.Container.Container; - -namespace FlowScope.Flow -{ - public sealed class FeatureContext - { - public FeatureContext( - ContainerType scope, - IResourceGroup resources, - CompositeDisposable disposables, - CancellationToken cancellationToken) - { - Scope = scope; - Resources = resources; - Disposables = disposables; - CancellationToken = cancellationToken; - } - - public ContainerType Scope { get; } - public IResourceGroup Resources { get; } - public CompositeDisposable Disposables { get; } - public CancellationToken CancellationToken { get; } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Flow/FeatureContext.cs.meta b/My project/Assets/FlowScope/Runtime/Flow/FeatureContext.cs.meta deleted file mode 100644 index 6b6a9e6..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/FeatureContext.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4196008ec1434af48d1307f18d14b655 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Flow/GameFlow.cs b/My project/Assets/FlowScope/Runtime/Flow/GameFlow.cs deleted file mode 100644 index f1883b0..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/GameFlow.cs +++ /dev/null @@ -1,285 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using FlowScope.Config; -using FlowScope.Resources; -using R3; -using UnityEngine; -using ContainerType = FlowScope.Container.Container; - -namespace FlowScope.Flow -{ - public sealed class GameFlow - { - private ContainerType _root; - private IFeature _activeFeature; - private FeatureContext _activeContext; - - public GameFlowState State { get; private set; } = GameFlowState.Idle; - - public async Task StartupAsync( - ContainerType root, - CancellationToken cancellationToken) - where TInitialFeature : IFeature - { - EnsureState(nameof(StartupAsync), GameFlowState.Idle); - _root = root ?? throw new ArgumentNullException(nameof(root)); - State = GameFlowState.Starting; - - IFeature feature = null; - FeatureContext context = null; - - try - { - var config = _root.Resolve(); - await config.LoadAllAsync(cancellationToken); - - (feature, context) = CreateFeature(cancellationToken); - await feature.LoadAsync(context); - await feature.EnterAsync(context); - - _activeFeature = feature; - _activeContext = context; - State = GameFlowState.Running; - } - catch - { - BestEffortDisposeFeature(feature); - BestEffortDisposeContext(context); - _activeFeature = null; - _activeContext = null; - State = GameFlowState.Idle; - throw; - } - } - - public async Task SwitchToAsync(CancellationToken cancellationToken) - where TFeature : IFeature - { - EnsureState( - nameof(SwitchToAsync), - GameFlowState.Running, - GameFlowState.NoActiveFeature); - - State = GameFlowState.Switching; - await CleanupActiveFeatureAsync(); - - IFeature nextFeature = null; - FeatureContext nextContext = null; - - try - { - (nextFeature, nextContext) = CreateFeature(cancellationToken); - await nextFeature.LoadAsync(nextContext); - await nextFeature.EnterAsync(nextContext); - - _activeFeature = nextFeature; - _activeContext = nextContext; - State = GameFlowState.Running; - } - catch - { - BestEffortDisposeFeature(nextFeature); - BestEffortDisposeContext(nextContext); - _activeFeature = null; - _activeContext = null; - State = GameFlowState.NoActiveFeature; - throw; - } - } - - public async Task ShutdownAsync(CancellationToken cancellationToken) - { - EnsureState( - nameof(ShutdownAsync), - GameFlowState.Running, - GameFlowState.NoActiveFeature); - - State = GameFlowState.ShuttingDown; - Exception cancellationException = null; - - try - { - cancellationToken.ThrowIfCancellationRequested(); - } - catch (OperationCanceledException exception) - { - cancellationException = exception; - } - - await CleanupActiveFeatureAsync(); - BestEffortDisposeRoot(); - State = GameFlowState.Disposed; - - if (cancellationException != null) - { - throw cancellationException; - } - } - - private (IFeature Feature, FeatureContext Context) CreateFeature( - CancellationToken cancellationToken) - where TFeature : IFeature - { - ContainerType scope = null; - IResourceGroup resources = null; - FeatureContext context = null; - - try - { - scope = _root.CreateScope(); - var resourceService = _root.Resolve(); - resources = resourceService.CreateGroup(); - context = new FeatureContext( - scope, - resources, - new CompositeDisposable(), - cancellationToken); - var feature = scope.Resolve(); - return (feature, context); - } - catch - { - if (context != null) - { - BestEffortDisposeContext(context); - } - else - { - BestEffortDisposePartialContext(resources, scope); - } - - throw; - } - } - - private async Task CleanupActiveFeatureAsync() - { - var feature = _activeFeature; - var context = _activeContext; - _activeFeature = null; - _activeContext = null; - - if (feature != null) - { - try - { - await feature.ExitAsync(context); - } - catch (Exception exception) - { - Debug.LogError(exception); - } - - BestEffortDisposeFeature(feature); - } - - BestEffortDisposeContext(context); - } - - private void BestEffortDisposeFeature(IFeature feature) - { - if (feature == null) - { - return; - } - - try - { - feature.Dispose(); - } - catch (Exception exception) - { - Debug.LogError(exception); - } - } - - private void BestEffortDisposeContext(FeatureContext context) - { - if (context == null) - { - return; - } - - try - { - context.Disposables.Clear(); - } - catch (Exception exception) - { - Debug.LogError(exception); - } - - try - { - context.Resources?.Dispose(); - } - catch (Exception exception) - { - Debug.LogError(exception); - } - - try - { - context.Scope?.Dispose(); - } - catch (Exception exception) - { - Debug.LogError(exception); - } - } - - private void BestEffortDisposePartialContext( - IResourceGroup resources, - ContainerType scope) - { - try - { - resources?.Dispose(); - } - catch (Exception exception) - { - Debug.LogError(exception); - } - - try - { - scope?.Dispose(); - } - catch (Exception exception) - { - Debug.LogError(exception); - } - } - - private void BestEffortDisposeRoot() - { - try - { - _root?.Dispose(); - } - catch (Exception exception) - { - Debug.LogError(exception); - } - finally - { - _root = null; - } - } - - private void EnsureState(string operation, params GameFlowState[] allowedStates) - { - foreach (var allowedState in allowedStates) - { - if (State == allowedState) - { - return; - } - } - - throw new InvalidOperationException( - $"{operation} cannot run while GameFlow state is {State}."); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Flow/GameFlow.cs.meta b/My project/Assets/FlowScope/Runtime/Flow/GameFlow.cs.meta deleted file mode 100644 index 56ab886..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/GameFlow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a533908611b643259dbfcb681369d012 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Flow/GameFlowState.cs b/My project/Assets/FlowScope/Runtime/Flow/GameFlowState.cs deleted file mode 100644 index e9f3c81..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/GameFlowState.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace FlowScope.Flow -{ - public enum GameFlowState - { - Idle, - Starting, - Running, - Switching, - NoActiveFeature, - ShuttingDown, - Disposed - } -} diff --git a/My project/Assets/FlowScope/Runtime/Flow/GameFlowState.cs.meta b/My project/Assets/FlowScope/Runtime/Flow/GameFlowState.cs.meta deleted file mode 100644 index 0eac168..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/GameFlowState.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1f73ffad83dc461db1dde0b4bece5eda -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Flow/IFeature.cs b/My project/Assets/FlowScope/Runtime/Flow/IFeature.cs deleted file mode 100644 index 3cb3e97..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/IFeature.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace FlowScope.Flow -{ - public interface IFeature : IDisposable - { - Task LoadAsync(FeatureContext context); - Task EnterAsync(FeatureContext context); - Task ExitAsync(FeatureContext context); - } -} diff --git a/My project/Assets/FlowScope/Runtime/Flow/IFeature.cs.meta b/My project/Assets/FlowScope/Runtime/Flow/IFeature.cs.meta deleted file mode 100644 index 6d06d58..0000000 --- a/My project/Assets/FlowScope/Runtime/Flow/IFeature.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 749ce778d6814cf9a9fe89889025bccb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/FlowScope.Runtime.asmdef b/My project/Assets/FlowScope/Runtime/FlowScope.Runtime.asmdef index a4fae8f..c6285f2 100644 --- a/My project/Assets/FlowScope/Runtime/FlowScope.Runtime.asmdef +++ b/My project/Assets/FlowScope/Runtime/FlowScope.Runtime.asmdef @@ -1,9 +1,7 @@ { "name": "FlowScope.Runtime", "rootNamespace": "FlowScope", - "references": [ - "R3.Unity" - ], + "references": [], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, diff --git a/My project/Assets/FlowScope/Runtime/Resources.meta b/My project/Assets/FlowScope/Runtime/Resources.meta deleted file mode 100644 index f4a06ba..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2a7d670c048e4930b0a0980773a6210b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Resources/IResourceBackend.cs b/My project/Assets/FlowScope/Runtime/Resources/IResourceBackend.cs deleted file mode 100644 index c66cc17..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/IResourceBackend.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Resources -{ - public interface IResourceBackend - { - string Name { get; } - - Task LoadAsync( - string key, - CancellationToken cancellationToken) - where T : class; - - void Release(string key, T asset) - where T : class; - } -} diff --git a/My project/Assets/FlowScope/Runtime/Resources/IResourceBackend.cs.meta b/My project/Assets/FlowScope/Runtime/Resources/IResourceBackend.cs.meta deleted file mode 100644 index d89acd9..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/IResourceBackend.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 76d9b18ff17949a987f26418e1f1c978 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Resources/IResourceGroup.cs b/My project/Assets/FlowScope/Runtime/Resources/IResourceGroup.cs deleted file mode 100644 index 14de14e..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/IResourceGroup.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace FlowScope.Resources -{ - public interface IResourceGroup : IDisposable - { - void Add(IResourceHandle handle) where T : class; - int Count { get; } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Resources/IResourceGroup.cs.meta b/My project/Assets/FlowScope/Runtime/Resources/IResourceGroup.cs.meta deleted file mode 100644 index b4e64cf..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/IResourceGroup.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0e613834058f49db95c2814ab52d7cc4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Resources/IResourceHandle.cs b/My project/Assets/FlowScope/Runtime/Resources/IResourceHandle.cs deleted file mode 100644 index f293100..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/IResourceHandle.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace FlowScope.Resources -{ - public interface IResourceHandle : IDisposable where T : class - { - string Key { get; } - T Asset { get; } - bool IsDisposed { get; } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Resources/IResourceHandle.cs.meta b/My project/Assets/FlowScope/Runtime/Resources/IResourceHandle.cs.meta deleted file mode 100644 index 7577ddb..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/IResourceHandle.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f248abc2018449e3be0905dc01ef7e11 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Resources/IResourceService.cs b/My project/Assets/FlowScope/Runtime/Resources/IResourceService.cs deleted file mode 100644 index 93f5478..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/IResourceService.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Resources -{ - public interface IResourceService - { - Task> LoadAsync( - string key, - CancellationToken cancellationToken) - where T : class; - - IResourceGroup CreateGroup(); - } - - public interface ICompletedResourceService - { - bool TryLoadCompleted(string key, out IResourceHandle handle) - where T : class; - } -} diff --git a/My project/Assets/FlowScope/Runtime/Resources/IResourceService.cs.meta b/My project/Assets/FlowScope/Runtime/Resources/IResourceService.cs.meta deleted file mode 100644 index 9828ddb..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/IResourceService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 52a701ee3b744171b5e01e927c83b645 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Resources/ResourceEntry.cs b/My project/Assets/FlowScope/Runtime/Resources/ResourceEntry.cs deleted file mode 100644 index d3f0d77..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/ResourceEntry.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; - -namespace FlowScope.Resources -{ - internal sealed class ResourceEntry - { - private readonly Action _release; - private int _referenceCount; - private bool _released; - - public ResourceEntry(string key, object asset, Action release) - : this(key, asset?.GetType(), asset, (_, _, releasedAsset) => release(key, releasedAsset)) - { - } - - public ResourceEntry(string key, Type assetType, object asset, Action release) - { - Key = string.IsNullOrWhiteSpace(key) - ? throw new ArgumentException("Resource key is required.", nameof(key)) - : key; - AssetType = assetType ?? throw new ArgumentNullException(nameof(assetType)); - Asset = asset ?? throw new ArgumentNullException(nameof(asset)); - _release = release ?? throw new ArgumentNullException(nameof(release)); - } - - public string Key { get; } - public Type AssetType { get; } - public object Asset { get; private set; } - public int ReferenceCount => _referenceCount; - - public ResourceHandle CreateHandle() where T : class - { - if (_released) - { - throw new ObjectDisposedException(nameof(ResourceEntry)); - } - - _referenceCount++; - return new ResourceHandle(this); - } - - public void ReleaseHandle() - { - if (_released) - { - return; - } - - _referenceCount--; - if (_referenceCount > 0) - { - return; - } - - _released = true; - var asset = Asset; - Asset = null; - _release(Key, AssetType, asset); - } - - public void ReleaseWithoutHandle() - { - if (_released) - { - return; - } - - _released = true; - var asset = Asset; - Asset = null; - _release(Key, AssetType, asset); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Resources/ResourceEntry.cs.meta b/My project/Assets/FlowScope/Runtime/Resources/ResourceEntry.cs.meta deleted file mode 100644 index f535b2d..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/ResourceEntry.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 02477283d77540ed9be0b002bb05f37a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Resources/ResourceGroup.cs b/My project/Assets/FlowScope/Runtime/Resources/ResourceGroup.cs deleted file mode 100644 index bdfcac4..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/ResourceGroup.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace FlowScope.Resources -{ - public sealed class ResourceGroup : IResourceGroup - { - private readonly HashSet _handles = new(); - private bool _disposed; - - public int Count => _handles.Count; - - public void Add(IResourceHandle handle) where T : class - { - if (_disposed) - { - throw new ObjectDisposedException(nameof(ResourceGroup)); - } - - if (handle == null) - { - throw new ArgumentNullException(nameof(handle)); - } - - _handles.Add(handle); - } - - public void Dispose() - { - if (_disposed) - { - return; - } - - _disposed = true; - foreach (var handle in _handles) - { - handle.Dispose(); - } - - _handles.Clear(); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Resources/ResourceGroup.cs.meta b/My project/Assets/FlowScope/Runtime/Resources/ResourceGroup.cs.meta deleted file mode 100644 index 88d4a88..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/ResourceGroup.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 896ce428279a4740b44cebeb2c0b635e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Resources/ResourceHandle.cs b/My project/Assets/FlowScope/Runtime/Resources/ResourceHandle.cs deleted file mode 100644 index b571d57..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/ResourceHandle.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; - -namespace FlowScope.Resources -{ - public sealed class ResourceHandle : IResourceHandle where T : class - { - private readonly ResourceEntry _entry; - private readonly Action _release; - private T _asset; - - internal ResourceHandle(ResourceEntry entry) - { - _entry = entry ?? throw new ArgumentNullException(nameof(entry)); - Key = entry.Key; - _asset = (T)entry.Asset; - } - - public ResourceHandle(string key, T asset, Action release) - { - Key = string.IsNullOrWhiteSpace(key) - ? throw new ArgumentException("Resource key is required.", nameof(key)) - : key; - _asset = asset ?? throw new ArgumentNullException(nameof(asset)); - _release = release ?? throw new ArgumentNullException(nameof(release)); - } - - public string Key { get; } - public T Asset => IsDisposed ? null : _asset; - public bool IsDisposed { get; private set; } - - public void Dispose() - { - if (IsDisposed) - { - return; - } - - IsDisposed = true; - var asset = _asset; - _asset = null; - - if (_entry != null) - { - _entry.ReleaseHandle(); - return; - } - - _release(Key, asset); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Resources/ResourceHandle.cs.meta b/My project/Assets/FlowScope/Runtime/Resources/ResourceHandle.cs.meta deleted file mode 100644 index fd1cc36..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/ResourceHandle.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ab4e98e842c34a09a324062b57b09009 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Resources/ResourceService.cs b/My project/Assets/FlowScope/Runtime/Resources/ResourceService.cs deleted file mode 100644 index 39c5faf..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/ResourceService.cs +++ /dev/null @@ -1,239 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Resources -{ - public sealed class ResourceService : IResourceService, ICompletedResourceService - { - private readonly object _gate = new(); - private readonly IResourceBackend _backend; - private readonly Dictionary _entries = new(); - private readonly Dictionary _loads = new(); - - public ResourceService(IResourceBackend backend) - { - _backend = backend ?? throw new ArgumentNullException(nameof(backend)); - } - - public async Task> LoadAsync( - string key, - CancellationToken cancellationToken) - where T : class - { - if (string.IsNullOrWhiteSpace(key)) - { - throw new ArgumentException("Resource key is required.", nameof(key)); - } - - cancellationToken.ThrowIfCancellationRequested(); - var resourceKey = new ResourceKey(key, typeof(T)); - SharedLoad sharedLoad; - - lock (_gate) - { - if (_entries.TryGetValue(resourceKey, out var entry)) - { - return entry.CreateHandle(); - } - - if (!_loads.TryGetValue(resourceKey, out sharedLoad)) - { - sharedLoad = new SharedLoad(); - _loads.Add(resourceKey, sharedLoad); - } - - sharedLoad.WaiterCount++; - if (sharedLoad.LoadTask == null) - { - sharedLoad.LoadTask = LoadAndOwnEntryAsync(resourceKey, key, sharedLoad); - } - } - - try - { - var loaded = await WaitForSharedLoad(sharedLoad.LoadTask, cancellationToken); - lock (_gate) - { - return loaded.CreateHandle(); - } - } - catch (OperationCanceledException) - { - lock (_gate) - { - if (sharedLoad.WaiterCount > 0) - { - sharedLoad.WaiterCount--; - } - } - - throw; - } - } - - public bool TryLoadCompleted(string key, out IResourceHandle handle) - where T : class - { - if (string.IsNullOrWhiteSpace(key)) - { - throw new ArgumentException("Resource key is required.", nameof(key)); - } - - lock (_gate) - { - if (_entries.TryGetValue(new ResourceKey(key, typeof(T)), out var entry)) - { - handle = entry.CreateHandle(); - return true; - } - } - - handle = null; - return false; - } - - public IResourceGroup CreateGroup() - { - return new ResourceGroup(); - } - - private async Task LoadEntryAsync(string key) - where T : class - { - T asset; - try - { - asset = await _backend.LoadAsync(key, CancellationToken.None); - } - catch (Exception exception) when (exception is not OperationCanceledException) - { - throw new InvalidOperationException( - $"Failed to load resource '{key}' as {typeof(T).Name} from backend '{_backend.Name}'.", - exception); - } - - if (asset == null) - { - throw new InvalidOperationException( - $"Resource '{key}' returned null for {typeof(T).Name} from backend '{_backend.Name}'."); - } - - return new ResourceEntry( - key, - typeof(T), - asset, - (entryKey, assetType, releasedAsset) => - ReleaseBackendEntry(entryKey, assetType, (T)releasedAsset)); - } - - private async Task LoadAndOwnEntryAsync( - ResourceKey resourceKey, - string key, - SharedLoad sharedLoad) - where T : class - { - ResourceEntry entry = null; - try - { - entry = await LoadEntryAsync(key); - lock (_gate) - { - _loads.Remove(resourceKey); - if (sharedLoad.WaiterCount > 0) - { - _entries.Add(resourceKey, entry); - return entry; - } - } - - ReleaseEntry(entry); - return entry; - } - catch - { - lock (_gate) - { - _loads.Remove(resourceKey); - } - - throw; - } - } - - private static async Task WaitForSharedLoad( - Task loadTask, - CancellationToken cancellationToken) - { - if (!cancellationToken.CanBeCanceled) - { - return await loadTask; - } - - var cancellation = new TaskCompletionSource(); - using (cancellationToken.Register(() => cancellation.TrySetResult(true))) - { - if (await Task.WhenAny(loadTask, cancellation.Task) == cancellation.Task) - { - throw new OperationCanceledException(cancellationToken); - } - } - - return await loadTask; - } - - private void ReleaseEntry(ResourceEntry entry) - { - entry.ReleaseWithoutHandle(); - } - - private void ReleaseBackendEntry(string key, Type assetType, T asset) - where T : class - { - lock (_gate) - { - _entries.Remove(new ResourceKey(key, assetType)); - } - - _backend.Release(key, asset); - } - - private sealed class SharedLoad - { - public Task LoadTask; - public int WaiterCount; - } - - private readonly struct ResourceKey : IEquatable - { - private readonly string _key; - private readonly Type _type; - - public ResourceKey(string key, Type type) - { - _key = key; - _type = type; - } - - public bool Equals(ResourceKey other) - { - return _key == other._key && _type == other._type; - } - - public override bool Equals(object obj) - { - return obj is ResourceKey other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - return ((_key != null ? _key.GetHashCode() : 0) * 397) ^ - (_type != null ? _type.GetHashCode() : 0); - } - } - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Resources/ResourceService.cs.meta b/My project/Assets/FlowScope/Runtime/Resources/ResourceService.cs.meta deleted file mode 100644 index 622cec2..0000000 --- a/My project/Assets/FlowScope/Runtime/Resources/ResourceService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d123a5c6220843b18a09611f77e8cd31 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Save.meta b/My project/Assets/FlowScope/Runtime/Save.meta deleted file mode 100644 index fb1bcc9..0000000 --- a/My project/Assets/FlowScope/Runtime/Save.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: aade8defc2324dde8776534f5d8acccc -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Save/FileSaveStorage.cs b/My project/Assets/FlowScope/Runtime/Save/FileSaveStorage.cs deleted file mode 100644 index 92be2e5..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/FileSaveStorage.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using UnityEngine; - -namespace FlowScope.Save -{ - public interface ISaveStorage - { - Task WriteAsync(string key, byte[] data, CancellationToken cancellationToken); - Task ReadAsync(string key, CancellationToken cancellationToken); - void Delete(string key); - bool Exists(string key); - } - - public sealed class FileSaveStorage : ISaveStorage - { - private readonly string _rootDirectory; - - public FileSaveStorage(string rootDirectory = null) - { - _rootDirectory = string.IsNullOrWhiteSpace(rootDirectory) - ? Path.Combine(Application.persistentDataPath, "FlowScopeSaves") - : rootDirectory; - } - - public async Task WriteAsync(string key, byte[] data, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - if (data == null) - { - throw new ArgumentNullException(nameof(data)); - } - - Directory.CreateDirectory(_rootDirectory); - var path = GetPath(key); - using var stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, 4096, true); - await stream.WriteAsync(data, 0, data.Length, cancellationToken); - } - - public async Task ReadAsync(string key, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - var path = GetPath(key); - if (!File.Exists(path)) - { - return null; - } - - using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, true); - var data = new byte[stream.Length]; - var read = 0; - while (read < data.Length) - { - var count = await stream.ReadAsync(data, read, data.Length - read, cancellationToken); - if (count == 0) - { - break; - } - - read += count; - } - - return data; - } - - public void Delete(string key) - { - var path = GetPath(key); - if (File.Exists(path)) - { - File.Delete(path); - } - } - - public bool Exists(string key) - { - return File.Exists(GetPath(key)); - } - - private string GetPath(string key) - { - if (string.IsNullOrWhiteSpace(key)) - { - throw new ArgumentException("Save key is required.", nameof(key)); - } - - return Path.Combine(_rootDirectory, Convert.ToBase64String(Encoding.UTF8.GetBytes(key)) + ".json"); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Save/FileSaveStorage.cs.meta b/My project/Assets/FlowScope/Runtime/Save/FileSaveStorage.cs.meta deleted file mode 100644 index 059eef1..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/FileSaveStorage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 59beaa2c506548ea9f526f3784f5f938 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Save/ISaveMigration.cs b/My project/Assets/FlowScope/Runtime/Save/ISaveMigration.cs deleted file mode 100644 index 3396055..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/ISaveMigration.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FlowScope.Save -{ - public interface ISaveMigration - { - string Key { get; } - int FromVersion { get; } - int ToVersion { get; } - - string Migrate(string json); - } -} diff --git a/My project/Assets/FlowScope/Runtime/Save/ISaveMigration.cs.meta b/My project/Assets/FlowScope/Runtime/Save/ISaveMigration.cs.meta deleted file mode 100644 index bc11b72..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/ISaveMigration.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 689eab5eef8647009da3f56423bd0a3d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Save/ISaveService.cs b/My project/Assets/FlowScope/Runtime/Save/ISaveService.cs deleted file mode 100644 index f4f0256..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/ISaveService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.Save -{ - public interface ISaveService - { - Task SaveAsync(string key, T data, CancellationToken cancellationToken); - Task LoadAsync(string key, T defaultValue, CancellationToken cancellationToken); - void Delete(string key); - bool Exists(string key); - } -} diff --git a/My project/Assets/FlowScope/Runtime/Save/ISaveService.cs.meta b/My project/Assets/FlowScope/Runtime/Save/ISaveService.cs.meta deleted file mode 100644 index 369bd54..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/ISaveService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 02c1b05d79f4432dbb64923943158c57 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Save/JsonSaveSerializer.cs b/My project/Assets/FlowScope/Runtime/Save/JsonSaveSerializer.cs deleted file mode 100644 index ff99832..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/JsonSaveSerializer.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using System.Text; -using FlowScope.Data; - -namespace FlowScope.Save -{ - public interface ISaveSerializer - { - byte[] Serialize(T data); - T Deserialize(byte[] bytes); - } - - public sealed class JsonSaveSerializer : ISaveSerializer - { - private readonly int _currentVersion; - private readonly SaveMigrationRegistry _migrations; - - public JsonSaveSerializer( - int currentVersion = 1, - SaveMigrationRegistry migrations = null) - { - if (currentVersion < 1) - { - throw new ArgumentOutOfRangeException(nameof(currentVersion)); - } - - _currentVersion = currentVersion; - _migrations = migrations ?? new SaveMigrationRegistry(); - } - - public byte[] Serialize(T data) - { - return Encoding.UTF8.GetBytes(SerializeToString(data)); - } - - public T Deserialize(byte[] bytes) - { - if (bytes == null) - { - throw new ArgumentNullException(nameof(bytes)); - } - - return DeserializeFromString(Encoding.UTF8.GetString(bytes)); - } - - public string SerializeToString(T data) - { - var payload = ReactivePropertyJsonConverter.SerializeObject(data); - if (_currentVersion <= 1) - { - return payload; - } - - return ReactivePropertyJsonConverter.SerializeObject(new SaveEnvelope - { - Version = _currentVersion, - Payload = payload - }); - } - - public T DeserializeFromString(string json) - { - var instance = (T)Activator.CreateInstance(typeof(T), true); - PopulateFromString(ResolvePayload(json), instance); - return instance; - } - - public void PopulateFromString(string json, T target) - { - ReactivePropertyJsonConverter.PopulateObject(ResolvePayload(json), target); - } - - private string ResolvePayload(string json) - { - if (!TryReadEnvelope(json, out var envelope)) - { - return _currentVersion > 1 - ? _migrations.Migrate(GetMigrationKey(), 1, _currentVersion, json) - : json; - } - - if (envelope.Version == _currentVersion) - { - return envelope.Payload; - } - - if (envelope.Version > _currentVersion) - { - throw new InvalidOperationException( - $"Save version {envelope.Version} is newer than current version {_currentVersion}."); - } - - return _migrations.Migrate( - GetMigrationKey(), - envelope.Version, - _currentVersion, - envelope.Payload); - } - - private static bool TryReadEnvelope(string json, out SaveEnvelope envelope) - { - envelope = null; - try - { - envelope = ReactivePropertyJsonConverter.DeserializeObject(json); - return envelope.Version > 0 && envelope.Payload != null; - } - catch - { - return false; - } - } - - private static string GetMigrationKey() - { - return typeof(T).FullName; - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Save/JsonSaveSerializer.cs.meta b/My project/Assets/FlowScope/Runtime/Save/JsonSaveSerializer.cs.meta deleted file mode 100644 index 8edd90b..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/JsonSaveSerializer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6823b62f8e7044d0a8f7e85fc33ca10b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Save/PlayerPrefsSaveStorage.cs b/My project/Assets/FlowScope/Runtime/Save/PlayerPrefsSaveStorage.cs deleted file mode 100644 index 2598348..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/PlayerPrefsSaveStorage.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using UnityEngine; - -namespace FlowScope.Save -{ - public sealed class PlayerPrefsSaveStorage : ISaveStorage - { - private const string Prefix = "FlowScope.Save."; - - public Task WriteAsync(string key, byte[] data, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - if (data == null) - { - throw new ArgumentNullException(nameof(data)); - } - - PlayerPrefs.SetString(ToPrefsKey(key), Convert.ToBase64String(data)); - PlayerPrefs.Save(); - return Task.CompletedTask; - } - - public Task ReadAsync(string key, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - var prefsKey = ToPrefsKey(key); - return Task.FromResult(PlayerPrefs.HasKey(prefsKey) - ? Convert.FromBase64String(PlayerPrefs.GetString(prefsKey)) - : null); - } - - public void Delete(string key) - { - PlayerPrefs.DeleteKey(ToPrefsKey(key)); - PlayerPrefs.Save(); - } - - public bool Exists(string key) - { - return PlayerPrefs.HasKey(ToPrefsKey(key)); - } - - private static string ToPrefsKey(string key) - { - if (string.IsNullOrWhiteSpace(key)) - { - throw new ArgumentException("Save key is required.", nameof(key)); - } - - return Prefix + key; - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Save/PlayerPrefsSaveStorage.cs.meta b/My project/Assets/FlowScope/Runtime/Save/PlayerPrefsSaveStorage.cs.meta deleted file mode 100644 index 4a382ad..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/PlayerPrefsSaveStorage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d421a058fe6d4927ad7b3f48b3060529 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Save/SaveEnvelope.cs b/My project/Assets/FlowScope/Runtime/Save/SaveEnvelope.cs deleted file mode 100644 index f2013f0..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/SaveEnvelope.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace FlowScope.Save -{ - internal sealed class SaveEnvelope - { - public int Version { get; set; } - public string Payload { get; set; } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Save/SaveEnvelope.cs.meta b/My project/Assets/FlowScope/Runtime/Save/SaveEnvelope.cs.meta deleted file mode 100644 index 11acd8a..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/SaveEnvelope.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 67ada4b73d47420db150f34ab12a236a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Save/SaveMigrationRegistry.cs b/My project/Assets/FlowScope/Runtime/Save/SaveMigrationRegistry.cs deleted file mode 100644 index 4ee5fa6..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/SaveMigrationRegistry.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace FlowScope.Save -{ - public sealed class SaveMigrationRegistry - { - private readonly Dictionary _migrations = new(); - - public void Register(ISaveMigration migration) - { - if (migration == null) - { - throw new ArgumentNullException(nameof(migration)); - } - - _migrations[new MigrationKey(migration.Key, migration.FromVersion)] = migration; - } - - public string Migrate( - string key, - int fromVersion, - int currentVersion, - string json) - { - var current = fromVersion; - var payload = json; - while (current < currentVersion) - { - if (!_migrations.TryGetValue(new MigrationKey(key, current), out var migration) || - migration.ToVersion != current + 1) - { - throw new InvalidOperationException( - $"Missing save migration for key '{key}' from version {current}."); - } - - payload = migration.Migrate(payload); - current = migration.ToVersion; - } - - return payload; - } - - private readonly struct MigrationKey : IEquatable - { - private readonly string _key; - private readonly int _fromVersion; - - public MigrationKey(string key, int fromVersion) - { - _key = key ?? string.Empty; - _fromVersion = fromVersion; - } - - public bool Equals(MigrationKey other) - { - return _key == other._key && _fromVersion == other._fromVersion; - } - - public override bool Equals(object obj) - { - return obj is MigrationKey other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - return ((_key != null ? _key.GetHashCode() : 0) * 397) ^ _fromVersion; - } - } - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Save/SaveMigrationRegistry.cs.meta b/My project/Assets/FlowScope/Runtime/Save/SaveMigrationRegistry.cs.meta deleted file mode 100644 index e74593f..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/SaveMigrationRegistry.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3f2c3dd694c94ed59d08bcdf88d830a7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/Save/SaveService.cs b/My project/Assets/FlowScope/Runtime/Save/SaveService.cs deleted file mode 100644 index 7eb65fb..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/SaveService.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using UnityEngine; - -namespace FlowScope.Save -{ - public sealed class SaveService : ISaveService - { - private readonly ISaveStorage _storage; - private readonly ISaveSerializer _serializer; - - public SaveService(ISaveStorage storage, ISaveSerializer serializer) - { - _storage = storage ?? throw new ArgumentNullException(nameof(storage)); - _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); - } - - public async Task SaveAsync(string key, T data, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - try - { - var bytes = _serializer.Serialize(data); - await _storage.WriteAsync(key, bytes, cancellationToken); - } - catch (OperationCanceledException) - { - throw; - } - catch (Exception exception) - { - throw new InvalidOperationException($"Failed to write save key '{key}'.", exception); - } - } - - public async Task LoadAsync(string key, T defaultValue, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - byte[] bytes; - try - { - bytes = await _storage.ReadAsync(key, cancellationToken); - } - catch (OperationCanceledException) - { - throw; - } - catch (Exception exception) - { - Debug.LogWarning($"Failed to read save key '{key}': {exception.Message}"); - return defaultValue; - } - - if (bytes == null) - { - return defaultValue; - } - - try - { - return _serializer.Deserialize(bytes); - } - catch (Exception exception) - { - Debug.LogWarning($"Failed to deserialize save key '{key}': {exception.Message}"); - return defaultValue; - } - } - - public void Delete(string key) - { - _storage.Delete(key); - } - - public bool Exists(string key) - { - return _storage.Exists(key); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/Save/SaveService.cs.meta b/My project/Assets/FlowScope/Runtime/Save/SaveService.cs.meta deleted file mode 100644 index 7051a49..0000000 --- a/My project/Assets/FlowScope/Runtime/Save/SaveService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c71e93285f6c4f8287c96785fe1975d6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI.meta b/My project/Assets/FlowScope/Runtime/UI.meta deleted file mode 100644 index db9d363..0000000 --- a/My project/Assets/FlowScope/Runtime/UI.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3e730e1406e843dd957ffddac73ac8be -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/IUIPreloadService.cs b/My project/Assets/FlowScope/Runtime/UI/IUIPreloadService.cs deleted file mode 100644 index d605ce2..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/IUIPreloadService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using FlowScope.Resources; -using UnityEngine; - -namespace FlowScope.UI -{ - public interface IUIPreloadService - { - Task PreloadAsync(CancellationToken cancellationToken); - bool IsPreloaded(); - bool TryGetPreloadedHandle(out IResourceHandle handle); - void Release(); - void ReleaseAll(); - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/IUIPreloadService.cs.meta b/My project/Assets/FlowScope/Runtime/UI/IUIPreloadService.cs.meta deleted file mode 100644 index b37529e..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/IUIPreloadService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 34f5e8174a844438842b8e839ba4bb64 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/IUIScreenNavigator.cs b/My project/Assets/FlowScope/Runtime/UI/IUIScreenNavigator.cs deleted file mode 100644 index 61e06cb..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/IUIScreenNavigator.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.UI -{ - public interface IUIScreenNavigator - { - Task PushAsync( - TViewModel viewModel, - CancellationToken cancellationToken) - where TPanel : UIPanelBase; - - bool CanGoBack { get; } - - void GoBack(); - - void Clear(); - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/IUIScreenNavigator.cs.meta b/My project/Assets/FlowScope/Runtime/UI/IUIScreenNavigator.cs.meta deleted file mode 100644 index 41a739b..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/IUIScreenNavigator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d76da54cf887479d8448849a5ddb7dd8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/PanelStrategy.cs b/My project/Assets/FlowScope/Runtime/UI/PanelStrategy.cs deleted file mode 100644 index 1141c60..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/PanelStrategy.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace FlowScope.UI -{ - public enum PanelStrategy - { - Destroy, - Cache - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/PanelStrategy.cs.meta b/My project/Assets/FlowScope/Runtime/UI/PanelStrategy.cs.meta deleted file mode 100644 index aa0cadc..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/PanelStrategy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: be444a62bb9241da99d5a4fa2ff8be69 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/UILayer.cs b/My project/Assets/FlowScope/Runtime/UI/UILayer.cs deleted file mode 100644 index ea2e6af..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UILayer.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace FlowScope.UI -{ - internal sealed class UILayer - { - private readonly Stack _stack = new(); - private readonly Dictionary _cachedPanels = new(); - - public UILayer(string name, Canvas canvas, int sortOrder, PanelStrategy strategy) - { - Name = name; - Canvas = canvas; - Strategy = strategy; - Canvas.sortingOrder = sortOrder; - } - - public string Name { get; } - public Canvas Canvas { get; } - public PanelStrategy Strategy { get; } - public int Count => _stack.Count; - - public void Push(UIPanelRecord record) - { - record.IsOpen = true; - _stack.Push(record); - } - - public UIPanelRecord Peek() - { - return _stack.Peek(); - } - - public UIPanelRecord Pop() - { - var record = _stack.Pop(); - record.IsOpen = false; - return record; - } - - public bool TryGetCached(Type panelType, out UIPanelRecord record) - { - return _cachedPanels.TryGetValue(panelType, out record); - } - - public void Cache(UIPanelRecord record) - { - _cachedPanels[record.PanelType] = record; - } - - public void RemoveCached(Type panelType) - { - _cachedPanels.Remove(panelType); - } - - public bool ContainsOpen(Type panelType, out UIPanelRecord record) - { - foreach (var current in _stack) - { - if (current.PanelType == panelType) - { - record = current; - return true; - } - } - - record = null; - return false; - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/UILayer.cs.meta b/My project/Assets/FlowScope/Runtime/UI/UILayer.cs.meta deleted file mode 100644 index 3780179..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UILayer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8bf04ebbbc2f4785b5daf63b334d1a6a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/UIManager.cs b/My project/Assets/FlowScope/Runtime/UI/UIManager.cs deleted file mode 100644 index db71f29..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIManager.cs +++ /dev/null @@ -1,266 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using FlowScope.Resources; -using UnityEngine; - -namespace FlowScope.UI -{ - public sealed class UIManager - { - private readonly IResourceService _resources; - private readonly IUIPreloadService _preloadService; - private readonly Dictionary _layers = new(); - - public UIManager(IResourceService resources, IUIPreloadService preloadService = null) - { - _resources = resources ?? throw new ArgumentNullException(nameof(resources)); - _preloadService = preloadService; - } - - public void RegisterLayer( - string name, - Canvas canvas, - int sortOrder, - PanelStrategy strategy = PanelStrategy.Destroy) - { - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentException("Layer name is required.", nameof(name)); - } - - if (canvas == null) - { - throw new ArgumentNullException(nameof(canvas)); - } - - _layers[name] = new UILayer(name, canvas, sortOrder, strategy); - } - - public async Task OpenAsync( - TViewModel viewModel, - CancellationToken cancellationToken) - where TPanel : UIPanelBase - { - cancellationToken.ThrowIfCancellationRequested(); - - var attribute = GetPanelAttribute(typeof(TPanel)); - if (!_layers.TryGetValue(attribute.Layer, out var layer)) - { - throw new InvalidOperationException($"UI layer is not registered: {attribute.Layer}"); - } - - var strategy = attribute.OverrideStrategy ?? layer.Strategy; - if (strategy == PanelStrategy.Cache && - layer.TryGetCached(typeof(TPanel), out var cached) && - !cached.IsOpen) - { - return ReopenCached(cached, layer, viewModel); - } - - var path = ResolvePath(typeof(TPanel), attribute); - var handle = await LoadPanelHandleAsync(path, cancellationToken); - if (handle == null || handle.Asset == null) - { - handle?.Dispose(); - throw new InvalidOperationException($"UI panel resource is missing: {path}"); - } - - GameObject instance = null; - var ownsHandle = !IsPreloadedHandle(handle); - try - { - instance = UnityEngine.Object.Instantiate(handle.Asset, layer.Canvas.transform, false); - var panel = instance.GetComponent(); - if (panel == null) - { - throw new InvalidOperationException( - $"UI panel prefab '{path}' does not contain component {typeof(TPanel).Name}."); - } - - panel.Bind(viewModel); - instance.SetActive(true); - - var recordHandle = ownsHandle ? (IDisposable)handle : RetainedPanelHandle.Instance; - var record = new UIPanelRecord(typeof(TPanel), layer.Name, panel, recordHandle, strategy); - if (strategy == PanelStrategy.Cache) - { - layer.Cache(record); - } - - layer.Push(record); - return panel; - } - catch - { - if (instance != null) - { - UnityEngine.Object.Destroy(instance); - } - - if (ownsHandle) - { - handle.Dispose(); - } - - throw; - } - } - - public void Close() - { - var panelType = typeof(TPanel); - foreach (var layer in _layers.Values) - { - if (!layer.ContainsOpen(panelType, out var record)) - { - continue; - } - - if (!ReferenceEquals(layer.Peek(), record)) - { - throw new InvalidOperationException( - $"Cannot close non-top UI panel: {panelType.Name}"); - } - - CloseTop(layer); - return; - } - } - - public void CloseLayer(string layerName) - { - if (!_layers.TryGetValue(layerName, out var layer)) - { - throw new InvalidOperationException($"UI layer is not registered: {layerName}"); - } - - while (layer.Count > 0) - { - CloseTop(layer); - } - } - - public void CloseAll() - { - foreach (var layer in _layers.Values) - { - while (layer.Count > 0) - { - CloseTop(layer); - } - } - } - - public bool IsOpen() - { - var panelType = typeof(TPanel); - foreach (var layer in _layers.Values) - { - if (layer.ContainsOpen(panelType, out _)) - { - return true; - } - } - - return false; - } - - private static TPanel ReopenCached( - UIPanelRecord record, - UILayer layer, - TViewModel viewModel) - where TPanel : UIPanelBase - { - var panel = (TPanel)record.Panel; - panel.Bind(viewModel); - panel.gameObject.SetActive(true); - layer.Push(record); - return panel; - } - - private static void CloseTop(UILayer layer) - { - var record = layer.Pop(); - record.Panel.Unbind(); - - if (record.Strategy == PanelStrategy.Cache) - { - record.Panel.gameObject.SetActive(false); - return; - } - - layer.RemoveCached(record.PanelType); - UnityEngine.Object.Destroy(record.Panel.gameObject); - record.Handle.Dispose(); - } - - private async Task> LoadPanelHandleAsync( - string path, - CancellationToken cancellationToken) - { - if (_preloadService != null && - _preloadService.TryGetPreloadedHandle(out var preloadedHandle)) - { - return preloadedHandle; - } - - return await _resources.LoadAsync(path, cancellationToken); - } - - private bool IsPreloadedHandle(IResourceHandle handle) - { - return _preloadService != null && - _preloadService.TryGetPreloadedHandle(out var preloadedHandle) && - ReferenceEquals(preloadedHandle, handle); - } - - internal static UIPanelAttribute GetPanelAttribute(Type panelType) - { - var attribute = (UIPanelAttribute)Attribute.GetCustomAttribute( - panelType, - typeof(UIPanelAttribute)); - - if (attribute == null) - { - throw new InvalidOperationException( - $"UI panel must declare UIPanelAttribute: {panelType.Name}"); - } - - if (string.IsNullOrWhiteSpace(attribute.Layer)) - { - throw new InvalidOperationException( - $"UI panel layer is required: {panelType.Name}"); - } - - return attribute; - } - - internal static string ResolvePath(Type panelType, UIPanelAttribute attribute) - { - if (!string.IsNullOrWhiteSpace(attribute.Path)) - { - return attribute.Path; - } - - var name = panelType.Name; - const string suffix = "Panel"; - if (name.EndsWith(suffix, StringComparison.Ordinal)) - { - name = name.Substring(0, name.Length - suffix.Length); - } - - return $"UI/{name}/Prefab"; - } - - private sealed class RetainedPanelHandle : IDisposable - { - public static readonly RetainedPanelHandle Instance = new(); - - public void Dispose() - { - } - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/UIManager.cs.meta b/My project/Assets/FlowScope/Runtime/UI/UIManager.cs.meta deleted file mode 100644 index 1ae0cc5..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c83637921703494f8fd6eb6e2eda6c70 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/UIPanelAttribute.cs b/My project/Assets/FlowScope/Runtime/UI/UIPanelAttribute.cs deleted file mode 100644 index bee8408..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIPanelAttribute.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; - -namespace FlowScope.UI -{ - [AttributeUsage(AttributeTargets.Class)] - public sealed class UIPanelAttribute : Attribute - { - public UIPanelAttribute(string layer) - : this(layer, null, null) - { - } - - public UIPanelAttribute(string layer, string path) - : this(layer, path, null) - { - } - - public UIPanelAttribute(string layer, PanelStrategy overrideStrategy) - : this(layer, null, overrideStrategy) - { - } - - public UIPanelAttribute(string layer, string path, PanelStrategy overrideStrategy) - : this(layer, path, (PanelStrategy?)overrideStrategy) - { - } - - private UIPanelAttribute( - string layer, - string path, - PanelStrategy? overrideStrategy) - { - Layer = layer; - Path = path; - OverrideStrategy = overrideStrategy; - } - - public string Layer { get; } - public string Path { get; } - public PanelStrategy? OverrideStrategy { get; } - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/UIPanelAttribute.cs.meta b/My project/Assets/FlowScope/Runtime/UI/UIPanelAttribute.cs.meta deleted file mode 100644 index 38986a9..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIPanelAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b6b9266c245947bebd6cdf8c445cf712 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/UIPanelBase.cs b/My project/Assets/FlowScope/Runtime/UI/UIPanelBase.cs deleted file mode 100644 index e4cec66..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIPanelBase.cs +++ /dev/null @@ -1,31 +0,0 @@ -using R3; -using UnityEngine; - -namespace FlowScope.UI -{ - internal interface IUIPanel - { - GameObject gameObject { get; } - Transform transform { get; } - void Unbind(); - } - - public abstract class UIPanelBase : MonoBehaviour, IUIPanel - { - protected TViewModel ViewModel { get; private set; } - protected CompositeDisposable Disposables { get; } = new(); - - public void Bind(TViewModel viewModel) - { - ViewModel = viewModel; - OnBind(viewModel); - } - - public virtual void Unbind() - { - Disposables.Clear(); - } - - protected abstract void OnBind(TViewModel viewModel); - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/UIPanelBase.cs.meta b/My project/Assets/FlowScope/Runtime/UI/UIPanelBase.cs.meta deleted file mode 100644 index b41d0fc..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIPanelBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2c766b1543a347c2bec5d5f1b34b99ae -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/UIPanelRecord.cs b/My project/Assets/FlowScope/Runtime/UI/UIPanelRecord.cs deleted file mode 100644 index ddc9dcf..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIPanelRecord.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -namespace FlowScope.UI -{ - internal sealed class UIPanelRecord - { - public UIPanelRecord( - Type panelType, - string layerName, - IUIPanel panel, - IDisposable handle, - PanelStrategy strategy) - { - PanelType = panelType; - LayerName = layerName; - Panel = panel; - Handle = handle; - Strategy = strategy; - } - - public Type PanelType { get; } - public string LayerName { get; } - public IUIPanel Panel { get; } - public IDisposable Handle { get; } - public PanelStrategy Strategy { get; } - public bool IsOpen { get; set; } - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/UIPanelRecord.cs.meta b/My project/Assets/FlowScope/Runtime/UI/UIPanelRecord.cs.meta deleted file mode 100644 index 45adfff..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIPanelRecord.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6a5aee9195e642a1a6f72d4ce5390885 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/UIPreloadService.cs b/My project/Assets/FlowScope/Runtime/UI/UIPreloadService.cs deleted file mode 100644 index 4dd6f01..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIPreloadService.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using FlowScope.Resources; -using UnityEngine; - -namespace FlowScope.UI -{ - public sealed class UIPreloadService : IUIPreloadService, IDisposable - { - private readonly IResourceService _resources; - private readonly Dictionary> _handles = new(); - - public UIPreloadService(IResourceService resources) - { - _resources = resources ?? throw new ArgumentNullException(nameof(resources)); - } - - public async Task PreloadAsync(CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - - var panelType = typeof(TPanel); - if (IsPreloaded()) - { - return; - } - - var attribute = UIManager.GetPanelAttribute(panelType); - var path = UIManager.ResolvePath(panelType, attribute); - var handle = await _resources.LoadAsync(path, cancellationToken); - if (handle == null || handle.Asset == null) - { - handle?.Dispose(); - throw new InvalidOperationException($"UI panel resource is missing: {path}"); - } - - _handles[panelType] = handle; - } - - public bool IsPreloaded() - { - return _handles.TryGetValue(typeof(TPanel), out var handle) && - handle != null && - !handle.IsDisposed && - handle.Asset != null; - } - - public bool TryGetPreloadedHandle(out IResourceHandle handle) - { - if (IsPreloaded()) - { - handle = _handles[typeof(TPanel)]; - return true; - } - - handle = null; - return false; - } - - public void Release() - { - var panelType = typeof(TPanel); - if (!_handles.TryGetValue(panelType, out var handle)) - { - return; - } - - _handles.Remove(panelType); - handle.Dispose(); - } - - public void ReleaseAll() - { - foreach (var handle in _handles.Values) - { - handle.Dispose(); - } - - _handles.Clear(); - } - - public void Dispose() - { - ReleaseAll(); - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/UIPreloadService.cs.meta b/My project/Assets/FlowScope/Runtime/UI/UIPreloadService.cs.meta deleted file mode 100644 index 1e636c3..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIPreloadService.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6b2cbe6065884f82838b7c882ad5085a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Runtime/UI/UIScreenNavigator.cs b/My project/Assets/FlowScope/Runtime/UI/UIScreenNavigator.cs deleted file mode 100644 index aef83b3..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIScreenNavigator.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace FlowScope.UI -{ - public sealed class UIScreenNavigator : IUIScreenNavigator - { - private readonly UIManager _uiManager; - private readonly Stack _closeStack = new(); - - public UIScreenNavigator(UIManager uiManager) - { - _uiManager = uiManager ?? throw new ArgumentNullException(nameof(uiManager)); - } - - public bool CanGoBack => _closeStack.Count > 1; - - public async Task PushAsync( - TViewModel viewModel, - CancellationToken cancellationToken) - where TPanel : UIPanelBase - { - var panel = await _uiManager.OpenAsync(viewModel, cancellationToken); - _closeStack.Push(() => _uiManager.Close()); - return panel; - } - - public void GoBack() - { - if (!CanGoBack) - { - return; - } - - var close = _closeStack.Pop(); - close(); - } - - public void Clear() - { - while (_closeStack.Count > 0) - { - var close = _closeStack.Pop(); - close(); - } - } - } -} diff --git a/My project/Assets/FlowScope/Runtime/UI/UIScreenNavigator.cs.meta b/My project/Assets/FlowScope/Runtime/UI/UIScreenNavigator.cs.meta deleted file mode 100644 index 296aee5..0000000 --- a/My project/Assets/FlowScope/Runtime/UI/UIScreenNavigator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f991669426b4444098f1973daeb8fb58 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples.meta b/My project/Assets/FlowScope/Samples.meta deleted file mode 100644 index b45fd0b..0000000 --- a/My project/Assets/FlowScope/Samples.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c21892f24eee4c20b29f51afc7228321 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0.meta b/My project/Assets/FlowScope/Samples/MainMenuP0.meta deleted file mode 100644 index b306f6d..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5e5172994f0edc6468e55a5e1e742064 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Configs.meta b/My project/Assets/FlowScope/Samples/MainMenuP0/Configs.meta deleted file mode 100644 index f79c84a..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Configs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 76085fdd1da44ab08b69395b17064b59 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Configs/player_start.json b/My project/Assets/FlowScope/Samples/MainMenuP0/Configs/player_start.json deleted file mode 100644 index a65d073..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Configs/player_start.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Gold": 0 -} diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Configs/player_start.json.meta b/My project/Assets/FlowScope/Samples/MainMenuP0/Configs/player_start.json.meta deleted file mode 100644 index 45ea51d..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Configs/player_start.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: bd391f0c499b42a3a264d0a9de2483f8 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/FlowScope.Samples.MainMenuP0.asmdef b/My project/Assets/FlowScope/Samples/MainMenuP0/FlowScope.Samples.MainMenuP0.asmdef deleted file mode 100644 index 96b2c6e..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/FlowScope.Samples.MainMenuP0.asmdef +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "FlowScope.Samples.MainMenuP0", - "rootNamespace": "FlowScope.Samples.MainMenuP0", - "references": [ - "FlowScope.Runtime", - "R3.Unity" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/FlowScope.Samples.MainMenuP0.asmdef.meta b/My project/Assets/FlowScope/Samples/MainMenuP0/FlowScope.Samples.MainMenuP0.asmdef.meta deleted file mode 100644 index dd25658..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/FlowScope.Samples.MainMenuP0.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: eb3b4bf3dfdc46e4a9352fc2203bbfd4 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs.meta b/My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs.meta deleted file mode 100644 index 57597fe..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c88fe653c15d473cac0029539a2ff355 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs/MainMenuPanel.prefab b/My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs/MainMenuPanel.prefab deleted file mode 100644 index 826ce08..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs/MainMenuPanel.prefab +++ /dev/null @@ -1,453 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &4224295462618148274 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2785319262204863001} - - component: {fileID: 6821847843857072034} - - component: {fileID: 8750438775342100074} - - component: {fileID: 8038936202738359261} - m_Layer: 0 - m_Name: MainMenuPanel - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2785319262204863001 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4224295462618148274} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 6248245286658728259} - - {fileID: 6082938367091974448} - - {fileID: 8836034375789789371} - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 420, y: 240} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &6821847843857072034 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4224295462618148274} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3a641bd6447847f2af2cd5af40305a5a, type: 3} - m_Name: - m_EditorClassIdentifier: - goldText: {fileID: 1736696561195866944} - incrementButton: {fileID: 4338913550008398238} ---- !u!222 &8750438775342100074 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4224295462618148274} - m_CullTransparentMesh: 1 ---- !u!114 &8038936202738359261 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4224295462618148274} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.08, g: 0.1, b: 0.12, a: 0.92} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &4373334964405757163 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 8836034375789789371} - - component: {fileID: 2680961909818563798} - - component: {fileID: 1639113149993436237} - - component: {fileID: 4338913550008398238} - m_Layer: 0 - m_Name: IncrementGoldButton - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &8836034375789789371 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4373334964405757163} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 9086714161511357950} - m_Father: {fileID: 2785319262204863001} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0} - m_AnchorMax: {x: 0.5, y: 0} - m_AnchoredPosition: {x: 0, y: 48} - m_SizeDelta: {x: 220, y: 48} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &2680961909818563798 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4373334964405757163} - m_CullTransparentMesh: 1 ---- !u!114 &1639113149993436237 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4373334964405757163} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.2, g: 0.54, b: 0.8, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &4338913550008398238 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4373334964405757163} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 1639113149993436237} - m_OnClick: - m_PersistentCalls: - m_Calls: [] ---- !u!1 &5175570728316865318 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 6082938367091974448} - - component: {fileID: 901708792770677843} - - component: {fileID: 1736696561195866944} - m_Layer: 0 - m_Name: GoldText - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &6082938367091974448 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5175570728316865318} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 2785319262204863001} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0.5} - m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 0, y: 18} - m_SizeDelta: {x: -48, y: 60} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &901708792770677843 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5175570728316865318} - m_CullTransparentMesh: 1 ---- !u!114 &1736696561195866944 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5175570728316865318} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 40 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: 0 ---- !u!1 &7474348118067574816 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 6248245286658728259} - - component: {fileID: 8827375201563443825} - - component: {fileID: 1429476040966027426} - m_Layer: 0 - m_Name: Title - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &6248245286658728259 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7474348118067574816} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 2785319262204863001} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -24} - m_SizeDelta: {x: -48, y: 46} - m_Pivot: {x: 0.5, y: 1} ---- !u!222 &8827375201563443825 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7474348118067574816} - m_CullTransparentMesh: 1 ---- !u!114 &1429476040966027426 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7474348118067574816} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 28 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: FlowScope Main Menu ---- !u!1 &8599479246113536964 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 9086714161511357950} - - component: {fileID: 2312868584952693925} - - component: {fileID: 9151466043238822226} - m_Layer: 0 - m_Name: Label - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &9086714161511357950 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8599479246113536964} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 8836034375789789371} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &2312868584952693925 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8599479246113536964} - m_CullTransparentMesh: 1 ---- !u!114 &9151466043238822226 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8599479246113536964} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 20 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: Add Gold diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs/MainMenuPanel.prefab.meta b/My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs/MainMenuPanel.prefab.meta deleted file mode 100644 index fea0efa..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Prefabs/MainMenuPanel.prefab.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 05cda67df190bb746b57ab6f944469c5 -PrefabImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Scenes.meta b/My project/Assets/FlowScope/Samples/MainMenuP0/Scenes.meta deleted file mode 100644 index 585d361..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Scenes.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 946526d21b06440688088de21f383782 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Scenes/MainMenuP0.unity b/My project/Assets/FlowScope/Samples/MainMenuP0/Scenes/MainMenuP0.unity deleted file mode 100644 index 1e069fa..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Scenes/MainMenuP0.unity +++ /dev/null @@ -1,440 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -OcclusionCullingSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 - m_SceneGUID: 00000000000000000000000000000000 - m_OcclusionCullingData: {fileID: 0} ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 9 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 0 - m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} - m_UseRadianceAmbientProbe: 0 ---- !u!157 &3 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 12 - m_GIWorkflowMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 1 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 12 - m_Resolution: 2 - m_BakeResolution: 40 - m_AtlasSize: 1024 - m_AO: 0 - m_AOMaxDistance: 1 - m_CompAOExponent: 1 - m_CompAOExponentDirect: 0 - m_ExtractAmbientOcclusion: 0 - m_Padding: 2 - m_LightmapParameters: {fileID: 0} - m_LightmapsBakeMode: 1 - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 - m_ReflectionCompression: 2 - m_MixedBakeMode: 2 - m_BakeBackend: 1 - m_PVRSampling: 1 - m_PVRDirectSampleCount: 32 - m_PVRSampleCount: 512 - m_PVRBounces: 2 - m_PVREnvironmentSampleCount: 256 - m_PVREnvironmentReferencePointCount: 2048 - m_PVRFilteringMode: 1 - m_PVRDenoiserTypeDirect: 1 - m_PVRDenoiserTypeIndirect: 1 - m_PVRDenoiserTypeAO: 1 - m_PVRFilterTypeDirect: 0 - m_PVRFilterTypeIndirect: 0 - m_PVRFilterTypeAO: 0 - m_PVREnvironmentMIS: 1 - m_PVRCulling: 1 - m_PVRFilteringGaussRadiusDirect: 1 - m_PVRFilteringGaussRadiusIndirect: 5 - m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousPositionSigmaDirect: 0.5 - m_PVRFilteringAtrousPositionSigmaIndirect: 2 - m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ExportTrainingData: 0 - m_TrainingDataDestination: TrainingData - m_LightProbeSampleCountMultiplier: 4 - m_LightingDataAsset: {fileID: 0} - m_LightingSettings: {fileID: 0} ---- !u!196 &4 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 3 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - buildHeightMesh: 0 - maxJobWorkers: 0 - preserveTilesOutsideBounds: 0 - debug: - m_Flags: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &204902849 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 204902852} - - component: {fileID: 204902851} - - component: {fileID: 204902850} - m_Layer: 0 - m_Name: Main Camera - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &204902850 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 204902849} - m_Enabled: 1 ---- !u!20 &204902851 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 204902849} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 2 - m_BackGroundColor: {r: 0.05, g: 0.06, b: 0.07, a: 1} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_Iso: 200 - m_ShutterSpeed: 0.005 - m_Aperture: 16 - m_FocusDistance: 10 - m_FocalLength: 50 - m_BladeCount: 5 - m_Curvature: {x: 2, y: 11} - m_BarrelClipping: 0.25 - m_Anamorphism: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 0 - orthographic size: 5 - m_Depth: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &204902852 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 204902849} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1061918572 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1061918574} - - component: {fileID: 1061918573} - m_Layer: 0 - m_Name: GameBootstrap - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1061918573 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1061918572} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cd97432f2838454cbbf2d19dbe14d7f3, type: 3} - m_Name: - m_EditorClassIdentifier: - hudCanvas: {fileID: 1965407523} - mainMenuPanelPrefab: {fileID: 6821847843857072034, guid: 05cda67df190bb746b57ab6f944469c5, type: 3} - defaultGold: 0 ---- !u!4 &1061918574 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1061918572} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1965407522 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1965407526} - - component: {fileID: 1965407523} - - component: {fileID: 1965407525} - - component: {fileID: 1965407524} - m_Layer: 0 - m_Name: HUD Canvas - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!223 &1965407523 -Canvas: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1965407522} - m_Enabled: 1 - serializedVersion: 3 - m_RenderMode: 0 - m_Camera: {fileID: 0} - m_PlaneDistance: 100 - m_PixelPerfect: 0 - m_ReceivesEvents: 1 - m_OverrideSorting: 0 - m_OverridePixelPerfect: 0 - m_SortingBucketNormalizedSize: 0 - m_VertexColorAlwaysGammaSpace: 0 - m_AdditionalShaderChannelsFlag: 0 - m_UpdateRectTransformForStandalone: 0 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 ---- !u!114 &1965407524 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1965407522} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 ---- !u!114 &1965407525 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1965407522} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} - m_Name: - m_EditorClassIdentifier: - m_UiScaleMode: 0 - m_ReferencePixelsPerUnit: 100 - m_ScaleFactor: 1 - m_ReferenceResolution: {x: 800, y: 600} - m_ScreenMatchMode: 0 - m_MatchWidthOrHeight: 0 - m_PhysicalUnit: 3 - m_FallbackScreenDPI: 96 - m_DefaultSpriteDPI: 96 - m_DynamicPixelsPerUnit: 1 - m_PresetInfoIsWorld: 0 ---- !u!224 &1965407526 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1965407522} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0, y: 0, z: 0} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0, y: 0} ---- !u!1 &2023591418 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2023591421} - - component: {fileID: 2023591420} - - component: {fileID: 2023591419} - m_Layer: 0 - m_Name: EventSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &2023591419 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2023591418} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} - m_Name: - m_EditorClassIdentifier: - m_SendPointerHoverToParent: 1 - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 ---- !u!114 &2023591420 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2023591418} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 10 ---- !u!4 &2023591421 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2023591418} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1660057539 &9223372036854775807 -SceneRoots: - m_ObjectHideFlags: 0 - m_Roots: - - {fileID: 204902852} - - {fileID: 2023591421} - - {fileID: 1965407526} - - {fileID: 1061918574} diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Scenes/MainMenuP0.unity.meta b/My project/Assets/FlowScope/Samples/MainMenuP0/Scenes/MainMenuP0.unity.meta deleted file mode 100644 index 73b8a81..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Scenes/MainMenuP0.unity.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 03630d34cf304668afe00ab221f3557e -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Scripts.meta b/My project/Assets/FlowScope/Samples/MainMenuP0/Scripts.meta deleted file mode 100644 index a5d0e45..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 93879cc02e2644039382a2006c5434b1 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/GameBootstrap.cs b/My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/GameBootstrap.cs deleted file mode 100644 index 9ab9e7c..0000000 --- a/My project/Assets/FlowScope/Samples/MainMenuP0/Scripts/GameBootstrap.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using FlowScope.Audio; -using FlowScope.Config; -using FlowScope.Flow; -using FlowScope.Resources; -using FlowScope.Save; -using FlowScope.UI; -using UnityEngine; -using UnityEngine.UI; -using ContainerType = FlowScope.Container.Container; - -namespace FlowScope.Samples.MainMenuP0 -{ - public sealed class GameBootstrap : MonoBehaviour - { - private const string SaveKey = "main-menu-player"; - - [SerializeField] private Canvas hudCanvas; - [SerializeField] private MainMenuPanel mainMenuPanelPrefab; - [SerializeField] private int defaultGold; - - private ContainerType _root; - private GameFlow _gameFlow; - private ISaveService _saveService; - private UIPreloadService _preloadService; - private SampleResourceBackend _sampleBackend; - private PlayerData _playerData; - private CancellationTokenSource _lifetime; - private bool _started; - private bool _shutdown; - - public int ReleasedResourceCount => _sampleBackend?.ReleaseCount ?? 0; - public bool IsShutdown => _shutdown; - - private async void Awake() - { - _lifetime = new CancellationTokenSource(); - await StartupAsync(_lifetime.Token); - } - - public async Task StartupAsync(CancellationToken cancellationToken) - { - if (_started) - { - return; - } - - _started = true; - _shutdown = false; - _root = new ContainerType(); - _gameFlow = new GameFlow(); - - _sampleBackend = new SampleResourceBackend(); - _sampleBackend.Register( - "FlowScope/Samples/MainMenuP0/MainMenuPanel", - ResolveMainMenuPanelPrefab().gameObject); - var resources = new ResourceService(_sampleBackend); - _preloadService = new UIPreloadService(resources); - var uiManager = new UIManager(resources, _preloadService); - uiManager.RegisterLayer("hud", ResolveHudCanvas(), 0, PanelStrategy.Destroy); - var screenNavigator = new UIScreenNavigator(uiManager); - - var migrations = new SaveMigrationRegistry(); - migrations.Register(new PlayerDataV1ToV2Migration()); - _saveService = new SaveService( - new FileSaveStorage(), - new JsonSaveSerializer(2, migrations)); - _playerData = await _saveService.LoadAsync( - SaveKey, - new PlayerData { Gold = new R3.ReactiveProperty(defaultGold) }, - cancellationToken); - - await _preloadService.PreloadAsync(cancellationToken); - - var audioService = gameObject.AddComponent().Initialize(resources); - _root.RegisterInstance(_root); - _root.RegisterInstance( - new JsonConfigProvider(new[] - { - JsonConfigProvider.Mapping( - "main_menu.json", - new InMemoryConfigSource( - new Dictionary - { - { "main_menu.json", "[{\"Id\":1,\"Title\":\"Main Menu P1\"}]" } - }, - "MainMenuP0"), - new JsonConfigParser()) - })); - _root.RegisterInstance(resources); - _root.RegisterInstance(_saveService); - _root.RegisterInstance(audioService); - _root.RegisterInstance(uiManager); - _root.RegisterInstance(_preloadService); - _root.RegisterInstance(screenNavigator); - _root.RegisterInstance(_playerData); - _root.RegisterFactory(_ => new MainMenuFeature(screenNavigator, _playerData)); - - await _gameFlow.StartupAsync(_root, cancellationToken); - } - - public async Task ShutdownAsync(CancellationToken cancellationToken) - { - if (_saveService != null && _playerData != null) - { - await _saveService.SaveAsync(SaveKey, _playerData, cancellationToken); - } - - if (_gameFlow != null && _gameFlow.State != GameFlowState.Disposed) - { - await _gameFlow.ShutdownAsync(cancellationToken); - } - - _preloadService?.ReleaseAll(); - _shutdown = true; - } - - private async void OnApplicationQuit() - { - _lifetime?.Cancel(); - await ShutdownAsync(CancellationToken.None); - } - - private void OnDestroy() - { - _lifetime?.Cancel(); - _lifetime?.Dispose(); - } - - private Canvas ResolveHudCanvas() - { - if (hudCanvas != null) - { - return hudCanvas; - } - - var canvasObject = new GameObject("FlowScope HUD Canvas"); - canvasObject.transform.SetParent(transform, false); - hudCanvas = canvasObject.AddComponent(); - hudCanvas.renderMode = RenderMode.ScreenSpaceOverlay; - return hudCanvas; - } - - private MainMenuPanel ResolveMainMenuPanelPrefab() - { - if (mainMenuPanelPrefab != null) - { - return mainMenuPanelPrefab; - } - - var panelObject = new GameObject("MainMenuPanel Template"); - panelObject.transform.SetParent(transform, false); - panelObject.SetActive(false); - - var panel = panelObject.AddComponent(); - - var goldObject = new GameObject("GoldText"); - goldObject.transform.SetParent(panelObject.transform, false); - var goldText = goldObject.AddComponent(); - goldText.text = defaultGold.ToString(); - goldText.alignment = TextAnchor.MiddleCenter; - - var buttonObject = new GameObject("IncrementGoldButton"); - buttonObject.transform.SetParent(panelObject.transform, false); - buttonObject.AddComponent(); - var button = buttonObject.AddComponent