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

How do I load Mecanim animations on the Android platform? #788

Open
3 of 7 tasks
WalkerMe opened this issue Oct 12, 2024 · 1 comment
Open
3 of 7 tasks

How do I load Mecanim animations on the Android platform? #788

WalkerMe opened this issue Oct 12, 2024 · 1 comment

Comments

@WalkerMe
Copy link

Describe the bug 💬

I need to load some animation resources directly without going through Unity's import process.
Using the code below, it runs normally in the Editor, but on Android, the loaded Clip is incorrect and the action cannot be played.

`public async Task Load(string uri)
{
string dir = URIHelper.GetDirectoryName(uri);
ImportOptions options = new()
{
AnimationMethod = AnimationMethod.Mecanim,
ImportNormals = GLTFImporterNormals.None,
ImportTangents = GLTFImporterNormals.None,
// ImportContext = new GLTFImportContext(GLTFSettings.GetOrCreateSettings()),
DataLoader = new UnityWebRequestLoader(dir),
AsyncCoroutineHelper = UITools.GetOrAdd(GameRunner.Inst.gameObject),
};

string fileName = Path.GetFileName(uri);
GLTFSceneImporter importer = new(fileName, options)
{
    SceneParent = null,
    Collider = GLTFSceneImporter.ColliderType.None,
    IsMultithreaded = false,
};
await importer.LoadSceneAsync(-1, false, _OnLoadComplete);
AnimationClip[] clips = importer.CreatedAnimationClips;
if (null == clips || 0 == clips.Length) return null;
Object.Destroy(importer.LastLoadedScene);
importer.Dispose();
return clips[0];

}
`

Steps to reproduce 🔢

Loading Mecanim animations from glTF files on the Android platform is bound to fail.

Files to reproduce the issue ♻

No response

Editor Version 🎲

2022.3

Render Pipeline and version

URP

UnityGLTF Version

2.13.0

Operating System 👩‍💻

Android

When does this problem happen?

  • Editor Import
  • Runtime Import
  • Editor Export
  • Runtime Export

Additional Info 📜

No response

Validations 🩹

@pfcDorn
Copy link
Contributor

pfcDorn commented Oct 16, 2024

hey,
because we can't create Animator Controllers outside of the Editor (Unity restrictions), you need to add the animation to an existing Animator Controller.

From the readme:
image

Have you already try that or is there another importing issue (when yes, please provide a sample file) ?

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

No branches or pull requests

2 participants