AnyPortrait > Script > 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.
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.
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)
apOptTransform : apOptTransform retrieved. Return null if not
Refers to a socket in apOptTransform.
Please refer to related page about socket.
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)
Transform : Socket Transform of apOptTransform. Return null if not
Controls the position of apOptTransform.
You can interpolate using weights.
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
bool : Return false if it refers to apOptTransform that does not exist
Controls the angle of rotation of apOptTransform.
You can interpolate using weights.
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
bool : Return false if it refers to apOptTransform that does not exist
Controls the size of apOptTransform.
You can interpolate using weights
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
bool : Return false if it refers to apOptTransform that does not exist
Replaces the texture of the apOptTransform.
If the texture is replaced, the draw call may increase.
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
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.
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)
Sets the alpha (transparency) of the color of apOptTransform.
The default value is 1; otherwise, the draw call may increase.
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
Replaces the texture of the apOptTransform.
If the texture is replaced, the draw call may increase.
When targeting "_MainTex", please use the "SetMeshImage" function.
Instead of optTransform, you can specify the target by entering transformName and rootUnitIndex.
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 propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Sets the color of the apOptTransform.
If the color is not the default, the draw call may increase.
When targeting "_Color", use the "SetMeshColor" function.
Instead of optTransform, you can specify the target by entering transformName and rootUnitIndex.
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 color : Color to replace
string propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Sets the alpha (transparency) of the color of apOptTransform.
The default value is 1; otherwise, the draw call may increase.
When targeting "_Color", use the "SetMeshAlpha" function.
Instead of optTransform, you can specify the target by entering transformName and rootUnitIndex.
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
string propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Sets the value of the Float property of the material of apOptTransform.
When this function is called, the draw call may increase.
Instead of optTransform, you can specify the target by entering transformName and rootUnitIndex.
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 floatValue : Float Value
string propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Sets the value of the Int property of the material of apOptTransform.
When this function is called, the draw call may increase.
Instead of optTransform, you can specify the target by entering transformName and rootUnitIndex.
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)
int intValue : Int Value
string propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Sets the value of the Vector4 property of the material of apOptTransform.
When this function is called, the draw call may increase.
Instead of optTransform, you can specify the target by entering transformName and rootUnitIndex.
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)
Vector4 vector4Value : Vector4 Value
string propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
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.
apOptTransform optTransform : apOptTransform to refer
Vector2 textureOffsetValue : Texture Offset Value
string propertyName : Shader property name
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.
apOptTransform optTransform : apOptTransform to refer
Vector2 textureScaleValue : Texture Scale Value
string propertyName : Shader property name
Makes the apOptTransform containing the mesh rendered.
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)
Hides the apOptTransform containing the mesh from rendering.
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)
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)
- SetCustomImageAll(Texture2D texture, int propertyNameID)
- SetMeshColorAll(Color color)
- SetCustomColorAll(Color color, string propertyName)
- SetCustomColorAll(Color color, int propertyNameID)
- SetCustomFloatAll(float floatValue, string propertyName)
- SetCustomFloatAll(float floatValue, int propertyNameID)
- SetCustomIntAll(int intValue, string propertyName)
- SetCustomIntAll(int intValue, int propertyNameID)
- SetCustomVector4All(Vector4 vector4Value, string propertyName)
- SetCustomVector4All(Vector4 vector4Value, int propertyNameID)
string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)
apOptTextureData : Referenced apOptTextureData. Return null if not
Batchly replace textures in all meshes that use apOptTextureData.
When targeting "_MainTex", use "SetMeshImageAll" function instead of "SetMeshCustomImageAll" function.
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
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
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.
When targeting "_Color", use "SetMeshColorAll" function instead of "SetMeshCustomColorAll" function.
string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)
Color color : Color to replace
string propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Batchly replace alpha (transparency) of all meshes.
Entering optTextureName sets the alpha of meshes that use the apOptTextureData.
When targeting "_Color", use "SetMeshAlphaAll" function instead of "SetMeshCustomAlphaAll" function.
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
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Batchly set Float property values for all meshes.
Entering optTextureName sets the value of the property for meshes that use apOptTextureData.
string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)
float floatValue : Float Value
string propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Batchly set Int property values for all meshes.
Entering optTextureName sets the value of the property for meshes that use apOptTextureData.
string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)
int intValue : Int Value
string propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Batchly set Vector4 property values for all meshes.
Entering optTextureName sets the value of the property for meshes that use apOptTextureData.
string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)
Vector4 vector4Value : Vector4 Value
string propertyName : Shader property name
int propertyNameID : Shader property ID (use the Shader.PropertyToID function to get the ID)
Change the value of Offset or Scale of custom texture property of all meshes.
Vector2 textureOffsetValue : Offset of the texture propertie
Vector2 textureScaleValue : Scale of the texture propertie
string propertyName : Texture property name
Returns the material property of the apOptTransform to the value of the Bake state.
Draw calls may be reduced, which may improve performance.
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)
Returns the material property of all apOptTransform to the value of the Bake state.
Draw calls may be reduced, which may improve performance.
Returns all material properties using the requested texture to the value of the Bake state.
Draw calls may be reduced, which may improve performance.
string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)
If you change the texture of an image subject to the Extra option using the image texture change function, calling this function returns the image's texture to the Bake state value.
This function only affects the processing of Extra options.
string optTextureName : The name of the apOptTexture to reference. (Name of the Image of the editor.)
Reduces draw calls by merging materials, including the character the function is called on and other characters input as arguments.
apPortraits with merged materials share the behavior of the functions changing materials in a batch.
When materials are merged, the behavior of some functions change.
When this function is called, the "ResetMeshMaterialToBatchAll()" function is executed inside.
For more information, please refer to the related page.
params apPortrait[] otherPortraits : Enter other apPortraits. You can enter one or more or none by the params keyword.
Unmerge materials.
All apPortraits connected to this apPortrait are treated in the same way, so you only need to call this function once.
When this function is called, the "ResetMeshMaterialToBatchAll()" function is executed inside.
Using the GetOptTransform function, you can efficiently write a script by using some functions while referring to apOptTransform.
Many functions of apOptTransform are used in AnyPortrait's system, so it is recommended to use only the functions introduced here.
public int GetSortingOrder()
: If it has a mesh, returns the Sorting Order value of the mesh renderer.
public void SetSortingOrder(int sortingOrder)
: If it has a mesh, a Sorting Order is assigned to the mesh renderer via this function.