Skip to content

Commit

Permalink
ChainMotion2
Browse files Browse the repository at this point in the history
  • Loading branch information
pandrabox committed Sep 17, 2024
1 parent 78de673 commit 6280fe0
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Editor/EmoteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static TransitionInfo StartTransitionInfo(int n)
/// </summary>
public static TransitionInfo RegularExitTransitionInfo(int n)
{
return EmotePrefab(n).UseCustomExitTransition ? EmotePrefab(n).ExitTransitionInfo : EmoteProperty(n).RegularExitTransitionInfo;
return EmotePrefab(n).Motions[0].UseCustomExitTransition ? EmotePrefab(n).Motions[0].ExitTransitionInfo : EmoteProperty(n).RegularExitTransitionInfo;
}

/// <summary>
Expand Down
65 changes: 53 additions & 12 deletions Editor/EmotePrefabEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public override void OnInspectorGUI()
serializedObject.Update();

var nowInstance = (EmotePrefab)target;

var spMotions = serializedObject.FindProperty("Motions");
var unitMotion = spMotions.GetArrayElementAtIndex(0);

EditorGUILayout.BeginHorizontal();

Expand Down Expand Up @@ -94,27 +95,67 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(serializedObject.FindProperty("StartTransitionInfo"));
}

var spUseCustomExitTransition = serializedObject.FindProperty("UseCustomExitTransition");
EditorGUILayout.PropertyField(spUseCustomExitTransition);
if (spUseCustomExitTransition.boolValue)
EditorGUILayout.PropertyField(unitMotion.FindPropertyRelative("UseCustomExitTransition"));
if (nowInstance.Motions[0].UseCustomExitTransition)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("ExitTransitionInfo"));
EditorGUILayout.PropertyField(unitMotion.FindPropertyRelative("ExitTransitionInfo"));
}

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


GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField("ChainMotion");
if (GUILayout.Button("+"))
{
nowInstance.Motions.Add(new UnitMotion());
}
if (GUILayout.Button("-"))
{
if (nowInstance.Motions.Count > 1)
{
nowInstance.Motions.RemoveAt(nowInstance.Motions.Count - 1);
}
}
}
for(int i = 1;i<nowInstance.Motions.Count;i++)
{
if (i >= spMotions.arraySize)
{
continue;
}
unitMotion = spMotions.GetArrayElementAtIndex(i);
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField("", GUILayout.Width(20));
using (new EditorGUILayout.VerticalScope())
{
EditorGUILayout.PropertyField(unitMotion.FindPropertyRelative("Motion"));
EditorGUILayout.PropertyField(unitMotion.FindPropertyRelative("UseCustomExitTransition"));
}
EditorGUILayout.LabelField("", GUILayout.Width(20));

if (nowInstance.Motions[i].UseCustomExitTransition)
{
EditorGUILayout.PropertyField(unitMotion.FindPropertyRelative("ExitTransitionInfo"));
}

}
}


}
serializedObject.ApplyModifiedProperties();


}


// SceneビューのGizmo描画を抑制
[DrawGizmo(GizmoType.NotInSelectionHierarchy | GizmoType.Pickable)]
static void DrawGizmoForMyComponent(EmotePrefab component, GizmoType gizmoType)
{
// ここで何も描画しない、もしくはカスタムの描画ロジックを設定




serializedObject.ApplyModifiedProperties();
}
}
}
35 changes: 25 additions & 10 deletions Runtime/EmotePrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ public class EmotePrefab : MonoBehaviour, VRC.SDKBase.IEditorOnly
public List<VRCPhysBone> ShrinkPhysBones;
public bool UseCustomStartTransition;
public TransitionInfo StartTransitionInfo;
public bool UseCustomExitTransition;
public TransitionInfo ExitTransitionInfo;
// public TransitionInfo ExitTransitionInfo;
public AnimationClip FakeWriteDefaultClip;
[SerializeField]
private AnimationClip _motion;
public List<UnitMotion> Motions;
// public int Quantitys=1;
// [SerializeField]
// private AnimationClip _motion;
[SerializeField]
private string _name;

Expand All @@ -40,17 +41,31 @@ public class EmotePrefab : MonoBehaviour, VRC.SDKBase.IEditorOnly
/// </summary>
public AnimationClip Motion
{
get => _motion;
get
{
if (Motions.Count > 0)
{
return Motions[0].Motion;
}
else
{
return null;
}
}
set
{
if (_motion != value)
if (Motions.Count == 0)
{
Motions.Add(new UnitMotion());
}
if (Motions[0].Motion != value)
{
_motion = value;
Motions[0].Motion = value;

if (_motion != null)
if (Motions[0].Motion != null)
{
Name = _motion.name.Replace("proxy_stand_", string.Empty).Replace("proxy_", string.Empty);
IsOneShot = !_motion.isLooping;
Name = Motions[0].Motion.name.Replace("proxy_stand_", string.Empty).Replace("proxy_", string.Empty);
IsOneShot = !Motions[0].Motion.isLooping;
IsEmote = true;
}
else
Expand Down
21 changes: 21 additions & 0 deletions Runtime/UnitMotion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// <copyright file="TransitionInfo.cs"></copyright>

#if UNITY_EDITOR

#pragma warning disable SA1401 // Fields should be private

using System;
using UnityEngine;

namespace com.github.pandrabox.emoteprefab.runtime
{
[Serializable]
public class UnitMotion
{
public AnimationClip Motion;
public bool UseCustomExitTransition;
public TransitionInfo ExitTransitionInfo;
}
}

#endif
11 changes: 11 additions & 0 deletions Runtime/UnitMotion.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6280fe0

Please sign in to comment.