Tanoda
ByNameLipSyncMapper.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using TriLibCore.General;
3using TriLibCore.Interfaces;
4using UnityEngine;
5
6namespace TriLibCore.Mappers
7{
9 [CreateAssetMenu(menuName = "TriLib/Mappers/LypSync/By Name Lip Sync Mapper", fileName = "ByNameLipSyncMapper")]
10 public class ByNameLipSyncMapper : LipSyncMapper
11 {
15 [Header("Left = Blend-Shape Key Name, Right = Viseme Name")]
17
21 public bool CaseInsensitive = true;
22
27 public List<VisemeCandidate> VisemeCandidates;
28
30 protected override int MapViseme(AssetLoaderContext assetLoaderContext, LipSyncViseme viseme, IGeometryGroup geometryGroup)
31 {
32 for (var i = 0; i < VisemeCandidates.Count; i++)
33 {
34 var visemeCandidate = VisemeCandidates[i];
35 if (visemeCandidate.Viseme == viseme)
36 {
37 foreach (var candidateName in visemeCandidate.CandidateNames)
38 {
39 for (var j = 0; j < geometryGroup.BlendShapeKeys.Count; j++)
40 {
41 var blendShapeGeometryBinding = geometryGroup.BlendShapeKeys[j];
42 if (Utils.StringComparer.Matches(StringComparisonMode, CaseInsensitive, blendShapeGeometryBinding.Name, candidateName))
43 {
44 return j;
45 }
46 }
47 }
48 }
49 }
50
51 return -1;
52 }
53 }
54}
Represents a Mapper that search Visemes by searching Blend-Shape Keys names.
StringComparisonMode StringComparisonMode
String comparison mode to use on the mapping.
override int MapViseme(AssetLoaderContext assetLoaderContext, LipSyncViseme viseme, IGeometryGroup geometryGroup)
bool CaseInsensitive
Is the string comparison case insensitive?
List< VisemeCandidate > VisemeCandidates
The viseme candidates. A viseme candidate is a reference between visemes and valid blend-shape names ...