Example #1
0
        public ExpressionKey(UniGLTF.Extensions.VRMC_vrm.ExpressionPreset preset, string customName = null)
        {
            Preset = preset;

            if (Preset != UniGLTF.Extensions.VRMC_vrm.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 UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.Custom");
                }

                _id  = $"{UnknownPresetPrefix}{customName}";
                Name = customName;
            }
        }
 void CreateDefaultPreset(UniGLTF.Extensions.VRMC_vrm.ExpressionPreset preset)
 {
     var clip = GetClip(new ExpressionKey(preset));
     if (clip != null) return;
     clip = ScriptableObject.CreateInstance<VRM10Expression>();
     clip.name = preset.ToString();
     clip.ExpressionName = preset.ToString();
     clip.Preset = preset;
     Clips.Add(clip);
 }
Example #3
0
        private static VrmLib.ExpressionPreset ToVrmFormat(this UniGLTF.Extensions.VRMC_vrm.ExpressionPreset preset)
        {
            switch (preset)
            {
            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.custom: return(ExpressionPreset.Custom);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.aa: return(ExpressionPreset.Aa);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.ih: return(ExpressionPreset.Ih);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.ou: return(ExpressionPreset.Ou);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.ee: return(ExpressionPreset.Ee);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.oh: return(ExpressionPreset.Oh);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.blink: return(ExpressionPreset.Blink);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.happy: return(ExpressionPreset.Happy);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.angry: return(ExpressionPreset.Angry);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.sad: return(ExpressionPreset.Sad);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.relaxed: return(ExpressionPreset.Relaxed);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookUp: return(ExpressionPreset.LookUp);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.surprised: return(ExpressionPreset.Surprised);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookDown: return(ExpressionPreset.LookDown);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookLeft: return(ExpressionPreset.LookLeft);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookRight: return(ExpressionPreset.LookRight);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.blinkLeft: return(ExpressionPreset.BlinkLeft);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.blinkRight: return(ExpressionPreset.BlinkRight);

            case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.neutral: return(ExpressionPreset.Neutral);

            default:
                throw new ArgumentOutOfRangeException(nameof(preset), preset, null);
            }
        }
Example #4
0
        IEnumerator RoutineNest(UniGLTF.Extensions.VRMC_vrm.ExpressionPreset preset, float velocity, float wait)
        {
            for (var value = 0.0f; value <= 1.0f; value += velocity)
            {
                VRM.Expression.SetWeight(ExpressionKey.CreateFromPreset(preset), value);
                yield return(null);
            }
            VRM.Expression.SetWeight(ExpressionKey.CreateFromPreset(preset), 1.0f);
            yield return(new WaitForSeconds(wait));

            for (var value = 1.0f; value >= 0; value -= velocity)
            {
                VRM.Expression.SetWeight(ExpressionKey.CreateFromPreset(preset), value);
                yield return(null);
            }
            VRM.Expression.SetWeight(ExpressionKey.CreateFromPreset(preset), 0);
            yield return(new WaitForSeconds(wait * 2));
        }
Example #5
0
 public static ExpressionKey CreateFromPreset(UniGLTF.Extensions.VRMC_vrm.ExpressionPreset preset)
 {
     return(new ExpressionKey(preset));
 }