目录
一、运用unity Live Capture插件与iphone Unity Face Capture软件
(2)创建一个空物体(命名:Recorder),添加Take Recorder组件。
(3)将模型拖入场景,并添加ARKit Face Actor组件,将该模型制作成Prefab。
(4)设置模型ARKit Face Actor组件中的mapper。
(5)设置New FaceDevice的ARKit Face Device组件的Actor值。
3. iphone下载Unity Face Capture软件
Live Capture在Package Manager中通过git url的方式进行添加:

在该组件下添加ARKit Face Device:此时会在Recorder物体下自动创建New FaceDevice,该物体上有个ARKit Face Device组件。

注意模型导入Unity时要勾选Import BlendShapes(检查一下即可,unity默认勾选)。
在Project中创建一个mapper(右键/Create/Live Capture / ARKit Face Capture / Mapper),设置mapper相关属性(RigPrefab指定为上一步生成的prefab,LeftEye、RightEye、Head要选择对应的关节。这一步目的是映射BlendShape,如果我们的模型BlendShape名称符合苹果的ARKit要求,则AddRender操作会自动映射,否则需要我们手动设置)。

点击Window/Live Capture/Connections,点击Configure FireWall。点击Create Server/Companion App Server,点击Start开启服务。

打开软件(该软件在iphone 12 Pro Max 15.4.1上亲测稳定,在iphone X上会发热闪退),输入IP及Port,连接之后就可以驱动了~(如果连不上,可能unity版本不符合或者网络不符合,可参考官方文档:About Live Capture | Live Capture | 1.0.1 (unity3d.com))
- public sealed class Mesh : Object
- {
- public int blendShapeCount { get; }
- public string GetBlendShapeName(int shapeIndex);
- }
- public class SkinnedMeshRenderer : Renderer{
- public void SetBlendShapeWeight(int index, float value);
- }
可能算法提供的数据值范围为0-1,所以在SetBlendShapeWeight时要*100。
- Dictionary<string, int> bs_map;//模型上的bs名称-索引
- skinnedMeshRenderer.SetBlendShapeWeight(bs_map["eyebrow_BS.Eyebrows_Sad_L"], 20);