AnyPortrait > Scripting > Mesh, Mesh Group Transform

Mesh, Mesh Group Transform

It guides you through functions such as changing the color or texture of a mesh, or controlling its position.

In the editor, the mesh and mesh group data is converted to apOptTransform after bake.

Referencing apOptTransform in the scene is the same as referencing a mesh or mesh group.

Functions for batch conversion of textures and Draw Call Batching are also provided.

public apOptTransform GetOptTransform(string transformName)

public apOptTransform GetOptTransform(int rootUnitIndex, string transformName)

​Description

Finds and returns apOptTransform by name.

The name of apOptTransform is the name of the mesh or mesh group.

If you do not specify a root unit index, first perform a full search from the root unit that is currently being rendered.

Parameters

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

Return

apOptTransform : apOptTransform retrieved. Return null if not

public Transform GetOptTransformSocket(apOptTransform optTransform)

public Transform GetOptTransformSocket(string transformName)

public Transform GetOptTransformSocket(int rootUnitIndex, string transformName)

​Description

Refers to a socket in apOptTransform.

Please refer to related page about socket.

Parameters

apOptTransform optTransform : apOptTransform containing socket

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

Return

Transform : Socket Transform of apOptTransform. Return null if not

public bool SetOptTransformPosition(apOptTransform optTransform, Vector3 position, Space space,

                                                  float weight = 1.0f)

public bool SetOptTransformPosition(string transformName, Vector3 position, Space space, float weight = 1.0f)

public bool SetOptTransformPosition(int rootUnitIndex, string transformName, Vector3 position, Space space,

                                                  float weight = 1.0f)

​Description

Controls the position of apOptTransform.

You can interpolate using weights.

Parameters

apOptTransform optTransform : apOptTransform to control

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

Vector3 position : Position to move

Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.

float weight : Interpolation weight with original position

Return

bool : Return false if it refers to apOptTransform that does not exist

public bool SetOptTransformRotation(apOptTransform optTransform, float angle, Space space,                                                                           float weight = 1.0f)

public bool SetOptTransformRotation(string transformName, float angle, Space space, float weight = 1.0f)

public bool SetOptTransformRotation(int rootUnitIndex, string transformName, float angle, Space space,

                                                   float weight = 1.0f)

​Description

Controls the angle of rotation of apOptTransform.

You can interpolate using weights.

Parameters

apOptTransform optTransform : apOptTransform to control

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

float angle : Angle to rotate (Degree)

Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.

float weight : Interpolation weight with original rotation angle

Return

bool : Return false if it refers to apOptTransform that does not exist

public bool SetOptTransformScale(apOptTransform optTransform, Vector3 scale, Space space,                                                                         float weight = 1.0f)

public bool SetOptTransformScale(string transformName, Vector3 scale, Space space, float weight = 1.0f)

public bool SetOptTransformScale(int rootUnitIndex, string transformName, Vector3 scale, Space space,

                                               float weight = 1.0f)

​Description

Controls the size of apOptTransform.

You can interpolate using weights

Parameters

apOptTransform optTransform : apOptTransform to control

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

Vector3 scale : Scale value

Space space : World refers to the coordinate system of the scene, and Self refers to the coordinate system of apPortrait.

float weight : Interpolation weight with original size

Return

bool : Return false if it refers to apOptTransform that does not exist

public void SetMeshImage(apOptTransform optTransform, Texture2D texture)

public void SetMeshImage(string transformName, Texture2D texture)

public void SetMeshImage(int rootUnitIndex, string transformName, Texture2D texture)

public void SetMeshImage(apOptTransform optTransform, string imageName)

public void SetMeshImage(string transformName, string imageName)

public void SetMeshImage(int rootUnitIndex, string transformName, string imageName)

​Description

Replaces the texture of the apOptTransform.

If the texture is replaced, the draw call may increase.

Parameters

apOptTransform optTransform : apOptTransform to refer

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

Texture2D texture : Texture to replace

string imageName : When replacing an image stored in the AnyPortrait editor, the name of the image

public void SetMeshColor(apOptTransform optTransform, Color color2X)

public void SetMeshColor(string transformName, Color color2X)

public void SetMeshColor(int rootUnitIndex, string transformName, Color color2X)

​Description

Sets the color of the apOptTransform.

Colors are calculated as 2X Multiply, so the default is gray (0.5, 0.5, 0.5, 1).

If the color is not the default, the draw call may increase.

Parameters

apOptTransform optTransform : apOptTransform to refer

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

Color color2X : Color to replace (2X Multiply)

public void SetMeshAlpha(apOptTransform optTransform, float alpha)

public void SetMeshAlpha(string transformName, float alpha)

public void SetMeshAlpha(int rootUnitIndex, string transformName, float alpha)

​Description

Sets the alpha (transparency) of the color of apOptTransform.

The default value is 1; otherwise, the draw call may increase.

Parameters

apOptTransform optTransform : apOptTransform to refer

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

float alpha : Alpha to replace

public void SetMeshCustomImage(apOptTransform optTransform, Texture2D texture, string propertyName)

​Description

Replaces the texture of the apOptTransform.

If the texture is replaced, the draw call may increase.

Parameters

apOptTransform optTransform : apOptTransform to refer

Texture2D texture : Texture to replace

string propertyName : Shader property name

public void SetMeshCustomColor(apOptTransform optTransform, Color color2X, string propertyName)

​Description

Sets the color of the apOptTransform.

Colors are calculated as 2X Multiply, so the default is gray (0.5, 0.5, 0.5, 1).

If the color is not the default, the draw call may increase.

Parameters

apOptTransform optTransform : apOptTransform to refer

Color color2X : Color to replace (2X Multiply)

string propertyName : Shader property name

public void SetMeshCustomAlpha(apOptTransform optTransform, float alpha, string propertyName)

​Description

Sets the alpha (transparency) of the color of apOptTransform.

The default value is 1; otherwise, the draw call may increase.

Parameters

apOptTransform optTransform : apOptTransform to refer

float alpha : Alpha to replace

string propertyName : Shader property name

public void SetMeshCustomFloat(apOptTransform optTransform, float floatValue, string propertyName)

​Description

Sets the value of the Float property of the material of apOptTransform.

When this function is called, the draw call may increase.

Parameters

apOptTransform optTransform : apOptTransform to refer

float floatValue : Float Value

string propertyName : Shader property name

public void SetMeshCustomInt(apOptTransform optTransform, int intValue, string propertyName)

​Description

Sets the value of the Int property of the material of apOptTransform.

When this function is called, the draw call may increase.

Parameters

apOptTransform optTransform : apOptTransform to refer

int intValue : Int Value

string propertyName : Shader property name

public void SetMeshCustomVector4(apOptTransform optTransform, Vector4 vector4Value, string propertyName)

​Description

Sets the value of the Vector4 property of the material of apOptTransform.

When this function is called, the draw call may increase.

Parameters

apOptTransform optTransform : apOptTransform to refer

Vector4 vector4Value : Vector4 Value

string propertyName : Shader property name

public void SetMeshCustomTextureOffset(apOptTransform optTransform, Vector2 textureOffsetValue,

                                                         string propertyName)

​Description

Sets the value of the Offset property of the texture of the material of apOptTransform.

When this function is called, the draw call may increase.

(This function applies from version 1.1.4.)

Parameters

apOptTransform optTransform : apOptTransform to refer

Vector2 textureOffsetValue : Texture Offset Value

string propertyName : Shader property name

public void SetMeshCustomTextureScale(apOptTransform optTransform, Vector2 textureScaleValue,

                                                        string propertyName)

​Description

Sets the value of the Scale property of the texture of the material of apOptTransform.

When this function is called, the draw call may increase.

(This function applies from version 1.1.4.)

Parameters

apOptTransform optTransform : apOptTransform to refer

Vector2 textureScaleValue : Texture Scale Value

string propertyName : Shader property name

public void ShowMesh(apOptTransform optTransform)

public void ShowMesh(string transformName)

public void ShowMesh(int rootUnitIndex, string transformName)

​Description

Makes the apOptTransform containing the mesh rendered.

Parameters

apOptTransform optTransform : apOptTransform to render

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

public void HideMesh(apOptTransform optTransform)

public void HideMesh(string transformName)

public void HideMesh(int rootUnitIndex, string transformName)

​Description

Hides the apOptTransform containing the mesh from rendering.

Parameters

apOptTransform optTransform : apOptTransform to hide

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

public apOptTextureData GetOptTextureData(string optTextureName)

​Description

If the apOptTransform meshes use the same texture, it is possible to control them all in apOptTextureData.

If you use the apOptTextureData functions to modify the material properties of the texture, color, etc.,

 all meshes that use this texture will be automatically changed.

Batch change functions

  • SetMeshTextureAll(Texture2D texture)

  • SetCustomImageAll(Texture2D texture, string propertyName)

  • SetMeshColorAll(Color color)

  • SetCustomColorAll(Color color, string propertyName)

  • SetCustomFloatAll(float floatValue, string propertyName)

  • SetCustomIntAll(int intValue, string propertyName)

  • SetCustomVector4All(Vector4 vector4Value, string propertyName)

Parameters

string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)

Return

apOptTextureData : Referenced apOptTextureData. Return null if not

public void SetMeshImageAll(string optTextureName, Texture2D texture)

public void SetMeshCustomImageAll(string optTextureName, Texture2D texture, string propertyName)

​Description

Batchly replace textures in all meshes that use apOptTextureData.

Parameters

string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)

Texture2D texture : Texture to replace

string propertyName : Shader property name

public void SetMeshColorAll(Color color2X)

public void SetMeshColorAll(string optTextureName, Color color2X)

public void SetMeshCustomColorAll(Color color, string propertyName)

public void SetMeshCustomColorAll(string optTextureName, Color color, string propertyName)

​Description

Batchly replace the colors of all the meshes.

Entering optTextureName sets the color for meshes that use the corresponding apOptTextureData.

When you modify mainColor, it uses 2X Multiply color by default.

Parameters

string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)

Color color2X / color : Color to replace

string propertyName : Shader property name

public void SetMeshAlphaAll(float alpha)

public void SetMeshAlphaAll(string optTextureName, float alpha)

public void SetMeshCustomAlphaAll(float alpha, string propertyName)

public void SetMeshCustomAlphaAll(string optTextureName, float alpha, string propertyName)

​Description

Batchly replace alpha (transparency) of all meshes.

Entering optTextureName sets the alpha of meshes that use the apOptTextureData.

Parameters

string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)

float alpha : Alpha to replace

string propertyName : Shader property name

public void SetMeshCustomFloatAll(float floatValue, string propertyName)

public void SetMeshCustomFloatAll(string optTextureName, float floatValue, string propertyName)

public void SetMeshCustomIntAll(int intValue, string propertyName)

public void SetMeshCustomIntAll(string optTextureName, int intValue, string propertyName)

public void SetMeshCustomVector4All(Vector4 vector4Value, string propertyName)

public void SetMeshCustomVector4All(string optTextureName, Vector4 vector4Value, string propertyName)

​Description

Batchly set property values ​​for all meshes.

Entering optTextureName sets the value of the property for meshes that use apOptTextureData.

Parameters

string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)

float floatValue : Float Value

int intValue : Int Value

Vector4 vector4Value : Vector4 Value

string propertyName : Shader property name

public void ResetMeshMaterialToBatch(apOptTransform optTransform)

public void ResetMeshMaterialToBatch(string transformName)

public void ResetMeshMaterialToBatch(int rootUnitIndex, string transformName)

​Description

Returns the material property of the apOptTransform to the value of the Bake state.

Draw calls may be reduced, which may improve performance.

Parameters

apOptTransform optTransform : Target apOptTransform

int rootUnitIndex : Root Unit Index (if not, search all)

string transformName : The name of the apOptTransform (the name of the mesh or mesh group on the editor)

public void ResetMeshMaterialToBatchAll()

​Description

Returns the material property of all apOptTransform to the value of the Bake state.

Draw calls may be reduced, which may improve performance.

public void ResetMeshMaterialToBatchByTextureName(string optTextureName)

​Description

Returns all material properties using the requested texture to the value of the Bake state.

Draw calls may be reduced, which may improve performance.

(This function applies from version 1.1.4.)

Parameters

string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)