Skip to content

Instantly share code, notes, and snippets.

@DenchiSoft
Created October 27, 2019 10:53
Show Gist options
  • Save DenchiSoft/d215d1357ac9fb1bb238d225cc825789 to your computer and use it in GitHub Desktop.
Save DenchiSoft/d215d1357ac9fb1bb238d225cc825789 to your computer and use it in GitHub Desktop.
Minimal Live2D parameter manipulation example
using Live2D.Cubism.Core;
using Live2D.Cubism.Framework;
using System.Collections.Generic;
using UnityEngine;
public class L2DTest : MonoBehaviour
{
[Range(-30, 30)]
public float paramValue;
private CubismModel model;
private Dictionary<string, CubismParameter> parameters = new Dictionary<string, CubismParameter>();
void Start()
{
model = transform.FindCubismModel();
foreach (CubismParameter parameter in model.Parameters)
{
// Alternatively, use parameter.name
parameters.Add(parameter.Id, parameter);
}
}
void LateUpdate()
{
parameters["ParamAngleX"].BlendToValue(CubismParameterBlendMode.Override, paramValue);
parameters["ParamAngleY"].BlendToValue(CubismParameterBlendMode.Override, paramValue);
parameters["ParamAngleZ"].BlendToValue(CubismParameterBlendMode.Override, paramValue);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment