-
Notifications
You must be signed in to change notification settings - Fork 1
Release 0.10.0 #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 0.10.0 #19
Conversation
|
Caution Review failedThe pull request is closed. 📝 Walkthrough📝 WalkthroughWalkthroughThis pull request introduces several updates to the Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (8)
Runtime/UiAssetLoader.cs (2)
22-22: Update method documentation to reflect UniTask usageThe method signature has been correctly updated to use UniTask, but the documentation still references "task". Consider updating it for consistency.
-/// <returns>A task that completes with the instantiated prefab game object.</returns> +/// <returns>A UniTask that completes with the instantiated prefab game object.</returns>
Line range hint
34-52: Optimize async operation handling with UniTaskWhile the implementation works, it could be more efficient by using UniTask's native integration with AsyncOperationHandle instead of accessing the Task property.
Consider this optimization:
public async UniTask<GameObject> InstantiatePrefab(UiConfig config, Transform parent) { var operation = Addressables.InstantiateAsync(config.AddressableAddress, new InstantiationParameters(parent, false)); if(config.LoadSynchronously) { operation.WaitForCompletion(); } else { - await operation.Task; + await operation.ToUniTask(); } if (operation.Status != AsyncOperationStatus.Succeeded) { throw operation.OperationException; } return operation.Result; }This change leverages UniTask's optimized handling of Unity's AsyncOperationHandle, which is more efficient than going through the Task property.
Runtime/UiConfigs.cs (1)
26-26: Consider separating configuration concerns.While transitioning to UniTask, this might be a good opportunity to improve the architecture:
- Consider splitting the configuration storage (ScriptableObject) from the configuration management logic
- This would allow for better separation of concerns and easier testing
- The interface removal might be better handled by introducing a new interface that better represents the current responsibilities
Example structure:
// Storage public class UiConfigsStorage : ScriptableObject { ... } // Management public interface IUiConfigProvider { UiConfig GetConfigForType(Type uiType); IReadOnlyList<UiSetConfig> GetUiSets(); } public class UiConfigManager : IUiConfigProvider { private readonly UiConfigsStorage _storage; ... }CHANGELOG.md (1)
Line range hint
1-159: Maintain consistent formatting across changelog entriesThe changelog effectively documents changes, especially breaking changes and migration paths, which is excellent. However, there are some formatting inconsistencies:
- Section headers vary between
***New**:and**New**:- Some entries have trailing whitespace
- Some sections use emphasis (*) for technical terms while others don't
Consider standardizing the formatting:
- Use
**Section**:format consistently for all section headers- Remove trailing whitespace
- Use consistent emphasis for technical terms (preferably without asterisks unless referring to specific code elements)
Would you like me to generate a script to help identify these inconsistencies?
Runtime/IUiService.cs (2)
Line range hint
1-5: Consider removing unused System.Threading.Tasks importSince the interface has been fully migrated to use
UniTask, theSystem.Threading.Tasksimport appears to be unnecessary and can be removed.using Cysharp.Threading.Tasks; using System; using System.Collections.Generic; -using System.Threading.Tasks; using UnityEngine;
Line range hint
1-264: Consider documenting WebGL-specific behaviorWhile the migration to UniTask enables WebGL support, it would be beneficial to add documentation about any WebGL-specific considerations or limitations. This could include:
- Error handling differences in WebGL context
- Performance considerations
- Platform-specific initialization requirements
Consider adding a remarks section to the interface documentation:
/// <summary> /// This service provides an abstraction layer to interact with the game's UI <seealso cref="UiPresenter"/> /// The Ui Service is organized by layers. The higher the layer the more close is to the camera viewport /// </summary> +/// <remarks> +/// This service uses UniTask for asynchronous operations to ensure compatibility across platforms, including WebGL. +/// When using in WebGL context, ensure proper error handling as async operations behave differently compared to other platforms. +/// </remarks> public interface IUiServiceRuntime/UiService.cs (2)
Line range hint
194-211: Consider simplifyingLoadUiSetAsyncwithUniTask.WhenAll.Currently,
LoadUiSetAsyncreturns anIList<UniTask<UiPresenter>>, which requires the caller to handle multiple tasks. Refactoring the method to return a singleUniTask<IList<UiPresenter>>can simplify the API and improve usability by allowing the caller to await all UI loads at once.Here's how you might refactor the method:
-public IList<UniTask<UiPresenter>> LoadUiSetAsync(int setId) +public async UniTask<IList<UiPresenter>> LoadUiSetAsync(int setId) { var uiTasks = new List<UniTask<UiPresenter>>(); if (_uiSets.TryGetValue(setId, out var set)) { foreach (var type in set.UiConfigsType) { if (_uiPresenters.ContainsKey(type)) { continue; } uiTasks.Add(LoadUiAsync(type)); } } - return uiTasks; + var presenters = await UniTask.WhenAll(uiTasks); + return presenters.ToList(); }This change allows callers to simply
await LoadUiSetAsync(setId)without additional handling.
Line range hint
337-343: Fix missing assignment touiafter loading.In
GetOrLoadUiAsync, after callingawait LoadUiAsync(type), the variableuiis not updated. This meansuimay benullwhen returned, potentially leading to aNullReferenceException.Apply this diff to fix the issue:
private async UniTask<UiPresenter> GetOrLoadUiAsync(Type type) { if (!_uiPresenters.TryGetValue(type, out var ui)) { OpenLoadingSpinner(); - await LoadUiAsync(type); + ui = await LoadUiAsync(type); CloseLoadingSpinner(); } return ui; }This ensures that
uiis assigned the loaded presenter before returning.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (7)
CHANGELOG.md(7 hunks)Runtime/GameLovers.UiService.asmdef(1 hunks)Runtime/IUiService.cs(7 hunks)Runtime/UiAssetLoader.cs(3 hunks)Runtime/UiConfigs.cs(1 hunks)Runtime/UiService.cs(7 hunks)package.json(1 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md
[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...# [0.9.1] - 2024-11-04
Fixed:
- Fixed the issue that would crash *NonDrawingV...
(FIX_RESOLVE)
[style] ~52-~52: This phrase is redundant. Consider using “outside”.
Context: ...View in the same position if not placed outside of the safe area
Fixed:
- Fixed th...
(OUTSIDE_OF)
🪛 Markdownlint
CHANGELOG.md
9-9: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
🔇 Additional comments (10)
Runtime/GameLovers.UiService.asmdef (1)
6-7: LGTM! Verify UniTask reference.
The addition of the UniTask reference aligns with the PR objectives for WebGL platform support. The implementation looks correct.
Let's verify the UniTask reference:
✅ Verification successful
UniTask reference is correctly configured
The verification confirms:
- UniTask package is properly declared in package.json with version 2.5.10
- The GUID
f51ebe6a0ceec4240a699833d6309b23is correctly referenced in the assembly definition - The reference is only added where needed (Runtime assembly) and not in the Editor assembly
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the UniTask package reference and its dependencies
# Check if package.json exists and contains UniTask dependency
echo "Checking package.json for UniTask dependency..."
rg -l "com.cysharp.unitask"
# Verify if the GUID matches the official UniTask package
echo "Verifying UniTask GUID..."
rg -l "f51ebe6a0ceec4240a699833d6309b23"
Length of output: 283
Script:
#!/bin/bash
# Let's verify the content of package.json to ensure correct UniTask version
echo "Checking package.json content..."
cat package.json
# Let's also check if there are any other assembly definition files referencing UniTask
echo -e "\nChecking other .asmdef files for UniTask reference..."
fd -e asmdef --exec cat {}
Length of output: 2048
package.json (2)
5-5: LGTM: Version bump follows semantic versioning
The version increment to 0.9.2 appropriately reflects the addition of UniTask functionality while maintaining backward compatibility.
11-11: Verify UniTask version compatibility
Let's verify that UniTask v2.5.10 is the most suitable version for this package.
✅ Verification successful
UniTask version 2.5.10 is up to date
The package is using the latest stable version of UniTask (2.5.10) released on October 3rd, 2024. Let's verify the Unity version compatibility and WebGL support with a different approach.
UniTask 2.5.10 is compatible and recommended
The verification confirms:
- Using the latest stable version (2.5.10)
- Fully compatible with Unity 2022.3 (project's Unity version)
- Supports WebGL platform
- Runs on Unity's PlayerLoop without threading issues
- Provides proper integration with Unity's async operations (Resources, UnityWebRequest, etc.)
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify UniTask version compatibility and latest releases
# Check if there's a newer version of UniTask
echo "Checking for newer UniTask versions..."
gh api graphql -f query='
{
repository(owner: "Cysharp", name: "UniTask") {
releases(first: 5, orderBy: {field: CREATED_AT, direction: DESC}) {
nodes {
tagName
createdAt
isPrerelease
}
}
}
}' | jq '.data.repository.releases.nodes[] | select(.isPrerelease == false)'
# Check Unity version compatibility in documentation
echo "Checking Unity version compatibility..."
gh api repos/Cysharp/UniTask/contents/README.md | jq -r '.content' | base64 -d | grep -A 5 "Unity"
# Verify WebGL support
echo "Checking WebGL platform support..."
gh api repos/Cysharp/UniTask/contents/README.md | jq -r '.content' | base64 -d | grep -i "webgl"
Length of output: 1358
Script:
#!/bin/bash
# Try to fetch README content using a different approach
curl -s -L https://raw.githubusercontent.com/Cysharp/UniTask/master/README.md | grep -A 5 "Unity"
# Check WebGL support
curl -s -L https://raw.githubusercontent.com/Cysharp/UniTask/master/README.md | grep -i "webgl"
# Check package.json for Unity version requirements
fd -e json package.json --exec cat {} | grep -i "unity"
Length of output: 22632
Runtime/UiAssetLoader.cs (2)
1-1: LGTM: Required import for UniTask integration
The addition of UniTask import aligns with the PR objective of enabling WebGL platform support.
Line range hint 34-52: Verify Addressables behavior in WebGL
Since this change is specifically aimed at WebGL support, please ensure that the Addressables instantiation works as expected in WebGL builds, particularly in synchronous mode.
Consider testing the following scenarios in WebGL:
- Synchronous loading (
LoadSynchronously = true) - Asynchronous loading with various asset sizes
- Error handling when assets are not found
Runtime/UiConfigs.cs (1)
26-26:
Verify the impact of removing IConfigsContainer interface.
The commented-out interface implementation IConfigsContainer<UiConfig> appears to be a breaking change that could affect existing code depending on this contract. This change doesn't seem directly related to the UniTask integration objective.
Please clarify:
- Why is the interface implementation being removed?
- How should existing code depending on
IConfigsContainer<UiConfig>be updated? - Should this breaking change be documented in the changelog?
Runtime/IUiService.cs (1)
Line range hint 115-198: LGTM! Consistent migration to UniTask
The transition from Task to UniTask is implemented consistently across all async methods. This change aligns with the PR objective to enable WebGL platform support, as UniTask is better suited for Unity's runtime environment.
Let's verify that all async operations in the codebase have been migrated to UniTask:
✅ Verification successful
The search results show that all async operations in the UI-related files consistently use UniTask<T> instead of Task<T>. There are no remaining Task<T> usages that need migration. The implementation in both the interface (IUiService.cs) and concrete classes (UiService.cs, UiAssetLoader.cs) are properly aligned.
Migration to UniTask is complete and consistent
The codebase shows a thorough migration where all asynchronous operations in the UI system now use UniTask, which is optimal for Unity's runtime environment and WebGL support.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining Task usages that should be UniTask
# This helps ensure complete migration across the codebase
# Search for Task usage in C# files, excluding tests and obj/bin directories
rg "Task<" --type csharp --glob '!{**/*.Tests.cs,**/obj/**,**/bin/**}'
# Search for UniTask usage to verify the migration
rg "UniTask<" --type csharp --glob '!{**/*.Tests.cs,**/obj/**,**/bin/**}'
Length of output: 3108
Runtime/UiService.cs (3)
1-1: Addition of UniTask namespace is appropriate.
Including using Cysharp.Threading.Tasks; is necessary for utilizing UniTask. This change is correct.
Line range hint 158-193: Update to UniTask improves asynchronous operations.
Changing the return type to UniTask<UiPresenter> in LoadUiAsync aligns with the new asynchronous model using UniTask. This enhances compatibility with WebGL platforms and is a beneficial update.
Line range hint 239-248: Method signatures updated to use UniTask are consistent.
The OpenUiAsync methods now return UniTask<UiPresenter>, which is consistent with the shift to UniTask for asynchronous operations. This ensures uniformity across asynchronous methods.
Fixed
Summary by CodeRabbit
Release Notes for Version 0.10.0
New Features
Improvements