Beispiel #1
0
        public ExpressionKey(ExpressionPreset preset, string customName = null)
        {
            Preset = preset;

            if (Preset != ExpressionPreset.custom)
            {
                if (PresetNameDictionary.ContainsKey((Preset)))
                {
                    _id = Name = PresetNameDictionary[Preset];
                }
                else
                {
                    PresetNameDictionary.Add(Preset, Preset.ToString());
                    _id = Name = PresetNameDictionary[Preset];
                }
            }
            else
            {
                if (string.IsNullOrEmpty(customName))
                {
                    throw new ArgumentException("name is required for ExpressionPreset.Custom");
                }

                _id  = $"{UnknownPresetPrefix}{customName}";
                Name = customName;
            }
        }
Beispiel #2
0
 float ExpressionPresetSlider(VRM10ObjectExpression expression, ExpressionPreset preset, float value)
 {
     EditorGUILayout.BeginHorizontal(Style);
     EditorGUILayout.LabelField(preset.ToString());
     value = EditorGUILayout.Slider(value, 0, 1.0f);
     EditorGUILayout.EndHorizontal();
     return(value);
 }
Beispiel #3
0
        static VRM10Expression CreateAndSaveExpression(ExpressionPreset preset, string dir)
        {
            var clip = ScriptableObject.CreateInstance <VRM10Expression>();

            clip.name = preset.ToString();
            var path      = System.IO.Path.Combine(dir, $"{preset}.asset");
            var unityPath = UnityPath.FromFullpath(path);

            unityPath.CreateAsset(clip);
            var loaded = unityPath.LoadAsset <VRM10Expression>();

            return(loaded);
        }
Beispiel #4
0
        IEnumerator RoutineNest(ExpressionPreset preset, float velocity, float wait)
        {
            for (var value = 0.0f; value <= 1.0f; value += velocity)
            {
                Controller.Vrm.Expression.SetWeight(ExpressionKey.CreateFromPreset(preset), value);
                yield return(null);
            }
            Controller.Vrm.Expression.SetWeight(ExpressionKey.CreateFromPreset(preset), 1.0f);
            yield return(new WaitForSeconds(wait));

            for (var value = 1.0f; value >= 0; value -= velocity)
            {
                Controller.Vrm.Expression.SetWeight(ExpressionKey.CreateFromPreset(preset), value);
                yield return(null);
            }
            Controller.Vrm.Expression.SetWeight(ExpressionKey.CreateFromPreset(preset), 0);
            yield return(new WaitForSeconds(wait * 2));
        }
Beispiel #5
0
 public static ExpressionKey CreateFromPreset(ExpressionPreset preset)
 {
     return(new ExpressionKey(preset));
 }
Beispiel #6
0
        private static BlendShapeClip GetExpression(BlendShapeAvatar blendShapeAvatar, ExpressionPreset preset)
        {
            switch (preset)
            {
            case ExpressionPreset.Aa:
                return(blendShapeAvatar.GetClip(BlendShapePreset.A));

            case ExpressionPreset.Ih:
                return(blendShapeAvatar.GetClip(BlendShapePreset.I));

            case ExpressionPreset.Ou:
                return(blendShapeAvatar.GetClip(BlendShapePreset.U));

            case ExpressionPreset.Ee:
                return(blendShapeAvatar.GetClip(BlendShapePreset.E));

            case ExpressionPreset.Oh:
                return(blendShapeAvatar.GetClip(BlendShapePreset.O));

            case ExpressionPreset.Happy:
                return(blendShapeAvatar.GetClip(BlendShapePreset.Joy));

            case ExpressionPreset.Angry:
                return(blendShapeAvatar.GetClip(BlendShapePreset.Angry));

            case ExpressionPreset.Sad:
                return(blendShapeAvatar.GetClip(BlendShapePreset.Sorrow));

            case ExpressionPreset.Relaxed:
                return(blendShapeAvatar.GetClip(BlendShapePreset.Fun));

            case ExpressionPreset.Surprised:
                var blendShapeClip = ScriptableObject.CreateInstance <BlendShapeClip>();
                blendShapeClip.BlendShapeName = "Surprised";
                blendShapeAvatar.Clips.Add(blendShapeClip);
                return(blendShapeClip);

            case ExpressionPreset.Blink:
                return(blendShapeAvatar.GetClip(BlendShapePreset.Blink));

            case ExpressionPreset.BlinkLeft:
                return(blendShapeAvatar.GetClip(BlendShapePreset.Blink_L));

            case ExpressionPreset.BlinkRight:
                return(blendShapeAvatar.GetClip(BlendShapePreset.Blink_R));
            }
            throw new ArgumentOutOfRangeException();
        }
Beispiel #7
0
 public Expression(ExpressionPreset preset, string name, bool isBinary)
 {
     Preset   = preset;
     Name     = name;
     IsBinary = isBinary;
 }