示例#1
0
        public Live2dPlay(Live2dPlayableVo playableVo, L2DView l2DView, Action onNextStep)
        {
            _onNextStep = onNextStep;
            _l2DView    = l2DView;
            _playableVo = playableVo;

            if (playableVo.motionName.Contains(L2DConst.MOTION_EYEBLINK))
            {
                _playType = Live2dPlayableVo.Live2dPlayType.EyeBlink;
            }
            else if (playableVo.motionName.Contains(L2DConst.MOTION_MOTIONLESS))
            {
                _playType = Live2dPlayableVo.Live2dPlayType.MontionLess;
            }
            else
            {
                _playType = Live2dPlayableVo.Live2dPlayType.Motion;
            }

            if (playableVo.delay <= 0)
            {
                Play();
            }
            else
            {
                _isDelayState = true;
            }
        }
示例#2
0
        /// <summary>
        /// 加载BundleAssets\SingleFile\Live2d\Animation路径下对应id的动画
        /// </summary>
        /// <param name="id">live2d id,文件夹名</param>
        /// <param name="x">x方向偏移量</param>
        /// <param name="y">y方向偏移量</param>
        /// <param name="width">缩放比例</param>
        public void LoadAnimationById(string id, float x = -0.85f, float y = 1.32f, float width = 1.7f, int textureWidth = 1440, int textureHeight = 2500)
        {
            if (_rtTex != null)
            {
                if (_live2dCanvas != null && _live2dCanvas.Live2dCamera != null)
                {
                    _live2dCanvas.Live2dCamera.targetTexture = null;
                }

                DestroyImmediate(_rtTex);
            }

            _rtTex = new RenderTexture(textureWidth, textureHeight, (int)Screen.dpi, RenderTextureFormat.ARGB32);
            _live2dCanvas.Live2dCamera.targetTexture = _rtTex;

            _image         = transform.GetComponent <RawImage>();
            _image.texture = _live2dCanvas.Live2dCamera.targetTexture;

            if (_live2dView == null)
            {
                _live2dView = Live2dManager.CreateL2DView(id, _live2dCanvas, _donotUnloadIds);
                _live2dView.Live2dViewType = LIVE2DVIEWTYPE.MAINPANLE;
            }
            else
            {
                _live2dView.LoadModel(id, _donotUnloadIds);
            }

            _live2dView.X     = x;
            _live2dView.Y     = y;
            _live2dView.Width = width;
        }
示例#3
0
        public void SetData(EntityVo vo)
        {
            if (_live2dCanvas.Live2dCamera.targetTexture != null)
            {
                Debug.LogError("===========_live2dCanvas.Live2dCamera.targetTexture==============");
            }

            var w      = vo.width;
            var h      = vo.height;
            var target = new RenderTexture((int)w, (int)h, (int)Screen.dpi, RenderTextureFormat.ARGB32);

            _live2dCanvas.Live2dCamera.targetTexture = target;

            _image         = transform.GetComponent <RawImage>();
            _image.texture = _live2dCanvas.Live2dCamera.targetTexture;

            _entityVo = vo;
            if (_live2dView == null)
            {
                _live2dView = Live2dManager.CreateL2DView(vo.id, _live2dCanvas, _donotUnloadIds);
                //  _live2dView.Live2dViewType = LIVE2DVIEWTYPE.MAINPANLE;
            }
            else
            {
                _live2dView.LoadModel(vo.id, _donotUnloadIds);
            }

            _live2dView.X     = vo.L2dScaleDataList[0];
            _live2dView.Y     = vo.L2dScaleDataList[1];
            _live2dView.Width = vo.L2dScaleDataList[2];

            _live2dView.LipSync = vo.lipSpync;
        }
示例#4
0
    public static L2DView CreateL2DView(string modelId, Live2dCanvas live2DCanvas, List <string> _donotUnloadIds)
    {
        L2DView l2dView = live2DCanvas.gameObject.AddComponent <L2DView>();

        l2dView.LoadModel(modelId, _donotUnloadIds);

        return(l2dView);
    }
示例#5
0
 public Live2dPlaySequence(L2DView l2DView, List <Live2dPlayableVo> playableList)
 {
     _l2DView      = l2DView;
     _playableList = playableList;
 }