AnyPortrait > Script > Initialization, Basic Settings

Initialization, Basic Settings


It guides you through the functions that should be called when using a GameObject with apPortrait and the functions that should be referenced by default.


public bool Initialize ()
Description

   Initialization function that is automatically executed just before the first update.
   If you load and use the Prefab in real time, you must call the Initialize() or AsyncInitialize() function.
   A function that takes a long execution time when there is a lot of data. It is recommended that you use the AsyncInitialize() function.


Return

   bool : Returns false if it is initializing or has already finished, and returns true if initialization is successful.


public bool AsyncInitialize ()
public bool AsyncInitialize ( apPortrait.OnAsyncLinkCompleted onAsyncLinkCompleted )
public bool AsyncInitialize ( int timePerYield )
public bool AsyncInitialize ( int timePerYield, apPortrait.OnAsyncLinkCompleted onAsyncLinkCompleted )
Description

   Initialization function that performs the same function as Initialize().
   If the Prefab is loaded in real time, you must call the Initialize() or AsyncInitialize() function.
   Use asynchronous processing to reduce execution time load using coroutine.
   Callback event is received as a parameter and is called on exit.
   
   If timePerYield, which is a unit of ms, is used as a parameter, it calculates the coroutine processing time as a timer, so that the load on the CPU is reduced.
   Instead, the initialization time may take a little longer in this case.
   (Processing with timePerYield will work from v1.1.7.)


Parameters

   apPortrait.OnAsyncLinkCompleted onAsyncLinkCompleted : Callback event invoked when initialization is finished
   int timePerYield : The timeout in milliseconds that yield is called during asynchronous processing


Return

   bool : Returns false if it is initializing or has already finished, and returns true if asynchronous initialization starts


public void ShowRootUnit ()
public void ShowRootUnit ( apOptRootUnit targetOptRootUnit )
Description

   Sets the root unit to be rendered.
   It targets the root unit with the "animation clip started automatically" or the root unit with index 0.
   Other root units are automatically hidden.


Parameters

   apOptRootUnit targetOptRootUnit : The root unit to be rendered.


public void HideRootUnits ()
Description

   Hide all root units.


public void Show ()
Description

   Sets the root unit to be rendered.
   It targets the root unit with the "animation clip started automatically" or the root unit with index 0.
   Other root units are automatically hidden.
   Same as ShowRootUnit().


public void Hide ()
Description

   Hide all root units.
   Same as HideRootUnits().


public void SetImportant ( bool isImportant )
Description

   Set the "Important" property.
   If the "Important" property is True, this object is updated every frame.
   If the "Important" attribute is False, the editor will update according to the FPS specified.


Parameters

   bool isImportant : Important Property


public void SetFPSForNotImportant ( int fps )
1.2.3
Description

   If "Important" property is off, the character will run with a fixed FPS. (Depending on the game's FPS, it may run at fewer FPS.)
   You can change the value of the fixed FPS set in "Bake step" by script.


Parameters

   int fps : Fixed FPS value applied when the character's animation is executed. Valid only if the "Important" attribute is off.


public apOptRootUnit GetOptRootUnit ( int rootUnitIndex )
Description

   Returns the root unit of the requested index.


Parameters

   int rootUnitIndex : Root Unit Index (Default is 0)


Return

   apOptRootUnit : The root unit corresponding to the index. Return null if not


public apOptRootUnit GetCurrentRootUnit ()
1.3.0
Description

   Returns the currently playing root unit.


Return

   apOptRootUnit : The currently playing root unit. If not, return null


public int GetCurrentRootUnitIndex ()
1.3.0
Description

   Returns the index of the currently playing root unit.


Return

   int : The index of the currently playing root unit. If not, return -1


public void CleanUpMeshesCommandBuffers ()
Description

   If there is a mesh with a clipping mask applied, it automatically works with one camera for rendering.
   Calling this function removes and initializes the information associated with the current camera.
   When re-rendering, it automatically tries to re-link.


public void ResetMeshesCommandBuffers ( bool isOnlyActiveRootUnit )
public void ResetMeshCommandBuffer ( apOptRootUnit targetOptRootUnit, bool isRegistToCamera )
Description

   Re-link with the camera for all or some of the meshes with clipping masks.
   Depending on arguments, you can also hold back the camera and re-create the render texture (RenderTexture) only.


Parameters

   bool isOnlyActiveRootUnit : Entering true will reset the current root unit only. If false, it will target the entire root unit.
   apOptRootUnit targetOptRootUnit : The root unit to be reset
   bool isRegistToCamera : If it is true, it will re-link with the camera. If false, re-create the render texture (RenderTexure) and wait for the next frame.


public void SetSortingLayer ( string sortingLayerName )
public void SetSortingLayer ( apOptTransform optTransform, string sortingLayerName )
public void SetSortingLayer ( string transformName, string sortingLayerName )
public void SetSortingLayer ( int rootUnitIndex, string transformName, string sortingLayerName )
1.1.6
Description

   Sets the Sorting Layer used when calculating the order in which GameObjects are rendered.
   The rendering order is calculated by grouping Game Objects on the same layer.
   The Sorting Layer can be configured in Unity's Project Settings > Tags and Layers.
   If you enter a name that is not set, processing will fail with an error message.
   ​
   If you only want to change the Sorting Layer of a specific apOptTransform,
   you can specify the apOptTransform object directly or enter its name as an argument.


Parameters

   string sortingLayerName : Name of the Sorting Layer to set
   apOptTransform optTransform : The object whose Sorting Layer is to be changed
   string transformName : The name of the optTransform for which you want to change the Sorting Layer
   ​int rootUnitIndex : The index of the root unit to which the optTransform to change the Sorting Layer belongs to


public void SetSortingOrder ( int sortingOrder )
public void SetSortingOrder ( apOptTransform optTransform, int sortingOrder )
public void SetSortingOrder ( string transformName, int sortingOrder )
public void SetSortingOrder ( int rootUnitIndex, string transformName, int sortingOrder )
1.1.6
Description

   Sets the Sorting Order used when calculating the order in which GameObjects are rendered.
   A GameObject with a large value in the same sorting layer is rendered on the front of the screen.
   ​
   If you only want to change the Sorting Order of a specific apOptTransform,
   you can specify the apOptTransform object directly or enter its name as an argument.


Parameters

   int sortingOrder : Rendering order. Larger values render in front of the screen.
   apOptTransform optTransform : The object whose Sorting Order is to be changed
   string transformName : The name of the optTransform for which you want to change the Sorting Order
   ​int rootUnitIndex : The index of the root unit to which the optTransform to change the Sorting Order belongs to


public string GetSortingLayerName ()
1.0.2
Description

   Returns the name of the currently applied Sorting Layer.
   The name of the Sorting Layer must be registered in Project Settings > Tags and Layers.
   It is not recommended to call this function frequently because it queries the settings of the project every time this function is called.


Return

   string : Name of the applied Sorting Layer. If it has a sorting layer value that does not match the project settings, it returns "Unknown Layer".


public int GetSortingOrder ()
1.0.2
Description

   Returns the currently applied Sorting Order value.
   The larger this value is, the more the front of the screen is rendered.


Return

   int : The current rendering order.


public int GetSortingOrder ( apOptTransform optTransform )
1.3.0
Description

   Returns the current Sorting Order value for a specific apOptTransform.


Parameters

   apOptTransform optTransform : Target apOptTransform


Return

   int : Current rendering Sorting Order.


public void SetSortingOrderChangedAutomatically ( bool isEnabled )
1.1.8
Description

   This is the function used when the Sorting Order Option of apPortrait is "Depth To Order" or "Reverse Depth To Order".
   This function determines whether the "Sorting Order" value of meshes will be changed automatically by changing the depth.
   If you want to control the Sorting Order with a script, you must enter False to prevent the Sorting Order from being changed automatically.
   The default value is True.


Parameters

   bool isEnabled : If true, the Sorting Order is changed automatically.


public void FindRenderingCamerasAutomatically ()
1.2.0
Description

   Set to recognize the cameras in the scene automatically while simultaneously checking the current cameras to determine how to render.
   Even if this function is not called, it is set to recognize the cameras in the scene in run time.


public int SetRenderingCameras ( params Camera[] cameras )
1.2.0
Description

   You can specify the cameras to render the character.
   After this function is called, it will not automatically check for cameras in the scene until the FindRenderingCamerasAutomatically() function is called.


Parameters

   params Camera[] cameras : Specify one or more cameras.


Return

   int : The number of cameras that can actually render the character.


public bool Synchronize ( apPortrait targetPortrait, bool syncAnimation, bool syncControlParam )
public bool Synchronize ( apPortrait targetPortrait, bool syncAnimation, bool syncControlParam, bool syncRootUnit )
public bool Synchronize ( apPortrait targetPortrait, bool syncAnimation, bool syncControlParam, bool syncRootUnit, bool syncBones, SYNC_BONE_OPTION syncBoneOption )
1.3.4
Description

   Synchronizes the values of animation or control parameters to the target character.
   When this function is called, the corresponding character is updated depending on the target character.
   Examples of using this function can be found on the following pages.
   - Synchronize with other characters
   - Synchronize bones to change costumes


Parameters

   apPortrait targetPortrait : The apPortrait to be synchronized.
   bool syncAnimation : Whether to sync animations.
   bool syncControlParam : Whether to synchronize control parameters.
   bool syncRootUnit : Whether to synchronize Root Units. The number of Root Units of apPortrait to be synchronized must be 2 or more and they must be the same. If the animation is synchronized, this request will be ignored.
   bool syncBones : Whether to synchronize the movement of the bones.
   SYNC_BONE_OPTION syncBoneOption : When synchronizing the movements of the bones, you can choose how to synchronize them. If you enter MatchFromRoot, the structure must be the same from the root bone, which is the topmost. If you enter MatchFromSubBones, the root bone of the character being synchronized will be synchronized even if it is not the root bone of the target character. If syncBones is false, this option is ignored, so you can enter any value.


Return

   bool : Synchronization processing result. Returns false if processing fails, such as if the synchronization target is invalid or already synchronized.


public void Unsynchronize ()
1.3.2
Description

   Turns off synchronization.


public void SetUpdateTimeMethod ( bool useUnscaleDeltaTime )
public void SetUpdateTimeMethod ( bool useUnscaleDeltaTime, float multiplier )
1.3.4
Description

   Determines which time value in Unity to use when the character is updated.
   Depending on this option, you can set whether the game speed will be affected and time multiplier.
   It does not apply when using Mecanim.
   You can learn the example using this functions at the related page.


Parameters

   bool useUnscaleDeltaTime : If this value is true, it is updated by Unity's Time.unscaledDeltaTime, and if false, it is updated by Time.deltaTime. (The default is false .)
   float multiplier : You can set the update speed. If not entered, it is set to the default speed of 1x.


public void SetUpdateTimeMethod ( OnDeltaTimeRequested onDeltaTimeRequested )
public void SetUpdateTimeMethod ( OnDeltaTimeRequested onDeltaTimeRequested, object savedObject )
1.3.5
Description

   When a character is updated, you can use a callback function to control the playback speed.
   It does not apply when using Mecanim.
   You can learn the example using this functions at the related page.


Parameters

   OnDeltaTimeRequested onDeltaTimeRequested : A callback function that returns the time of the current frame. You can modify the update time. The format of the callback function is "float OnDeltaTimeRequested(object savedObject)" .
   object savedObject : It is a value that can be used for purposes such as identifying which object is calling when a callback function is called. There is no restriction on the type, and null is possible.