Skip to content

Use class database MonoBehaviour header for TypeTreeGenerator nodes - #403

Open
1915rising wants to merge 1 commit into
K0lb3:masterfrom
1915rising:fix/388-monobehaviour-generator-header
Open

1915rising wants to merge 1 commit into
K0lb3:masterfrom
1915rising:fix/388-monobehaviour-generator-header

Conversation

@1915rising

Copy link
Copy Markdown

Fixes #388.

When a MonoBehaviour has no typetree and env.typetree_generator is set, the node returned by TypeTreeGeneratorAPI uses a fixed header that puts the align flag on m_GameObject, m_Script and m_Name, instead of only after m_Enabled as Unity and the class database do. m_Script is therefore read 3 bytes early (the issue's example reads PathID 0x4455667788000000 instead of 0x1122334455667788) and is written back changed on save.

This replaces the generated node's fields up to and including m_Name with the class-database header in generate_monobehaviour_node, leaving the generated script fields untouched. If either node has no m_Name field, the generated node is returned unchanged.

Tests: new tests/test_monobehaviour_node.py (2 tests) reproduces the issue's read/save round-trip — both fail on unpatched code and pass with the fix. Full suite: 44 passed / 4 failed before, 46 passed / 4 failed after; the 4 failures are pre-existing Git-LFS sample-data failures, identical before and after.

AI-assisted; the fix was reproduced and tested locally before submission.

This branch has not been deployed

No deployments
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.

MonoBehaviour nodes from TypeTreeGenerator misread m_Script and change it on save

1 participant