AnyPortrait > Script > Control Parameter
Control parameters can be referenced or controlled by a script.
Controlling the control parameters affects the modifiers associated with them.
Retrieves the control parameter.
string controlParamName : The name of the control parameter
apControlParam : The control parameter with the requested name (null if not exist)
Check that the control parameter with that name exists.
string controlParamName : The name of the control parameter
bool : Whether a control parameter with the requested name exists
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.
string controlParamName : The name of the control parameter
apControlParam controlParam : Target control parameter
int intValue : Int value
bool : Whether the process succeeded
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.
string controlParamName : The name of the control parameter
apControlParam controlParam : Target control parameter
float floatValue : Float value
bool : Whether the process succeeded
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.
string controlParamName : The name of the control parameter
apControlParam controlParam : Target control parameter
Vector2 vec2Value : Vector2 value
bool : Whether the process succeeded
Initializes the value of the control parameter to the default value.
string controlParamName : The name of the control parameter
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);
}
}
}