Mysteryem / Miscellaneous

Random scripts and programs that don't have a better home
MIT License
0 stars 0 forks source link

VrcAssetImportDefaults.cs: Disable "Sort Hierarchy By Name" #1

Open Mysteryem opened 2 years ago

Mysteryem commented 2 years ago

VRChat has the requirement that bones controlled by IK be the first child of their parent. Bones can be renamed in Blender to ensure they end up in the correct child order for VRChat, but often the alphabetical ordering in Unity will still end up different to the alphabetical ordering in Blender (usually due to certain characters being removed from the names or due to a mesh or another GameObject sharing the same name as a bone, causing the bone to be affixed with a number to ensure uniqueness). Disabling "Sort Hierarchy By Name" should result in the Unity hierarchy more closely matching the hierarchy seen in Blender. unknown

Note that in Unity, you can reorder the bones in a prefab by changing each bone's sibling index, but I'm unsure if this can be done to the imported .fbx. prefab, or only the prefab added into a scene. See: https://gitlab.com/s-ilent/silenttools/-/blob/master/Assets/SilentTools/Editor/SilentTools.cs

Mysteryem commented 1 year ago

If it's possible to automatically re-order sibling index upon import it would be good, but the initial import is usually as Generic and even then, the automatically assigned bones could be wrong.

Perhaps it would be possible to add a listener for VRChat's 'on build' that some other tools use and set the sibling indices before building (if that occurs in Play Mode, this assumes setting sibling index is even possible and won't break things if it is)