diff --git a/Assets/Scripts/UmaDatabase/UmaDataTypes.cs b/Assets/Scripts/UmaDatabase/UmaDataTypes.cs index 2f777bb..632db93 100644 --- a/Assets/Scripts/UmaDatabase/UmaDataTypes.cs +++ b/Assets/Scripts/UmaDatabase/UmaDataTypes.cs @@ -32,6 +32,7 @@ public class UmaLyricsData public string text; } +[System.Serializable] public class EmotionKey { public FacialMorph morph; @@ -46,11 +47,7 @@ public class FaceTypeData public FaceEmotionKeyTarget target; - public List mouthTarget; - public List eyeLTarget; - public List eyeRTarget; - public List eyebrowLTarget; - public List eyebrowRTarget; + public List emotionKeys; private float _weight; public float Weight diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index 6310e45..2d9d28e 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -187,7 +187,7 @@ public class UmaViewerUI : MonoBehaviour container.Slider.value = morph.Weight; container.Slider.maxValue = 1; container.Slider.minValue = 0; - container.Slider.onValueChanged.AddListener((a) => { morph.Weight = a;}); + container.Slider.onValueChanged.AddListener((a) => { target.ChangeMorphWeight(morph, a); }); } } diff --git a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs index cb9500e..ac7f586 100644 --- a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs +++ b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs @@ -108,7 +108,8 @@ namespace Gallop } } FacialResetAll(); - MouthMorphs[3].Weight = 1; + ChangeMorphWeight(MouthMorphs[3], 1); + if (UmaViewerUI.Instance) { UmaViewerUI.Instance.LoadFacialPanels(this); @@ -153,6 +154,7 @@ namespace Gallop { morph._weight = 0; } + ChangeMorph(); } private void ProcessMorph(FacialMorph morph) @@ -198,6 +200,21 @@ namespace Gallop trs.Key.localRotation = RotationConvert.fromMaya(trs.Value); } } + + public void ChangeMorphWeight(FacialMorph morph,float val) + { + morph.Weight = val; + ChangeMorph(); + } + + public void ChangeMorphWeights(Dictionary morphs) + { + foreach(var item in morphs) + { + item.Key.Weight = item.Value; + } + ChangeMorph(); + } } } diff --git a/Assets/Scripts/umamusume/Gallop/FaceEmotionKeyTarget.cs b/Assets/Scripts/umamusume/Gallop/FaceEmotionKeyTarget.cs index 049c279..01a823b 100644 --- a/Assets/Scripts/umamusume/Gallop/FaceEmotionKeyTarget.cs +++ b/Assets/Scripts/umamusume/Gallop/FaceEmotionKeyTarget.cs @@ -16,12 +16,12 @@ public class FaceEmotionKeyTarget : ScriptableObject { if (emotion.label == "Base") continue; emotion.target = this; - - InitializeEmotionTarget(ref emotion.mouthTarget,ref emotion.mouthTarget, FaceDrivenKeyTarget.MouthMorphs, emotion.mouth, false); - InitializeEmotionTarget(ref emotion.eyeLTarget, ref emotion.eyeLTarget, FaceDrivenKeyTarget.EyeMorphs, emotion.eye_l, true); - InitializeEmotionTarget(ref emotion.eyeRTarget, ref emotion.eyeRTarget, FaceDrivenKeyTarget.EyeMorphs, emotion.eye_r, false); - InitializeEmotionTarget(ref emotion.eyebrowLTarget, ref emotion.eyebrowLTarget, FaceDrivenKeyTarget.EyeBrowMorphs, emotion.eyebrow_l, true); - InitializeEmotionTarget(ref emotion.eyebrowRTarget, ref emotion.eyebrowRTarget, FaceDrivenKeyTarget.EyeBrowMorphs, emotion.eyebrow_r, false); + emotion.emotionKeys = new List(); + InitializeEmotionTarget(emotion,FaceDrivenKeyTarget.MouthMorphs, emotion.mouth, false); + InitializeEmotionTarget(emotion, FaceDrivenKeyTarget.EyeMorphs, emotion.eye_l, true); + InitializeEmotionTarget(emotion, FaceDrivenKeyTarget.EyeMorphs, emotion.eye_r, false); + InitializeEmotionTarget(emotion, FaceDrivenKeyTarget.EyeBrowMorphs, emotion.eyebrow_l, true); + InitializeEmotionTarget(emotion, FaceDrivenKeyTarget.EyeBrowMorphs, emotion.eyebrow_r, false); } if (UmaViewerUI.Instance) @@ -30,9 +30,8 @@ public class FaceEmotionKeyTarget : ScriptableObject } } - private void InitializeEmotionTarget(ref List targets, ref List emotionKeys,List morphs,string tags,bool direction) + private void InitializeEmotionTarget(FaceTypeData faceTypeData, List morphs,string tags,bool direction) { - targets = new List(); foreach (var morphName in tags.Split('|')) { EmotionKey newValue = new EmotionKey(); @@ -48,7 +47,7 @@ public class FaceEmotionKeyTarget : ScriptableObject newValue.morph = morphs.Where(a => a.tag == splitArray[0] && a.direction == direction).First(); } newValue.weight = Convert.ToInt32(splitArray[1]); - emotionKeys.Add(newValue); + faceTypeData.emotionKeys.Add(newValue); Debug.Log(newValue.weight); } else @@ -62,7 +61,7 @@ public class FaceEmotionKeyTarget : ScriptableObject newValue.morph = morphs.Where(a => a.tag == morphName && a.direction == direction).First(); } newValue.weight = 100; - emotionKeys.Add(newValue); + faceTypeData.emotionKeys.Add(newValue); Debug.Log(morphName); } } @@ -72,43 +71,24 @@ public class FaceEmotionKeyTarget : ScriptableObject { if (FaceDrivenKeyTarget == null) return; FaceDrivenKeyTarget.ClearMorph(); + Dictionary morphs = new Dictionary(); foreach (var emotion in FaceEmotionKey) { - if (emotion.mouthTarget != null) + if (emotion.emotionKeys != null) { - foreach (var key in emotion.mouthTarget) + foreach (var key in emotion.emotionKeys) { - key.morph.Weight += key.weight / 100 * emotion.Weight; - } - } - if (emotion.eyeLTarget != null) - { - foreach (var key in emotion.eyeLTarget) - { - key.morph.Weight += key.weight / 100 * emotion.Weight; - } - } - if (emotion.eyeRTarget != null) - { - foreach (var key in emotion.eyeRTarget) - { - key.morph.Weight += key.weight / 100 * emotion.Weight; - } - } - if (emotion.eyebrowLTarget != null) - { - foreach (var key in emotion.eyeRTarget) - { - key.morph.Weight += key.weight / 100 * emotion.Weight; - } - } - if (emotion.eyebrowRTarget != null) - { - foreach (var key in emotion.eyeRTarget) - { - key.morph.Weight += key.weight / 100 * emotion.Weight; + if (morphs.ContainsKey(key.morph)) + { + morphs[key.morph] = key.morph.Weight + key.weight / 100 * emotion.Weight; + } + else + { + morphs.Add(key.morph, key.morph.Weight + key.weight / 100 * emotion.Weight); + } } } + FaceDrivenKeyTarget.ChangeMorphWeights(morphs); } } } diff --git a/Assets/Scripts/umamusume/Gallop/FacialMorph.cs b/Assets/Scripts/umamusume/Gallop/FacialMorph.cs index 5b6e429..d158e53 100644 --- a/Assets/Scripts/umamusume/Gallop/FacialMorph.cs +++ b/Assets/Scripts/umamusume/Gallop/FacialMorph.cs @@ -24,7 +24,6 @@ namespace Gallop set { _weight = value; - target.ChangeMorph(); } } public List trsArray;