void SelectGUI(string dir) { if (m_avatar != null && m_avatar.Clips != null) { var array = m_avatar.Clips .Select(x => x != null ? ExpressionKey.CreateFromClip(x).ToString() : "null" ).ToArray(); SelectedIndex = GUILayout.SelectionGrid(SelectedIndex, array, 4); } // if (GUILayout.Button("Add Expression")) // { // var path = EditorUtility.SaveFilePanel( // "Create Expression", // dir, // string.Format("Expression#{0}.asset", m_avatar.Clips.Count), // "asset"); // if (!string.IsNullOrEmpty(path)) // { // var clip = ExpressionEditorBase.CreateExpression(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 <VRM10Expression>(x.Value); if (clip == null) { continue; } if (!Clips.Contains(clip)) { Clips.Add(clip); } Debug.LogFormat("{0}", clip.name); } Clips = Clips.OrderBy(x => ExpressionKey.CreateFromClip(x)).ToList(); }
void SelectGUI() { if (m_avatar != null && m_avatar.Clips != null) { var array = m_avatar.Clips .Select(x => x != null ? ExpressionKey.CreateFromClip(x).ToString() : "null" ).ToArray(); SelectedIndex = GUILayout.SelectionGrid(SelectedIndex, array, 4); } if (GUILayout.Button("Add Expression")) { var dir = Path.GetDirectoryName(AssetDatabase.GetAssetPath(m_avatar)); var path = EditorUtility.SaveFilePanel( "Create Expression", dir, string.Format("Expression#{0}.asset", m_avatar.Clips.Count), "asset"); if (!string.IsNullOrEmpty(path)) { var clip = VRM10ExpressionAvatar.CreateExpression(path.ToUnityRelativePath()); //clip.Prefab = AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GetAssetPath(target)); m_avatar.Clips.Add(clip); } } }
public ExpressionMerger(IEnumerable <VRM10Expression> clips, Transform root) { m_clipMap = clips.ToDictionary(x => ExpressionKey.CreateFromClip(x), x => x); m_valueMap = new Dictionary <ExpressionKey, float>(); m_morphTargetBindingMerger = new MorphTargetBindingMerger(m_clipMap, root); m_materialValueBindingMerger = new MaterialValueBindingMerger(m_clipMap, root); }
public void DuplicateWarn() { var key = ExpressionKey.CreateFromClip(GetSelected()); if (m_avatar.Clips.Where(x => key.Match(x)).Count() > 1) { EditorGUILayout.HelpBox("duplicate clip: " + key, MessageType.Error); } }
public VRM10ControllerEditorExpression(VRM10Controller target) { m_target = target; m_expressionKeyWeights = m_target.Vrm.Expression.Clips.ToDictionary(x => ExpressionKey.CreateFromClip(x), x => 0.0f); m_sliders = m_target.Vrm.Expression.Clips .Where(x => x != null) .Select(x => new ExpressionSlider(m_expressionKeyWeights, ExpressionKey.CreateFromClip(x))) .ToList() ; }
public override string GetInfoString() { var expression = CurrentExpression(); if (expression == null) { return("no expression"); } var key = ExpressionKey.CreateFromClip(expression); if (key.Preset != VrmLib.ExpressionPreset.Custom) { return(string.Format("Preset: {0}", key.Preset)); } else { return(string.Format("Custom: {0}", key.Name)); } }
void OnEnable() { m_target = (VRM10Controller)target; m_expressionKeyWeights = m_target.Expression.Clips.ToDictionary(x => ExpressionKey.CreateFromClip(x), x => 0.0f); m_sliders = m_target.Expression.Clips .Where(x => x != null) .Select(x => new ExpressionSlider(m_expressionKeyWeights, ExpressionKey.CreateFromClip(x))) .ToList() ; if (m_target?.Meta.Meta != null) { m_metaEditor = Editor.CreateEditor(m_target.Meta.Meta); } m_controller = PropGui.FromObject(serializedObject, nameof(m_target.Controller)); m_meta = PropGui.FromObject(serializedObject, nameof(m_target.Meta)); m_expression = PropGui.FromObject(serializedObject, nameof(m_target.Expression)); m_lookAt = PropGui.FromObject(serializedObject, nameof(m_target.LookAt)); m_firstPerson = PropGui.FromObject(serializedObject, nameof(m_target.FirstPerson)); }
/// <summary> /// initilaize /// </summary> /// <param name="avatar"></param> public void OnStart(VRM10ExpressionAvatar avatar) { m_clipMap = avatar.Clips.ToDictionary(x => ExpressionKey.CreateFromClip(x), x => x); expressionKeyWeights = m_clipMap.Keys.ToDictionary(x => x, x => 0.0f); }
void OnEnable() { m_target = (VRM10Controller)target; if (m_target.Expression.ExpressionAvatar != null && m_target.Expression.ExpressionAvatar.Clips != null) { m_expressionKeyWeights = m_target.Expression.ExpressionAvatar.Clips.ToDictionary(x => ExpressionKey.CreateFromClip(x), x => 0.0f); m_sliders = m_target.Expression.ExpressionAvatar.Clips .Where(x => x != null) .Select(x => new ExpressionSlider(m_expressionKeyWeights, ExpressionKey.CreateFromClip(x))) .ToList() ; } if (m_target.Meta) { m_metaEditor = Editor.CreateEditor(m_target.Meta); } m_controller = serializedObject.FindProperty(nameof(m_target.Controller)); m_expression = serializedObject.FindProperty(nameof(m_target.Expression)); m_lookAt = serializedObject.FindProperty(nameof(m_target.LookAt)); m_firstPerson = serializedObject.FindProperty(nameof(m_target.FirstPerson)); m_asset = serializedObject.FindProperty(nameof(m_target.ModelAsset)); }