From 8e4c96dcaf787e0da884f5ef64d5e3b7c9ef5c1d Mon Sep 17 00:00:00 2001 From: CroakFang <1605296300@qq.com> Date: Tue, 1 Nov 2022 23:43:50 +0800 Subject: [PATCH] optimize performance --- .../umamusume/Gallop/FaceDrivenKeyTarget.cs | 11 +---------- .../umamusume/Gallop/FaceEmotionKeyTarget.cs | 15 +++++---------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs index ac7f586..5b13487 100644 --- a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs +++ b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs @@ -154,7 +154,6 @@ namespace Gallop { morph._weight = 0; } - ChangeMorph(); } private void ProcessMorph(FacialMorph morph) @@ -206,15 +205,7 @@ namespace Gallop 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 01a823b..40da659 100644 --- a/Assets/Scripts/umamusume/Gallop/FaceEmotionKeyTarget.cs +++ b/Assets/Scripts/umamusume/Gallop/FaceEmotionKeyTarget.cs @@ -71,25 +71,20 @@ public class FaceEmotionKeyTarget : ScriptableObject { if (FaceDrivenKeyTarget == null) return; FaceDrivenKeyTarget.ClearMorph(); - Dictionary morphs = new Dictionary(); + foreach (var emotion in FaceEmotionKey) { if (emotion.emotionKeys != null) { foreach (var key in emotion.emotionKeys) { - 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); - } + key.morph.Weight += key.weight / 100 * emotion.Weight; } } - FaceDrivenKeyTarget.ChangeMorphWeights(morphs); + } + + FaceDrivenKeyTarget.ChangeMorph(); } }