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); } } }
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(); }
/// <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; } }
public BlendShapeClip GetClip(BlendShapeKey key) { if (Clips == null) { return(null); } return(Clips.FirstOrDefault(x => key.Match(x))); }
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; } }
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); } }
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); }
public float GetValue(BlendShapeKey key) { float value; if (!m_valueMap.TryGetValue(key, out value)) { return(0); } return(value); }
public BlendShapeClip GetClip(BlendShapeKey key) { if (m_clipMap.ContainsKey(key)) { return(m_clipMap[key]); } else { return(null); } }
public void SetValue(BlendShapeKey key, float value, bool immediately) { if (immediately) { ImmediatelySetValue(key, value); } else { AccumulateValue(key, value); } }
/// <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)); } }
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); } }
/// <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); }
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()); }
public BlendShapeSlider(Dictionary <BlendShapeKey, float> blendShapeKeys, BlendShapeKey key) { m_blendShapeKeys = blendShapeKeys; m_key = key; }
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() ; } }