// -------------------------------------------------------------------- private void AutodetectWithRules() // TODO - Move this to an autodetection thing { FaceSyncData syncData = target as FaceSyncData; if (syncData.ReferenceText == null || syncData.ReferenceText.Length == 0) { return; } Dictionary <string, FaceSyncBlendSet> rules = FaceSyncSettings.GetSettings().GetHashedRules(); float totalDuration = syncData.GetDuration(); string lowerCaseText = syncData.ReferenceText.ToLower(); for (int i = 0; i < syncData.ReferenceText.Length; ++i) { foreach (var rule in rules) { if (lowerCaseText.Substring(i).StartsWith(rule.Key.ToLower())) { FaceSyncKeyframe kf = new FaceSyncKeyframe(((float)i / syncData.ReferenceText.Length) * totalDuration); kf.BlendSet = rule.Value; syncData.Keyframes.Add(kf); } } } }
public static FaceSyncSettings GetSettings() { if (mSettings) { return(mSettings); } string path = "Assets/FaceSync/FaceSync/Data/Settings.asset"; mSettings = AssetDatabase.LoadAssetAtPath(path, typeof(FaceSyncSettings)) as FaceSyncSettings; if (mSettings == null) { mSettings = CreateInstance <FaceSyncSettings>(); FaceSyncUtils.CreateAssetWithPath(mSettings, path); } return(mSettings); }