void SetupBoneRig(Transform jawBone, Transform head) { LipsyncTemplate template = Resources.Load <LipsyncTemplate>(JawTemplate); LipsyncController controller = SetupController(template, MainObject.AddComponent <LipsyncController>()); AudioSource source = head.GetComponent <AudioSource>(); if (source == null) { source = head.gameObject.AddComponent <AudioSource>(); source.spatialBlend = 1.0f; } controller.mouthSource = source; controller.mouth = jawBone.gameObject; }
void SetupBlendshapeRig(SkinnedMeshRenderer smr, string shapeID, Transform head) { LipsyncTemplate template = Resources.Load <LipsyncTemplate>(ShapeTemplate); LipsyncController controller = SetupController(template, MainObject.AddComponent <LipsyncController>()); AudioSource source = head.GetComponent <AudioSource>(); if (source == null) { source = head.gameObject.AddComponent <AudioSource>(); source.spatialBlend = 1.0f; } controller.mouthSource = source; controller.skinnedMeshRenderer = smr; controller.shapeName = shapeID; }
LipsyncController SetupController(LipsyncTemplate template, LipsyncController controller) { controller.analysisType = template.analysisType; controller.syncType = template.syncType; controller.mouthAxis = template.mouthAxis; controller.mouthRotAxis = template.mouthRotAxis; controller.volByDistance = template.volByDistance; controller.volume = template.volume; controller.rotVolume = template.rotVolume; controller.minVol = template.minVol; controller.maxVol = template.maxVol; controller.frqHigh = template.frqHigh; controller.frqLow = template.frqLow; controller.ignoreDistance = template.ignoreDistance; return(controller); }
LipsyncController SetupController(LipsyncTemplate template, LipsyncController controller) { if (template == null) { template = CreateInstance <LipsyncTemplate>(); template.syncType = syncType; } controller.mode = syncMode; controller.analysisType = template.analysisType; controller.syncType = template.syncType; controller.mouthAxis = template.mouthAxis; controller.mouthRotAxis = template.mouthRotAxis; controller.volByDistance = template.volByDistance; controller.volume = template.volume; controller.rotVolume = template.rotVolume; controller.minVol = template.minVol; controller.maxVol = template.maxVol; controller.frqHigh = template.frqHigh; controller.frqLow = template.frqLow; controller.ignoreDistance = template.ignoreDistance; return(controller); }