-
Notifications
You must be signed in to change notification settings - Fork 872
feat(scene): add scene_view screenshot capture source and fix viewport handling #872
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
Closed
jiajunfeng
wants to merge
5
commits into
CoplayDev:beta
from
jiajunfeng:feat/scene-view-screenshot-capture
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
17c9524
feat(mcpforunity): add long coercion helpers for object-reference fileID
0863a1e
feat(mcpforunity): support atlas sprite resolution by guid+spriteName…
fda2ecb
fix(mcpforunity): include Unsafe dependency in Roslyn installer
726509d
feat(scene): add scene view screenshot capture source
7153272
fix(scene): align scene view screenshot viewport handling
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Repository Guidelines | ||
|
|
||
| ## Project Structure & Module Organization | ||
| This repo has two primary codebases: | ||
| - `Server/`: Python MCP server (`src/` runtime code, `tests/` Python tests, `pyproject.toml`). | ||
| - `MCPForUnity/`: Unity package (mainly `Editor/` tools/services and `Runtime/` code). | ||
|
|
||
| Supporting areas: | ||
| - `TestProjects/UnityMCPTests/`: Unity test project and C# test suites. | ||
| - `docs/`: user, migration, and development documentation. | ||
| - `tools/` and `scripts/`: release/dev utilities. | ||
| - `mcp_source.py`: switch Unity package source for local/upstream workflows. | ||
|
|
||
| ## Build, Test, and Development Commands | ||
| - `cd Server && uv run src/main.py --transport stdio`: run local server over stdio. | ||
| - `cd Server && uv run src/main.py --transport http --http-url http://127.0.0.1:8080`: run local HTTP server. | ||
| - `cd Server && uv run pytest tests/ -v`: run Python server tests. | ||
| - `cd Server && uv run pytest tests/ --cov --cov-report=html`: run coverage and generate `htmlcov/`. | ||
| - `cd Server && uv run python -m cli.main editor tests --mode PlayMode`: run Unity tests via MCP bridge (Unity must be running). | ||
| - `python mcp_source.py`: point Unity project to upstream/main/beta/local package sources. | ||
|
|
||
| ## Coding Style & Naming Conventions | ||
| - Python: 4-space indentation, snake_case modules/functions, keep async command handlers focused by domain under `Server/src/cli/commands/`. | ||
| - C#: PascalCase for types/methods, `ManageXxx` naming for tool classes, keep one tool responsibility per class. | ||
| - Prefer small, explicit code over one-off abstractions. | ||
| - Type checking uses `Server/pyrightconfig.json` (`typeCheckingMode: basic`). | ||
|
|
||
| ## Testing Guidelines | ||
| - Add tests for all feature work in both touched layers when applicable (Python + Unity). | ||
| - Python test files follow `test_*.py` under `Server/tests/`. | ||
| - Validate behavior changes with targeted tests first, then broader suites before PR. | ||
|
|
||
| ## Commit & Pull Request Guidelines | ||
| - Branch from `beta`; do not target `main` for feature development. | ||
| - Follow existing commit style: `feat(scope): ...`, `fix: ...`, `docs: ...`, `chore: ...`. | ||
| - Keep commits focused and reference issue/PR IDs when relevant (e.g., `(#859)`). | ||
| - PRs should include: clear summary, linked issue/discussion, test evidence, and screenshots/GIFs for Unity UI/tooling changes. | ||
|
|
||
| ## Security & Configuration Tips | ||
| - Default local HTTP endpoint is `127.0.0.1`; avoid exposing `0.0.0.0` unless explicitly needed. | ||
| - For local server iteration in Unity, use **Server Source Override** to your `Server/` path and enable **Dev Mode**. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Silent fallthrough when fileID doesn't match any sprite.
When
fileIDis provided but no sprite in the atlas matches, the code falls through to load the main asset at the path (line 665). This may return an unexpected asset type (e.g., the texture atlas itself) instead of failing with a clear error.Consider returning an error when fileID is provided but not found:
Proposed fix
var fileIdToken = jObj["fileID"]; if (fileIdToken != null) { long targetFileId = ParamCoercion.CoerceLong(fileIdToken, 0); if (targetFileId != 0) { var allAssets = AssetDatabase.LoadAllAssetsAtPath(path); foreach (var asset in allAssets) { if (asset is Sprite sprite) { long spriteFileId = GetSpriteFileId(sprite); if (spriteFileId == targetFileId) { prop.objectReferenceValue = sprite; return true; } } } + error = $"Sprite with fileID {targetFileId} not found in atlas '{path}'."; + return false; } }🤖 Prompt for AI Agents