====== vci.assets(ExportAnimation) ====== \\ Staring from [[en:vci:updatelog:1.7.2a |UniVCI v0.21]], multiple animations added to objects other than the root will be exported during the VCI export.\\ ---- ===== List of methods ===== **For the latest list of the methods, refer to "types.lua" file in "EmbeddedScriptWorkspace" folder. ** ^ Method ^ Description ^ | GetCount: fun(): number | Get the count of animations. | | GetNames: fun(): usertype | Get the name of animations | | | HasClip: fun(name: string): bool | Indicates whether or not animations exist. (1.8.2a)| | IsPlaying: fun(): bool | Indicates whether or not animations is playing. (1.8.2a)| | Play: fun(isloop: bool) | Loop play when the argument is true. Play once when the argument is false. | | PlayFromIndex: fun(index: number, isloop: bool) | Specify an animation with an index number and play. | | PlayFromName: fun(name: string, isloop: bool) | Specify an animation with a file name and play. | | PlayOneShot: fun() | Play an animation once.\\ It is equivalent to **Play(false)**. | | PlayWithState: fun(name: string, states: string) | Specify a state and play. (1.8.2a)| | Blend: fun(name: string, options: string) | Play blended animations. (1.8.2a)| | CrossFade: fun(name: string, options: string) | Play cross-faded animations. (1.8.2a)| | SetState: fun(name: string, states: string) | Specify a state for an animation. (1.8.2a)| | Stop: fun() | Stop the playback of an animation. | | Rewind: fun() | Rewinds the playing animation. (1.8.2a)| The methods with ''_ALL_'' are run on other clients as well. ^ Method ^ Description ^ | _ALL_Play: fun(isloop: bool) | Loop play when the argument is true. Play once when the argument is false. | | _ALL_PlayFromIndex: fun(index: number, isloop: bool) | Specify an animation with an index number and play. | | _ALL_PlayFromName: fun(name: string, isloop: bool) | Specify an animation with a file name and play. | | _ALL_PlayOneShot: fun() | Play an animation once. | | _ALL_PlayWithState: fun(name: string, states: string) | Specify a state and play. (1.8.2a)| | _ALL_Blend: fun(name: string, options: string) | Play blended animations. (1.8.2a)| | _ALL_CrossFade: fun(name: string, options: string) | Play cross-faded animations. (1.8.2a)| | _ALL_SetState: fun(name: string, states: string) | Specify a state for an animation. (1.8.2a)| | _ALL_Stop: fun() | Stop the playback of an animation. | | _ALL_Rewind: fun() | Rewinds the playing animation. (1.8.2a)| * The objects to attach an animation doesn't have to be a subitem. ==== Configurable settings of PlayWithState and SetState ==== ^ Name ^ Type ^ Description ^ |speed|number| Specify the playback speed. The default value is 1. Specify a value higher than 0. | |weight|number|Specify the blend weight. The default value is 1. Specify a value between 0 and 1. | |wrap_mode |string|Specify the wrap mode. The default value is once. You can specify `once,` `loop` or `ping_pong. **Example** Convert a table into json and pass. local table = { wrap_mode="loop", speed=0.2} local jsonString = json.serialize(table) anim.PlayWithState("AnimationName", jsonString) ==== Configurable settings of Blend ==== ^ Name ^ Type ^ Description ^ |target_weight |number|Specify the blend weight. The default value is 1. Specify a value higher than 0. | |fade_length |number|Specify a fade time (seconds). The default value is 0.3 seconds. Specify a value higher than 0. | **Example** Convert a table into json and pass. local table = { wrap_mode="loop", speed=1} local jsonString = json.serialize(table) anim.SetState("Playing animation", jsonString) anim.Blend("animation to blend", json.serialize({target_weight=2, fade_length=1})) ==== Configurable settings for CrossFade ==== ^ Name ^ Type ^ Description ^ |fade_length |number|Specify a fade time (seconds). Default value is 0.3 seconds. Specify a value higher than 0. | **Example** Convert a table into json and pass. anim.CrossFade("Animation name", json.serialize({fade_length=1})) Pass an empty string when not specifying the option. anim.CrossFade("Animation name", "")) ---- ===== Summary ===== Example\\ local chan_1 = vci.assets.GetSubItem("SD_unitychan_generic_1") local chan_2 = vci.assets.GetSubItem("SD_unitychan_generic_2") local chan_3 = vci.assets.GetSubItem("SD_unitychan_generic_3") -- Get animations from ExportTransform local chanAnime_1 = chan_1.GetAnimation() local chanAnime_2 = chan_2.GetAnimation() local chanAnime_3 = chan_3.GetAnimation() -- Play chanAnime_1.Play(true) -- The same as PlayFromIndex(0, true) chanAnime_2.Play(true) -- The same as PlayFromIndex(0, false) chanAnime_3.PlayFromName("Damaged@loop", true) -- You can get the count and the names of animations print(chanAnime_3.GetCount()) local names = chanAnime_3.GetNames() for i,m in ipairs(names) do print(string.format("%d[%s]",i,m)) end The result\\ (Three animations are played) ---- **Explanation**\\