novemberi / clover

Powerful VSCode extension for Unity project
MIT License
22 stars 1 forks source link

Feature: implement Unity Asset Diff Tool #25

Open ArnCarveris opened 4 months ago

ArnCarveris commented 4 months ago

Is your feature request related to a problem? Please describe. Is very hard to resolve merge conflicts by hand in text editor it very error prone

Describe the solution you'd like There should be something similar like UnityAssetViewerwhere you will see in hierarchy (and inspector) changes and conflicts, you should able to choose how to resolve merge conflict. It would be great to allow git to use UnityAssetDiff as mergetool

Describe alternatives you've considered None.

Additional context example: https://assetstore.unity.com/packages/tools/version-control/unimerge-9733

novemberi commented 4 months ago

This is really good idea! But the key is how to detect the file was changed. This feature will be integrate with git or something. Or we can supported conflict text viewer when happening merge conflict.

<<<<<< HEAD
some codes..
======
some codes..
>>>>>> commit hash

Maybe we can use this too.

ArnCarveris commented 4 months ago

Yaml parser should able able to parse merge conflict headers, it should be merge config node and two nodes with its infos. It should be happens before: https://github.com/novemberi/unity-yaml-parser/blob/master/main.ts#L28

ArnCarveris commented 4 months ago

Just to note JSON have diff & patch stuff https://jsonpatch.com/ there for yam: https://www.npmjs.com/package/yaml-diff-patch

ArnCarveris commented 3 months ago

@novemberi I did some research, firstly there is no way to preprocess yaml before asset got loaded via editor, you still need external tooling to explicitly launch and make invalid yaml file loadable by Unity, that means that you need restructure merge conflict markers into valid yaml diff objects, there comes interesting part you need read that diff and turn into specific component that holds info about diff same like PrefabInstance holds prefab overrides via PropertyModification class, this also used in undo system and in-editor animation frame recording, knowing this I think there is needed create specific component MergeConflictDescriptor you pass diff and rest meta data like commit hash to that instance, and in UnityEditorthere should be custom GUI for that to resolve merge conflict, you choose what version to apply in edit time, you could do that in vscode, but due huge sizes of game content yaml files it takes ages to just parse single big file, but this will work fine for small projects. If you do GUI for MergeConflictDescriptor then it should be consistent in UX both UnityEditor and vscode