AnyPortrait > Scripting > Control Parameter

​Control Parameter

Control parameters can be referenced or controlled by a script.

Controlling the control parameters affects the modifiers associated with them.

public apControlParam GetControlParam(string controlParamName)

​Description

Retrieves the control parameter.

Parameters

string controlParamName : The name of the control parameter

Return

apControlParam : The control parameter with the requested name (null if not exist)

public bool IsControlParamExist(string controlParamName)

​Description

Check that the control parameter with that name exists.

Parameters

string controlParamName : The name of the control parameter

Return

bool : Whether a control parameter with the requested name exists

public bool SetControlParamInt(string controlParamName, int intValue)

​Description

Specifies the value of an Int type control parameter.

If it is outside the range of the control parameters, it is limited to the minimum or maximum value.

Parameters

string controlParamName : The name of the control parameter

int intValue : Int value

Return

bool : Whether the process succeeded

public bool SetControlParamInt(apControlParam controlParam, int intValue)

​Description

Specifies the value of an Int type control parameter.

If it is outside the range of the control parameters, it is limited to the minimum or maximum value.

Parameters

apControlParam controlParam : Target control parameter

int intValue : Int value

Return

bool : Whether the process succeeded

public bool SetControlParamFloat(string controlParamName, float floatValue)

​Description

Specifies the value of an Float type control parameter.

If it is outside the range of the control parameters, it is limited to the minimum or maximum value.

Parameters

string controlParamName : The name of the control parameter

float floatValue : Float value

Return

bool : Whether the process succeeded

public bool SetControlParamFloat(apControlParam controlParam, float floatValue)

​Description

Specifies the value of an Float type control parameter.

If it is outside the range of the control parameters, it is limited to the minimum or maximum value.

Parameters

apControlParam controlParam : Target control parameter

float floatValue : Float value

Return

bool : Whether the process succeeded

public bool SetControlParamVector2(string controlParamName, Vector2 vec2Value)

​Description

Specifies the value of a control parameter of Vector2 type.

If it is out of the control parameter range for X, Y axis respectively, it is limited to minimum or maximum value.

Parameters

string controlParamName : The name of the control parameter

Vector2 vec2Value : Vector2 value

Return

bool : Whether the process succeeded

public bool SetControlParamVector2(apControlParam controlParam, Vector2 vec2Value)

​Description

Specifies the value of a control parameter of Vector2 type.

If it is out of the control parameter range for X, Y axis respectively, it is limited to minimum or maximum value.

Parameters

apControlParam controlParam : Target control parameter

Vector2 vec2Value : Vector2 value

Return

bool : Whether the process succeeded

public bool SetControlParamDefaultValue(string controlParamName)

​Description

Initializes the value of the control parameter to the default value.

Parameters

string controlParamName : The name of the control parameter

Return

bool : Whether the process succeeded

using UnityEngine;
using AnyPortrait;

public class ControlParamTest : MonoBehaviour
{
           // Target AnyPortrait
           public apPortrait portrait;

    

           // Parameter Values
           private int _eyeShape = 0;
           private int _mouthShape = 0;
           private float _verticalPosition = 0.0f;

           

           void Start () { }
        
           void Update ()
           {
                      // "Eye Shape" (0, 1, 2, 3 int)
                      if(Input.GetKeyDown(KeyCode.E))
                      {
                                 _eyeShape++;
                                 if(_eyeShape > 3) { _eyeShape = 0; }

                                 

                                 portrait.SetControlParamInt("Eye Shape", _eyeShape);
                      }

                      

                      // "Mouth Shape" (0, 1, 2, int)
                      if(Input.GetKeyDown(KeyCode.M))
                      {
                                 _mouthShape++;
                                 if(_mouthShape > 2) { _mouthShape = 0; }

            

                                 portrait.SetControlParamInt("Mouth Shape", _mouthShape);
                      }

        

                      // "Vertical Position" (0 ~ 1 float)
                      if(Input.GetKey(KeyCode.UpArrow))
                      {
                                 // Move Upward
                                 _verticalPosition += 2 * Time.deltaTime;
                                 if(_verticalPosition > 1) { _verticalPosition = 1; }

 

                                 portrait.SetControlParamFloat("Vertical Position", _verticalPosition);
                      }
                      else if(Input.GetKey(KeyCode.DownArrow))
                      {
                                 // Move Downward
                                 _verticalPosition -= 2 * Time.deltaTime;
                                 if(_verticalPosition < 0) { _verticalPosition = 0; }

            

                                 portrait.SetControlParamFloat("Vertical Position", _verticalPosition);
                      }
           }
}