mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-02 16:03:10 -05:00
remove unused
This commit is contained in:
parent
7067e52205
commit
89073efdba
|
|
@ -1,148 +0,0 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
/// <summary>
|
||||
/// ExpressionAvatarEditorの部品
|
||||
/// </summary>
|
||||
class ExpressionClipSelector
|
||||
{
|
||||
VRM10ObjectExpression m_avatar;
|
||||
|
||||
int m_mode;
|
||||
static readonly string[] MODES = new string[]{
|
||||
"Button",
|
||||
"List"
|
||||
};
|
||||
|
||||
ReorderableExpressionList m_clipList;
|
||||
|
||||
public VRM10Expression GetSelected()
|
||||
{
|
||||
var clips = m_avatar.Clips.ToArray();
|
||||
if (m_avatar == null || clips == null || clips.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (m_selectedIndex < 0 || m_selectedIndex >= clips.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return clips[m_selectedIndex];
|
||||
}
|
||||
|
||||
public event Action<VRM10Expression> Selected;
|
||||
void RaiseSelected(int index)
|
||||
{
|
||||
m_clipList.Select(index);
|
||||
var clip = GetSelected();
|
||||
var handle = Selected;
|
||||
if (handle == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
handle(clip);
|
||||
}
|
||||
|
||||
int m_selectedIndex;
|
||||
int SelectedIndex
|
||||
{
|
||||
get { return m_selectedIndex; }
|
||||
set
|
||||
{
|
||||
// これで更新するべし
|
||||
if (m_selectedIndex == value) return;
|
||||
m_selectedIndex = value;
|
||||
RaiseSelected(value);
|
||||
}
|
||||
}
|
||||
|
||||
public ExpressionClipSelector(VRM10ObjectExpression avatar, string dir, SerializedObject serializedObject)
|
||||
{
|
||||
avatar.RemoveNullClip();
|
||||
|
||||
m_avatar = avatar;
|
||||
|
||||
var prop = serializedObject.FindProperty("Clips");
|
||||
m_clipList = new ReorderableExpressionList(serializedObject, prop, dir);
|
||||
|
||||
m_clipList.Selected += (selected) =>
|
||||
{
|
||||
var clips = avatar.Clips.ToArray();
|
||||
SelectedIndex = Array.IndexOf(clips, selected);
|
||||
};
|
||||
}
|
||||
|
||||
public void DrawGUI(string dir)
|
||||
{
|
||||
var backup = GUI.enabled;
|
||||
try
|
||||
{
|
||||
GUI.enabled = true;
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Select Expression", EditorStyles.boldLabel);
|
||||
|
||||
m_mode = GUILayout.Toolbar(m_mode, MODES);
|
||||
switch (m_mode)
|
||||
{
|
||||
case 0:
|
||||
SelectGUI(dir);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
m_clipList.GUI();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
GUI.enabled = backup;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6d4d5da207577eb48ad767ff59bcf8b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
class ReorderableExpressionList
|
||||
{
|
||||
ReorderableList m_list;
|
||||
|
||||
public event Action<VRM10Expression> Selected;
|
||||
void RaiseSelected(VRM10Expression selected)
|
||||
{
|
||||
var handler = Selected;
|
||||
if (handler == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
handler(selected);
|
||||
}
|
||||
|
||||
public void Select(int index)
|
||||
{
|
||||
m_list.index = index;
|
||||
}
|
||||
|
||||
public ReorderableExpressionList(SerializedObject serializedObject, SerializedProperty prop, string dir)
|
||||
{
|
||||
m_list = new ReorderableList(serializedObject, prop);
|
||||
|
||||
m_list.drawHeaderCallback = (rect) =>
|
||||
EditorGUI.LabelField(rect, "Expressions");
|
||||
|
||||
m_list.drawElementCallback = (rect, index, isActive, isFocused) =>
|
||||
{
|
||||
var element = prop.GetArrayElementAtIndex(index);
|
||||
rect.height -= 4;
|
||||
rect.y += 2;
|
||||
EditorGUI.PropertyField(rect, element);
|
||||
};
|
||||
|
||||
m_list.onAddCallback += (list) =>
|
||||
{
|
||||
// Add slot
|
||||
prop.arraySize++;
|
||||
// select last item
|
||||
list.index = prop.arraySize - 1;
|
||||
// get last item
|
||||
var element = prop.GetArrayElementAtIndex(list.index);
|
||||
element.objectReferenceValue = null;
|
||||
|
||||
// var dir = Path.GetDirectoryName(AssetDatabase.GetAssetPath(target));
|
||||
var path = EditorUtility.SaveFilePanel(
|
||||
"Create Expression",
|
||||
dir,
|
||||
string.Format("Expression#{0}.asset", list.count),
|
||||
"asset");
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
var clip = ExpressionEditorBase.CreateExpression(path.ToUnityRelativePath());
|
||||
//clip.Prefab = AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GetAssetPath(target));
|
||||
|
||||
element.objectReferenceValue = clip;
|
||||
}
|
||||
};
|
||||
|
||||
m_list.onSelectCallback += (list) =>
|
||||
{
|
||||
var a = list.serializedProperty;
|
||||
var selected = a.GetArrayElementAtIndex(list.index);
|
||||
RaiseSelected((VRM10Expression)selected.objectReferenceValue);
|
||||
};
|
||||
|
||||
//m_clipList.onCanRemoveCallback += list => true;
|
||||
}
|
||||
|
||||
public void GUI()
|
||||
{
|
||||
m_list.DoLayoutList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a5a5707cea4226d40af879c4c9778002
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue
Block a user