diff --git a/Editor/BetterServices.Editor.asmdef b/Editor/BetterServices.Editor.asmdef index 35290fe..7940469 100644 --- a/Editor/BetterServices.Editor.asmdef +++ b/Editor/BetterServices.Editor.asmdef @@ -1,6 +1,6 @@ { "name": "BetterServices.Editor", - "rootNamespace": "Better.Services", + "rootNamespace": "Better.Services.EditorAddons", "references": [ "GUID:1c5574afb40e5fe4ca9e9c156009297b" ], diff --git a/README.md b/README.md index c7f807a..6e8d5fb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Better Services -[![openupm](https://img.shields.io/npm/v/com.tdw.betterservices?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.tdw.betterservices/) +[![openupm](https://img.shields.io/npm/v/com.tdw.better.services?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.tdw.better.services/) This plugins provides basic implementation for services pattern diff --git a/Runtime/BetterServices.Runtime.asmdef b/Runtime/BetterServices.Runtime.asmdef index 64d6daf..1b34de4 100644 --- a/Runtime/BetterServices.Runtime.asmdef +++ b/Runtime/BetterServices.Runtime.asmdef @@ -1,9 +1,9 @@ { "name": "BetterServices.Runtime", - "rootNamespace": "Better.Services", + "rootNamespace": "Better.Services.Runtime", "references": [ "GUID:441b78e90a9cf724ab41c6eed8c0b93d", - "GUID:a59e3daedde9ca94bba45364d4ead25f" + "GUID:8bd4b41f8da90144d9006c4d926c9679" ], "includePlatforms": [], "excludePlatforms": [], @@ -15,7 +15,7 @@ "versionDefines": [ { "name": "com.uurha.bettervalidation", - "expression": "1.0.4", + "expression": "1.6.0", "define": "BETTER_VALIDATION" } ], diff --git a/Runtime/Services/MonoService.cs b/Runtime/Services/MonoService.cs index 50daf82..b1e31e8 100644 --- a/Runtime/Services/MonoService.cs +++ b/Runtime/Services/MonoService.cs @@ -20,11 +20,9 @@ protected virtual void Awake() async Task IService.InitializeAsync(CancellationToken cancellationToken) { - Debug.Log($"[{GetType().Name}] {nameof(IService.InitializeAsync)}"); - if (Initialized) { - Debug.LogError($"[{GetType().Name}] {nameof(IService.InitializeAsync)}: already initialized"); + Debug.LogError("Service already initialized"); return; } @@ -38,18 +36,17 @@ async Task IService.InitializeAsync(CancellationToken cancellationToken) } Initialized = true; + Debug.Log("Service initialized"); } Task IService.PostInitializeAsync(CancellationToken cancellationToken) { if (!Initialized) { - Debug.LogError($"[{GetType().Name}] {nameof(IService.PostInitializeAsync)}: not initialized"); + Debug.LogError("Service must be initialized"); return Task.CompletedTask; } - Debug.Log($"[{GetType().Name}] {nameof(IService.PostInitializeAsync)}"); - var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(DestroyCancellationToken, cancellationToken); cancellationToken = linkedTokenSource.Token; diff --git a/Runtime/Services/PocoService.cs b/Runtime/Services/PocoService.cs index b64b6a2..2143ebd 100644 --- a/Runtime/Services/PocoService.cs +++ b/Runtime/Services/PocoService.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Better.Services.Runtime.Interfaces; using UnityEngine; + #if BETTER_VALIDATION using Better.Validation.Runtime.Attributes; #endif @@ -16,28 +17,27 @@ public abstract class PocoService : IService async Task IService.InitializeAsync(CancellationToken cancellationToken) { - Debug.Log($"[{GetType().Name}] {nameof(IService.InitializeAsync)}"); - if (Initialized) { - Debug.LogError($"[{GetType().Name}] {nameof(IService.InitializeAsync)}: already initialized"); + Debug.LogError("Service already initialized"); return; } Initialized = true; await OnInitializeAsync(cancellationToken); Initialized = !cancellationToken.IsCancellationRequested; + + Debug.Log("Service initialized"); } Task IService.PostInitializeAsync(CancellationToken cancellationToken) { if (!Initialized) { - Debug.LogError($"[{GetType().Name}] {nameof(IService.PostInitializeAsync)}: not initialized"); + Debug.LogError("Service must be initialized"); return Task.CompletedTask; } - Debug.Log($"[{GetType().Name}] {nameof(IService.PostInitializeAsync)}"); return OnPostInitializeAsync(cancellationToken); } @@ -49,7 +49,7 @@ Task IService.PostInitializeAsync(CancellationToken cancellationToken) public abstract class PocoService : PocoService where TSettings : ScriptableObject { #if BETTER_VALIDATION - [NotNull] + [NotNull] #endif [SerializeField] private TSettings _settings; @@ -59,7 +59,8 @@ protected override Task OnInitializeAsync(CancellationToken cancellationToken) { if (Settings == null) { - throw new NullReferenceException($"[{GetType().Name}] {nameof(OnInitializeAsync)}: {nameof(Settings)} cannot be null"); + var exception = new NullReferenceException(nameof(Settings)); + Debug.LogException(exception); } return Task.CompletedTask; diff --git a/package.json b/package.json index 137dc61..ce19b80 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,12 @@ { "name": "com.tdw.better.services", "displayName": "Better Services", - "version": "0.0.4", + "version": "0.1.0", "unity": "2021.3", "description": " ", + "dependencies": { + "com.tdw.better.internal.core": "0.0.2" + }, "author": { "name": "Better Plugins", "url": "https://github.com/techno-dwarf-works"