If you have any questions, reports, suggestions, or requests about Live2D, please send them to this forum.
※We cannot guarantee statements or answers from Live2D staff. Thank you for your understanding in advance.
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.
The L2DBaseModel class, from which the LAppModel class should be inheriting, has a getLive2DModel() method which returns the Live2D model instance once the moc has been loaded. Did you give that method a try?
I haven't, just tried it out but it still returns as Null... not sure what did I do wrong here.
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!
Hey, sorry for answering late. The below isn't tested but hopefully works. (let me know if not). The currently easiest way to do this if you don't want to do the loading completely on your own is to initialize a 'LAppModelProxy' component and then access the Live2D model through that. I hope this allows you to achieve what you want to.
using live2d;
using live2d.framework;
using UnityEngine;
// Require a 'LAppModelProxy' component to be available
// (making sure to set the proxy up in the inspector).
[RequireComponent(typeof(LAppModelProxy))]
public class PrintHandPosition : MonoBehaviour
{
private LAppModelProxy _proxy;
private void Update()
{
if (proxy == null)
{
proxy = GetComponent<LAppModelProxy>();
}
var model = proxy
.GetModel()
.getLive2DModel();
Debug.Log(model);
}
}
Got it, I made it work now the value returns as Live2DModelUnity
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);
}
}
Ah I figured it out, I had to delete some scripts which controlling the model idle animation from LAppModel.cs, now I can modify the parameters outside of the class Thank you so much, now finally I can sleep at night lol
Yeah, hopefully! With no clear documentation most of us could only rely on sample scripts provided..with no clear comments either which functions goes where, lol.
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); } }