Skip to content

fix:Addressable登録時のaddress名を変更 #491

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

Open
wants to merge 2 commits into
base: dev/v4
Choose a base branch
from

Conversation

yhikishima
Copy link
Contributor

@yhikishima yhikishima commented May 29, 2025

関連リンク

https://synesthesias.atlassian.net/browse/CPSDK25-124
こちらの対応

実装内容

  • Addressable生成時にゲームオブジェクトから親のオブジェクトを検索し、オブジェクト名からmeshcodeを取得

マージ前確認項目

  • Squash and Mergeが選択されていること
  • UI、挙動に変更ある場合、ユーザーマニュアルが更新されていること

動作確認

  • Addressable登録実行
  • Address名が以下になっていること
    • 3次メッシュ tile_zoom_(タイルのズームレベル)_grid_(タイルの位置を示すメッシュコード)_(従来のゲームオブジェクト名)_(同名の場合のID)
    • 2次メッシュ tile_(2次メッシュ)_(従来のゲームオブジェクト名)_(同名の場合のID)

その他

Summary by CodeRabbit

  • 新機能

    • タイルアドレスの命名規則が改善され、より一意で分かりやすい名前が付与されるようになりました。
    • タイル管理機能が強化され、タイル一覧の参照が可能になりました。
    • タイルの親情報を保持して管理する機能が追加されました。
  • 改善

    • エクスポート時のエラーメッセージがより具体的になり、問題の特定がしやすくなりました。
    • タイル管理とエクスポート処理の安定性と一貫性が向上しました。
    • エクスポート処理のフローが整理され、重複処理が削減されました。

@Copilot Copilot AI review requested due to automatic review settings May 29, 2025 04:53
Copy link

coderabbitai bot commented May 29, 2025

"""

Walkthrough

Dynamicタイルのエクスポート処理がリファクタリングされ、アドレス命名、タイル管理、コードの明確化が行われました。タイルマネージャのシングルトン化、アドレス名の一意性確保、親Transformの管理、エラーハンドリングの強化などが実装されています。

Changes

ファイル/グループ 変更概要
Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs タイルマネージャ取得のメソッド追加、アドレス名生成処理の統合、親Transform管理、エラー処理強化、アドレス名の一意性確保、コード整理
Runtime/DynamicTile/PLATEAUDynamicTile.cs コンストラクタにTransform parent引数を追加し、親Transformを保持するよう変更
Runtime/DynamicTile/PLATEAUTileManager.cs privateなdynamicTilesリストのpublicなReadOnlyプロパティDynamicTilesを追加し、外部からリスト参照を可能に

Sequence Diagram(s)

sequenceDiagram
    participant Exporter as DynamicTileExporter
    participant Manager as PLATEAUTileManager
    participant Tile as PLATEAUDynamicTile

    Exporter->>Manager: GetOrCreateTileManager()
    Exporter->>Manager: Clear()
    loop 各CityObjectGroup
        Exporter->>Exporter: GetAddress(GameObject)
        Exporter->>Manager: Check address uniqueness
        Exporter->>Tile: new PLATEAUDynamicTile(address, parent)
        Exporter->>Manager: AddTile(tile)
        Exporter->>Exporter: Save prefab, register addressable
    end
    Exporter->>Manager: Save catalog path
Loading

Possibly related PRs

Suggested reviewers

  • linoal

Poem

うさぎがタイルを並べるよ、
アドレスも親もきっちり管理、
一意の名前で迷子なし、
タイルマネージャもすっきり新調、
コードの森でぴょんぴょん跳ねて、
今日も整理でごきげんさ!
🐇✨
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors how Addressable names are generated by extracting mesh codes from parent GML objects and integrates a PLATEAUTileManager to track dynamic tiles.

  • Expose DynamicTiles on PLATEAUTileManager and extend PLATEAUDynamicTile to include its parent transform
  • Update DynamicTileExporter to compute and dedupe address names via a new GetAddress method, then register tiles with the manager
  • Add helper GetOrCreateTileManager and detailed address‐generation logic

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Runtime/DynamicTile/PLATEAUTileManager.cs Added public DynamicTiles property
Runtime/DynamicTile/PLATEAUDynamicTile.cs Updated constructor to accept a parent parameter
Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs Compute address names, handle duplicates, integrate manager, and add helper methods
Comments suppressed due to low confidence (5)

Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs:45

  • [nitpick] The name isExcludeAssetFolder is counterintuitive (it’s true when a build path is provided). Consider renaming to something like hasBuildFolderPath or useSeparateAssetFolder for clarity.
var isExcludeAssetFolder = !string.IsNullOrEmpty(buildFolderPath);

Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs:38

  • [nitpick] This error message mixes English and Japanese and may not clearly communicate to all users. Consider unifying the language and referencing the UI term "都市モデル" consistently.
onError?.Invoke("CityObjectGroupが見つかりません。都市モデルにCityObjectGroupが含まれていることを確認してください。");

Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs:226

  • The new GetAddress logic has multiple branches (2nd vs. 3rd mesh, invalid codes, path splits). Consider adding unit tests covering each branch to ensure address names stay correct over time.
private static string GetAddress(GameObject obj)

Runtime/DynamicTile/PLATEAUDynamicTile.cs:29

  • The class assigns this.parent = parent but I don’t see a parent field or property declared—add a private Transform parent; (or an exposed property) to avoid a compilation error.
public PLATEAUDynamicTile(string address, Transform parent)

Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs:171

  • The comment claims the method may return null, but the implementation always returns a non-null manager. Update or remove the null clause to keep docs accurate.
/// <returns>PLATEAUTileManagerのインスタンス。生成に失敗した場合はnull。</returns>

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (3)
Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs (3)

84-93: アドレス名の重複処理は適切ですが、コメントの修正が必要です

重複チェックと連番付与のロジックは正しく実装されていますが、90行目のコメントが実装と一致していません。

-                    // 最後の部分(baseName)に連番を付ける
+                    // アドレス名全体に連番を付ける

275-277: ズームレベルの取得方法について確認が必要です

現在ズームレベルは0にハードコードされています。TODOコメントがありますが、実装計画について確認させてください。

ズームレベルの取得ロジックの実装について、新しいissueを作成しますか?


221-227: GetAddressメソッドのドキュメントを詳細化することを推奨します

メソッドの動作をより明確にするため、ドキュメントコメントを拡張することを提案します。

         /// <summary>
         /// 指定したGameObjectからAddressables用のアドレス名を取得します。
+        /// 親のGMLオブジェクトからメッシュコードを抽出し、以下の形式でアドレス名を生成します:
+        /// - 2次メッシュ(6桁): tile_{meshCode}__{baseName}
+        /// - 3次メッシュ(8桁): tile_zoom_{zoomLevel}_grid_{meshCode}_{baseName}
         /// </summary>
         /// <param name="obj">アドレスを取得したいGameObject</param>
-        /// <returns>アドレス名。取得できない場合は空文字列。</returns>
+        /// <returns>生成されたアドレス名。メッシュコードが無効な場合は空文字列。</returns>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7802b10 and a45c248.

📒 Files selected for processing (3)
  • Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs (8 hunks)
  • Runtime/DynamicTile/PLATEAUDynamicTile.cs (1 hunks)
  • Runtime/DynamicTile/PLATEAUTileManager.cs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs (4)
Runtime/DynamicTile/PLATEAUTileManager.cs (4)
  • ClearTiles (144-147)
  • AddTile (125-139)
  • SaveCatalogPath (47-51)
  • PLATEAUTileManager (10-148)
Runtime/CityAdjust/ConvertToAsset/ConvertToAsset.cs (1)
  • List (45-156)
Runtime/DynamicTile/PLATEAUDynamicTile.cs (1)
  • PLATEAUDynamicTile (29-33)
Runtime/Util/Dialogue.cs (1)
  • Dialogue (13-37)
🔇 Additional comments (7)
Runtime/DynamicTile/PLATEAUTileManager.cs (1)

14-14: LGTM!

dynamicTilesリストへの読み取り専用アクセスを提供する適切な実装です。外部からの直接的な変更を防ぎつつ、必要な情報へのアクセスを可能にしています。

Runtime/DynamicTile/PLATEAUDynamicTile.cs (1)

29-33: LGTM!

タイルと親Transformの関係を管理するための適切な実装です。エクスポート処理で必要な情報を保持できるようになります。

Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs (5)

3-3: 必要なusing文の追加

GridCodeクラスとLINQ操作のために必要な名前空間が適切に追加されています。

Also applies to: 12-12


35-41: 変数名とエラーメッセージの改善

cityObjectGroupsという変数名は実際の型PLATEAUCityObjectGroupをより正確に反映しており、エラーメッセージも具体的になりました。


56-60: タイルマネージャーの適切な初期化

シングルトンパターンでタイルマネージャーを取得し、処理開始時にタイルをクリアすることで、クリーンな状態から開始できます。


168-182: タイルマネージャーの取得・生成メソッドの適切な実装

シングルトンパターンでタイルマネージャーを管理する良い実装です。既存のインスタンスがない場合のみ新規作成します。


260-265: GridCode検証の適切な実装

メッシュコードの妥当性チェックが適切に実装されています。無効なコードの場合のエラーハンドリングも問題ありません。

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs (1)

269-271: 2次メッシュのアドレス形式がPR要件と異なります

過去のレビューコメントでも指摘されていますが、PR要件ではtile_(secondary mesh)__(original game object name)_(ID if duplicate names exist)という形式(tile_の後にアンダースコア2つ)ですが、実装ではtile_{meshCode}_{baseName}(アンダースコア1つ)になっています。

PR要件に合わせて修正してください:

-                return $"tile_{meshCode}_{baseName}";
+                return $"tile_{meshCode}__{baseName}";
🧹 Nitpick comments (1)
Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs (1)

275-276: ズームレベルの実装が必要です

TODOコメントで示されているように、現在ズームレベルがハードコードされています。PR要件の「tile_zoom_(tile zoom level)grid...」形式を満たすために、適切なズームレベルの取得処理が必要です。

ズームレベルの取得処理の実装について支援が必要でしたら、メッシュコードからズームレベルを算出するロジックの提案も可能です。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a45c248 and 0f030b3.

📒 Files selected for processing (1)
  • Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs (8 hunks)
🔇 Additional comments (7)
Editor/Window/Main/Tab/DynamicTileGUI/DynamicTileExporter.cs (7)

3-12: 必要なusing文の追加を承認

System.Linqの追加により、新しく実装されたアドレス名生成処理で必要なLINQメソッドが使用できるようになっています。


35-40: 変数名の改善とエラーメッセージの明確化を承認

cityObjectsからcityObjectGroupsへの変数名変更により、コードの可読性が向上し、エラーメッセージもより具体的になっています。


57-60: タイルマネージャーのシングルトン化を承認

新しく追加されたGetOrCreateTileManager()メソッドにより、タイルマネージャーの取得と生成が適切に管理されています。処理開始前にタイルをクリアすることで、状態の一貫性が保たれています。


76-82: アドレス名生成処理の追加を承認

新しく実装されたGetAddress()メソッドによる一意なアドレス名の生成処理が適切に統合されています。失敗時の警告ログと処理の継続も適切です。


84-93: アドレス名の重複回避処理を承認

タイルマネージャーの既存タイルリストを使用した重複チェックにより、ファイルシステムへの依存を減らし、より効率的な重複回避が実現されています。


168-181: タイルマネージャー取得メソッドの実装を承認

シンプルで明確な実装により、シングルトンパターンが適切に実装されています。既存のマネージャーがない場合の新規作成も適切です。


260-265: メッシュコードバリデーション処理を承認

GridCode.Create()を使用したメッシュコードの妥当性チェックにより、不正な形式の早期検出と適切なエラーハンドリングが実現されています。

@yhikishima yhikishima requested a review from linoal May 29, 2025 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant