/// <summary> /// 设置Live2D对象 /// </summary> /// <param name="live2DData"></param> public void SetLive2DData(Live2DData live2DData) { if (this.live2DData != null) { Clear(); } this.live2DData = live2DData; gameObject = live2DData.GetGameObject(); transform = gameObject.transform; animator = gameObject.GetComponent <Animator>(); fadeController = gameObject.GetComponent <CubismFadeController>(); if (fadeController == null) { fadeController = gameObject.AddComponent <CubismFadeController>(); } fadeController.CubismFadeMotionList = live2DData.fadeMotionList; motionController = gameObject.GetComponent <CubismMotionController>(); if (motionController == null) { motionController = gameObject.AddComponent <CubismMotionController>(); } }
/// <summary> /// 创建Live2D动画 /// </summary> /// <param name="live2DData"></param> /// <returns></returns> public Live2DRenderer CreateLive2DRenderer(Live2DData live2DData) { Live2DRenderer renderer = App.objectPoolManager.GetObject <Live2DRenderer>(); renderer.SetLive2DData(live2DData); return(renderer); }
/// <summary> /// 清理 /// </summary> public void Clear() { transform = null; animator = null; fadeController.CubismFadeMotionList = null; fadeController = null; motionController = null; live2DData.ReleaseGameObject(gameObject); live2DData = null; }
/// <summary> /// 创建Live2D动画 /// </summary> /// <param name="name"></param> /// <returns></returns> public Live2DRenderer CreateLive2DRenderer(string name) { Live2DData live2DData = GetLive2DData(name); if (live2DData == null) { return(null); } return(CreateLive2DRenderer(live2DData)); }
/// <summary> /// 创建Live2D数据 /// </summary> /// <param name="name"></param> /// <param name="prefab"></param> /// <param name="animatorController"></param> /// <param name="fadeMotionList"></param> /// <returns></returns> public Live2DData CreateLive2DData(string name, GameObject prefab, RuntimeAnimatorController animatorController, CubismFadeMotionList fadeMotionList) { Live2DData live2DData = App.objectPoolManager.GetObject <Live2DData>(); live2DData.name = name; live2DData.prefab = prefab; live2DData.animatorController = animatorController; live2DData.fadeMotionList = fadeMotionList; live2DData.scale = defaultScale; return(live2DData); }