Skip to content

Commit

Permalink
EmoteChainのUI仮実装
Browse files Browse the repository at this point in the history
  • Loading branch information
pandrabox committed Sep 16, 2024
1 parent d063d67 commit f638666
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 9 deletions.
80 changes: 71 additions & 9 deletions Editor/EmotePrefabEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ namespace com.github.pandrabox.emoteprefab.editor
[CustomEditor(typeof(EmotePrefab))]
public class EmotePrefabEditor : Editor
{
private EmotePrefab _chainToLog;
private EmotePrefab _nowInstance;

void OnEnable()
{
_nowInstance = (EmotePrefab)target;
RenewChain(true);
}

public override void OnInspectorGUI()
{
serializedObject.Update();

var nowInstance = (EmotePrefab)target;


EditorGUILayout.BeginHorizontal();

EditorGUILayout.BeginVertical();

nowInstance.Motion = (AnimationClip)EditorGUILayout.ObjectField("Motion", nowInstance.Motion, typeof(AnimationClip), false);
nowInstance.Name = EditorGUILayout.TextField("Name", nowInstance.Name);
_nowInstance.Motion = (AnimationClip)EditorGUILayout.ObjectField("Motion", _nowInstance.Motion, typeof(AnimationClip), false);
_nowInstance.Name = EditorGUILayout.TextField("Name", _nowInstance.Name);
EditorGUILayout.PropertyField(serializedObject.FindProperty("IsOneShot"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("IsEmote"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("IsAFK"));
Expand Down Expand Up @@ -103,18 +110,73 @@ public override void OnInspectorGUI()

EditorGUILayout.PropertyField(serializedObject.FindProperty("FakeWriteDefaultClip"));


/* UIとしては動作するが機能未実装
EditorGUILayout.PropertyField(serializedObject.FindProperty("ChainTo"));
RenewChain();
GUI.enabled = false;
EditorGUILayout.PropertyField(serializedObject.FindProperty("ChainFrom"));
GUI.enabled = true;
*/





}
serializedObject.ApplyModifiedProperties();


}


// SceneビューのGizmo描画を抑制
[DrawGizmo(GizmoType.NotInSelectionHierarchy | GizmoType.Pickable)]
static void DrawGizmoForMyComponent(EmotePrefab component, GizmoType gizmoType)
private void RenewChain(bool initial = false)
{
// ここで何も描画しない、もしくはカスタムの描画ロジックを設定
if (initial)
{
if(_nowInstance.ChainTo==null)
{
_nowInstance.ChainTo = null; // "null"をnullに変換
}
if (_nowInstance.ChainFrom == null)
{
_nowInstance.ChainFrom = null;
}
_chainToLog = _nowInstance.ChainTo;
return;
}
if (_nowInstance.ChainTo != _chainToLog)
{
bool doChange = true;
WriteWarning("ChangeChain", $@"{_nowInstance?.name} : {_chainToLog?.name} >> {_nowInstance.ChainTo?.name}");
if (_nowInstance.ChainTo?.ChainFrom != null)
{
doChange = EditorUtility.DisplayDialog(
"Emote Chain", // ダイアログタイトル
$@"{_nowInstance.ChainTo.Name}は既に{_nowInstance.ChainTo.ChainFrom.Name}からチェインされています。実行するとそのチェインが解除されます。実行しますか?",
"Yes", // Yesボタンのラベル
"No" // Noボタンのラベル
);
if (doChange)
{
_nowInstance.ChainTo.ChainFrom.ChainTo = null;
_nowInstance.ChainTo.ChainFrom= null;
}
}
if (doChange)
{
if (_nowInstance.ChainTo != null)
{
_nowInstance.ChainTo.ChainFrom = _nowInstance;
}
RenewChain(true);
}
else
{
_nowInstance.ChainTo = _chainToLog;
}
}
}

}
}
5 changes: 5 additions & 0 deletions Runtime/EmotePrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using UnityEngine;
using System.Collections.Generic;
using VRC.SDK3.Dynamics.PhysBone.Components;
using System;

namespace com.github.pandrabox.emoteprefab.runtime
{
Expand All @@ -14,6 +15,7 @@ namespace com.github.pandrabox.emoteprefab.runtime
/// </summary>
[DisallowMultipleComponent]
[AddComponentMenu("Pan/EmotePrefab")]
[Serializable]
public class EmotePrefab : MonoBehaviour, VRC.SDKBase.IEditorOnly
{
public bool IsOneShot;
Expand All @@ -30,6 +32,9 @@ public class EmotePrefab : MonoBehaviour, VRC.SDKBase.IEditorOnly
public bool UseCustomExitTransition;
public TransitionInfo ExitTransitionInfo;
public AnimationClip FakeWriteDefaultClip;
public EmotePrefab ChainTo;
public EmotePrefab ChainFrom;

[SerializeField]
private AnimationClip _motion;
[SerializeField]
Expand Down

0 comments on commit f638666

Please sign in to comment.