示例#1
0
        public void SelectGUI()
        {
            if (m_avatar != null && m_avatar.Clips != null)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Select BlendShapeClip", EditorStyles.boldLabel);
                var array = m_avatar.Clips
                            .Select(x => x != null
                        ? BlendShapeKey.CreateFromClip(x).ToString()
                        : "null"
                                    ).ToArray();
                SelectedIndex = GUILayout.SelectionGrid(SelectedIndex, array, 4);
            }

            if (GUILayout.Button("Add BlendShapeClip"))
            {
                var dir  = Path.GetDirectoryName(AssetDatabase.GetAssetPath(m_avatar));
                var path = EditorUtility.SaveFilePanel(
                    "Create BlendShapeClip",
                    dir,
                    string.Format("BlendShapeClip#{0}.asset", m_avatar.Clips.Count),
                    "asset");
                if (!string.IsNullOrEmpty(path))
                {
                    var clip = BlendShapeAvatar.CreateBlendShapeClip(path.ToUnityRelativePath());
                    //clip.Prefab = AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GetAssetPath(target));

                    m_avatar.Clips.Add(clip);
                }
            }
        }
示例#2
0
        void Restore()
        {
            var assetPath = UnityPath.FromAsset(this);

            if (assetPath.IsNull)
            {
                return;
            }


            foreach (var x in assetPath.Parent.ChildFiles)
            {
                var clip = UnityEditor.AssetDatabase.LoadAssetAtPath <BlendShapeClip>(x.Value);
                if (clip == null)
                {
                    continue;
                }

                if (!Clips.Contains(clip))
                {
                    Clips.Add(clip);
                }

                Debug.LogFormat("{0}", clip.name);
            }
            Clips = Clips.OrderBy(x => BlendShapeKey.CreateFrom(x)).ToList();
        }
示例#3
0
 /// <summary>
 /// SetValue
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public void SetValue(BlendShapeKey key, float value)
 {
     if (BlendShapeKeyWeights.ContainsKey(key))
     {
         BlendShapeKeyWeights[key] = value;
     }
 }
示例#4
0
 public BlendShapeClip GetClip(BlendShapeKey key)
 {
     if (Clips == null)
     {
         return(null);
     }
     return(Clips.FirstOrDefault(x => key.Match(x)));
 }
示例#5
0
        public static void SetValue(this VRMBlendShapeProxy proxy, String key, float value)
        {
            var blendShapeKey = new BlendShapeKey(key);

            if (proxy.BlendShapeKeyWeights.ContainsKey(blendShapeKey))
            {
                proxy.BlendShapeKeyWeights[blendShapeKey] = value;
            }
        }
示例#6
0
        public void DuplicateWarn()
        {
            var key = BlendShapeKey.CreateFromClip(Selected);

            if (m_avatar.Clips.Where(x => key.Match(x)).Count() > 1)
            {
                EditorGUILayout.HelpBox("duplicate clip: " + key, MessageType.Error);
            }
        }
示例#7
0
        public BlendShapeMerger(IEnumerable <BlendShapeClip> clips, Transform root)
        {
            m_clipMap = clips.ToDictionary(x => BlendShapeKey.CreateFrom(x), x => x);

            m_valueMap = new Dictionary <BlendShapeKey, float>();

            m_blendShapeBindingMerger    = new BlendShapeBindingMerger(m_clipMap, root);
            m_materialValueBindingMerger = new MaterialValueBindingMerger(m_clipMap, root);
        }
示例#8
0
        public float GetValue(BlendShapeKey key)
        {
            float value;

            if (!m_valueMap.TryGetValue(key, out value))
            {
                return(0);
            }
            return(value);
        }
示例#9
0
 public BlendShapeClip GetClip(BlendShapeKey key)
 {
     if (m_clipMap.ContainsKey(key))
     {
         return(m_clipMap[key]);
     }
     else
     {
         return(null);
     }
 }
示例#10
0
 public void SetValue(BlendShapeKey key, float value, bool immediately)
 {
     if (immediately)
     {
         ImmediatelySetValue(key, value);
     }
     else
     {
         AccumulateValue(key, value);
     }
 }
示例#11
0
 /// <summary>
 /// Get a blendShape value
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public float GetValue(BlendShapeKey key)
 {
     if (BlendShapeKeyWeights.ContainsKey(key))
     {
         return(BlendShapeKeyWeights[key]);
     }
     else
     {
         return(0.0f);
     }
 }
        public override string GetInfoString()
        {
            var key = BlendShapeKey.CreateFromClip(CurrentBlendShapeClip());

            if (key.Preset != VrmLib.BlendShapePreset.Custom)
            {
                return(string.Format("Preset: {0}", key.Preset));
            }
            else
            {
                return(string.Format("Custom: {0}", key.Name));
            }
        }
示例#13
0
        public static float GetValue(this VRMBlendShapeProxy proxy, String key)
        {
            var blendShapeKey = new BlendShapeKey(key);

            if (proxy.BlendShapeKeyWeights.ContainsKey(blendShapeKey))
            {
                return(proxy.BlendShapeKeyWeights[blendShapeKey]);
            }
            else
            {
                return(0.0f);
            }
        }
示例#14
0
        /// <summary>
        /// 即時に反映しない。後にApplyによって反映する
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void AccumulateValue(BlendShapeKey key, float value)
        {
            m_valueMap[key] = value;

            BlendShapeClip clip;

            if (!m_clipMap.TryGetValue(key, out clip))
            {
                return;
            }

            if (clip.IsBinary)
            {
                value = Mathf.Round(value);
            }

            m_blendShapeBindingMerger.AccumulateValue(clip, value);
            m_materialValueBindingMerger.AccumulateValue(clip, value);
        }
示例#15
0
        public void SetClip(BlendShapeKey key, BlendShapeClip clip)
        {
            int index = -1;

            try
            {
                index = Clips.FindIndex(x => key.Match(x));
            }
            catch (Exception)
            {
            }
            if (index == -1)
            {
                Clips.Add(clip);
            }
            else
            {
                Clips[index] = clip;
            }
        }
 public override string GetInfoString()
 {
     return(BlendShapeKey.CreateFromClip((BlendShapeClip)target).ToString());
 }
示例#17
0
 public BlendShapeSlider(Dictionary <BlendShapeKey, float> blendShapeKeys, BlendShapeKey key)
 {
     m_blendShapeKeys = blendShapeKeys;
     m_key            = key;
 }
示例#18
0
 void OnEnable()
 {
     m_target = (VRMBlendShapeProxy)target;
     if (m_target.BlendShapeAvatar != null && m_target.BlendShapeAvatar.Clips != null)
     {
         m_blendShapeKeyWeights = m_target.BlendShapeAvatar.Clips.ToDictionary(x => BlendShapeKey.CreateFromClip(x), x => 0.0f);
         m_sliders = m_target.BlendShapeAvatar.Clips
                     .Where(x => x != null)
                     .Select(x => new BlendShapeSlider(m_blendShapeKeyWeights, BlendShapeKey.CreateFromClip(x)))
                     .ToList()
         ;
     }
 }