[Notice of Holidays]
Please note that our staff will not be available from 2024/Dec/28 - 2025/Jan/5 JST.
The Live2D Creators Forum will remain open during the holidays.
Submissions that require a response will be answered after we reopen for business.
Please note that it will take longer than usual to respond to your request.
How do I reference the model from a script?
Is there any way I can reference a Live2D model within a script instead of modifying it inside LAppModel.cs, for example?
I tried public Live2DModelUnity live2dmodel; but it always returns as null.
0 ·
Comments
using live2d;
using live2d.framework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PrintHandPosition : MonoBehaviour
{
L2DBaseModel lappmodel = new L2DBaseModel();
// Update is called once per frame
private void Update()
{
var l2dmodel = lappmodel.getLive2DModel();
Debug.Log(l2dmodel);
}
}
I want to control my model motion parameter from a script, if you can help me write the snippet of the code for that (without modifying any files from Sample1App) it would be much appreciated!
However I still can't get setParamFloat to work, could you see what did I do wrong here?:
using live2d; using live2d.framework; using System.Collections; using System.Collections.Generic; using UnityEngine; public class PrintHandPosition : MonoBehaviour { private L2DBaseModel l2dbasemodel; private LAppModelProxy _proxy; private ALive2DModel themodel; // Use this for initialization void Start() { if (_proxy == null) { _proxy = GameObject.Find("Live2D_Canvas").GetComponent<LAppModelProxy>(); } var model = _proxy.GetModel(); themodel = model.getLive2DModel(); } // Update is called once per frame private void Update() { themodel.setParamFloat("PARAM_CHEEK", 1, 1); //this line simply has no effect themodel.update(); Debug.Log(themodel); } }