Skip to content
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

Unity Character Rig Avatar and Avatar Mask Creation #2

Open
diegodelarocha opened this issue May 6, 2020 · 1 comment
Open

Unity Character Rig Avatar and Avatar Mask Creation #2

diegodelarocha opened this issue May 6, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@diegodelarocha
Copy link
Collaborator

Would be quite useful if the GLTF importer had a feature to add a Character Avatar and Character Masks like the FBX importer has, so that we can use the animation states with `

Avatar Masks` on the Unity Animation Controller 🤓

Here's an image of the FBX importer tab where it deals with creating an Avatar for the imported character's hierarchy of bones.

fbxImporterAvatar

Here's some code that let's you pull a generic Avatar, and an Avatar Mask on the Unity Editor, but it would be way more helpful, if it was included on the importer 🤓 😍

using UnityEditor;
using UnityEngine;
 
namespace Infrastructure.Editor
{
    public class avatarCreator
    {
        [MenuItem("AvatarTools/CreateAvatarMask")]
        private static void CreateAvatarMask()
        {
            GameObject activeGameObject = Selection.activeGameObject;
 
            if (activeGameObject != null)
            {
                AvatarMask avatarMask = new AvatarMask();
 
                avatarMask.AddTransformPath(activeGameObject.transform);
 
                var path = string.Format("Assets/{0}.mask", activeGameObject.name.Replace(':', '_'));
                AssetDatabase.CreateAsset(avatarMask, path);
            }
        }
 
        [MenuItem("AvatarTools/CreateAvatar")]
        private static void CreateAvatar()
        {
            GameObject activeGameObject = Selection.activeGameObject;
 
            if (activeGameObject != null)
            {
                Avatar avatar = AvatarBuilder.BuildGenericAvatar(activeGameObject, "");
                avatar.name = activeGameObject.name;
                Debug.Log(avatar.isHuman ? "is human" : "is generic");
 
                var path = string.Format("Assets/{0}.ht", avatar.name.Replace(':', '_'));
                AssetDatabase.CreateAsset(avatar, path);
            }
        }
    }
}
@diegodelarocha diegodelarocha added the enhancement New feature or request label May 6, 2020
@diegodelarocha
Copy link
Collaborator Author

Before adding this, make sure it hasn't been already been addressed by Siccity's here. 🤓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant