Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Masking imported clips in editor script?

Discussion in 'Immediate Mode GUI (IMGUI)' started by ryancampfire, Jul 10, 2017.

  1. ryancampfire

    ryancampfire

    Joined:
    Jan 4, 2017
    Posts:
    31
    So I'm trying to automate importing a bunch of animations that all have similar format.

    So far, I can easily make clips and set their start and end frames. But they also need masks applied to them and I'm not 100% on that yet.

    ModelImporterClipAnimation newClip = new ModelImporterClipAnimation();

    So I make an array of ModelImporterClipAnimation and assign them to the ModelImporter's .clipAnimations right?

    ModelImporterClipAnimation has its own properties, most are easy for me to set up what I want, but the mask is not obvious.

    There's a .maskSource property which is of type AvatarMask, and that has a SetTransformActive method. But it only accepts an index to pick which transform. If I want to find the index of a bone according to its name, how would I do that?
     
  2. ryancampfire

    ryancampfire

    Joined:
    Jan 4, 2017
    Posts:
    31
    So the ModelImporter has a .transformPaths property, so I tried looping through that, finding matching strings, and calling SetTransformActive method, but that gets me an InvalidTransformIndex.

    Manually going in through the editor, all the animation clips have a "Mask does not match hierarchy" message, which can be fixed by clicking the "Fix Mask" button. Is there an equivalent to that button that I can call from the script?
     
  3. ryancampfire

    ryancampfire

    Joined:
    Jan 4, 2017
    Posts:
    31
    I tried calling SaveAndReimport on the model before setting the masks, but it didn't make the indices get set correctly. Can't think of anything else to try.