UMotion API
The UMotion API is a simple and easy-to-use API that provides a basic interface for custom scripts to interact with UMotion. The API provides classes and methods that support the following features:
- Opening the UMotion windows
- Opening/closing UMotion projects
- Switching between animation clips
- Assigning or removing a GameObject to/from the Pose Editor
In order to implement custom constraints or 3rd party IK solutions, please take a look at the UMotion Callback System instead.
Preparation
To access the UMotion API in one of your scripts, make sure that they are placed inside an "Editor" folder. Add the following using statement to get access to the UMotion namespace: using UMotionEditor.API; There are two classes within this namespace:
- ClipEditor
- PoseEditor
ClipEditor Overview
Properties
- static bool IsWindowOpened True when the Clip Editor window is opened and initialized. It might be necessary to focus either the Clip Editor or the Pose Editor window in order to initialize UMotion.
- static bool IsProjectLoaded True when the Clip Editor window has a UMotion project loaded.
Methods
- static void OpenWindow() Opens the UMotion Clip Editor window. If the window is already opened but hidden by another window, it is brought to the front. It takes at least one frame (or more) until the window is initialized.
- static void LoadProject(string path) Loads a UMotion project. The Clip Editor needs to be open in order for this method to succeed. This method can also be used to switch from one loaded project to another. The path must be relative to the Unity project directory (e.g. "Assets/umotion_project.asset").
- static void CloseProject() Closes a loaded UMotion project.
- static string GetLoadedProjectPath() Get the path to the currently loaded UMotion project. The path is relative to the Unity project directory. Returns null if no project is currently loaded.
- static string[] GetAllClipNames() Returns the names of all animation clips in the currently loaded UMotion project. A UMotion project must be loaded.
- static string GetSelectedClipName() Returns the name of the currently selected animation clip in the Clip Editor.
- static void SelectClip(string name) Selects (opens) the clip in the clip editor. The clip must already exist in the current UMotion project.
- static void SetClipName(string oldName, string newName) Changes the name of an animation clip. When called right before "ExportCurrentClip()" this method can be used to change the name of the exported animation clip. This is useful when exporting the same animation clip several times (with different animation layers enabled).
- static void ExportCurrentClip() Exports the clip currently opened in the Clip Editor. This method blocks until the export is finished.
- static void ExportAllClips() Exports all clips of the current loaded UMotion project. This method blocks until the export is finished.
- static string[] GetClipLayerNames() Returns an array that holds the names of all animation layers of the currently opened animation clip. The base layer is not included.
- static void SetClipLayerName(string oldName, string newName) Changes the name of an animaton layer of the currently opened animation clip.
- static void GetClipLayerBlendProperties(string layerName, out bool mute, out float blendWeight) Gets the blend properties (mute and blend weight 0-1) of the layer with the given name.
- static void SetClipLayerBlendProperties(string layerName, bool mute, float blendWeight) Sets the blend properties (mute and blend weight 0-1) of the layer with the given layer name. This method is useful for exporting an animation clip several times with different layers muted/unmuted.
PoseEditor Overview
Properties
- static bool IsWindowOpened True when the Pose Editor window is opened and initialized. It might be necessary to focus either the Pose Editor or the Clip Editor window in order to initialize UMotion.
Methods
- static void OpenWindow() Opens the UMotion Pose Editor window. If the window is already opened but hidden by another window, it is brought to the front. It takes at least one frame (or more) until the window is initialized.
- static void SetAnimatedGameObject(GameObject gameObject) Applies a GameObject (from the current Unity scene) to the Pose Editor. A UMotion project already needs to be loaded.
- static void ClearAnimatedGameObject(PoseEditor.ClearMode clearMode = PoseEditor.ClearMode.RevertChanges) Removes a GameObject from the Pose Editor. By default, the GameObject is reverted to the pose that it had before it has been assigned to UMotion.
enum PoseEditor.ClearMode
- RevertChanges Restores the original pose of the GameObject before it was assigned to the UMotion Pose Editor.
- KeepChanges Keeps the current pose of the GameObject.