mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-12 05:48:47 -05:00
RotateParticleRuntimeProvider
This commit is contained in:
@@ -6,9 +6,10 @@ using UniVRM10;
|
||||
|
||||
namespace RotateParticle.Components
|
||||
{
|
||||
public static class Converter
|
||||
[CustomEditor(typeof(RotateParticleRuntimeProvider))]
|
||||
public class RotateParticleRuntimeProviderEditor : Editor
|
||||
{
|
||||
const string FROM_VRM10_MENU = "GameObject/CreateRotateParticleFromVrm10";
|
||||
const string FROM_VRM10_MENU = "Replace VRM10 Springs to RotateParticle Warps";
|
||||
|
||||
[MenuItem(FROM_VRM10_MENU, true)]
|
||||
public static bool IsFromVrm10()
|
||||
@@ -21,20 +22,8 @@ namespace RotateParticle.Components
|
||||
return go.GetComponent<Vrm10Instance>() != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// instance.SpringBone.Springs を rotate particle で置き換える。
|
||||
/// UNDO 可能。
|
||||
/// </summary>
|
||||
[MenuItem(FROM_VRM10_MENU, false)]
|
||||
public static void FromVrm10()
|
||||
static void FromVrm10(Vrm10Instance instance)
|
||||
{
|
||||
var go = Selection.activeGameObject;
|
||||
var instance = go.GetComponent<Vrm10Instance>();
|
||||
|
||||
Undo.IncrementCurrentGroup();
|
||||
Undo.SetCurrentGroupName(FROM_VRM10_MENU);
|
||||
var undo = Undo.GetCurrentGroup();
|
||||
|
||||
Undo.RegisterCompleteObjectUndo(instance, "RegisterCompleteObjectUndo");
|
||||
foreach (var spring in instance.SpringBone.Springs)
|
||||
{
|
||||
@@ -77,9 +66,36 @@ namespace RotateParticle.Components
|
||||
}
|
||||
instance.SpringBone.Springs.Clear();
|
||||
|
||||
Undo.RegisterFullObjectHierarchyUndo(go, "RegisterFullObjectHierarchyUndo");
|
||||
Undo.RegisterFullObjectHierarchyUndo(instance.gameObject, "RegisterFullObjectHierarchyUndo");
|
||||
|
||||
Undo.CollapseUndoOperations(undo);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var provider = target as RotateParticleRuntimeProvider;
|
||||
if (provider == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var instance = provider.GetComponent<Vrm10Instance>();
|
||||
using (new EditorGUI.DisabledScope(instance == null))
|
||||
{
|
||||
if (GUILayout.Button("Replace VRM10 Springs to RotateParticle Warps"))
|
||||
{
|
||||
Undo.IncrementCurrentGroup();
|
||||
Undo.SetCurrentGroupName(FROM_VRM10_MENU);
|
||||
var undo = Undo.GetCurrentGroup();
|
||||
|
||||
FromVrm10(instance);
|
||||
|
||||
Undo.RegisterCompleteObjectUndo(provider, "RegisterCompleteObjectUndo");
|
||||
provider.Reset();
|
||||
|
||||
Undo.CollapseUndoOperations(undo);
|
||||
}
|
||||
}
|
||||
|
||||
base.OnInspectorGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ using UnityEngine;
|
||||
|
||||
namespace RotateParticle.Components
|
||||
{
|
||||
[AddComponentMenu("RotateParticle/Cloth")]
|
||||
[AddComponentMenu("RotateParticle/RectCloth")]
|
||||
[DisallowMultipleComponent]
|
||||
public class Cloth : MonoBehaviour
|
||||
public class RectCloth : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public bool Loop = false;
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UniVRM10;
|
||||
|
||||
namespace RotateParticle.Components
|
||||
{
|
||||
[AddComponentMenu("RotateParticle/RotateParticleRuntimeProvider")]
|
||||
[DisallowMultipleComponent]
|
||||
public class RotateParticleRuntimeProvider : MonoBehaviour, IVrm10SpringBoneRuntimeProvider
|
||||
{
|
||||
[SerializeField]
|
||||
public List<Warp> Warps = new();
|
||||
|
||||
[SerializeField]
|
||||
public List<RectCloth> Cloths = new();
|
||||
|
||||
public IVrm10SpringBoneRuntime CreateSpringBoneRuntime()
|
||||
{
|
||||
return new RotateParticleSpringboneRuntime();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Warps = GetComponentsInChildren<Warp>().ToList();
|
||||
Cloths = GetComponentsInChildren<RectCloth>().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,5 +63,10 @@ namespace RotateParticle.Components
|
||||
// TODO: 枝分かれを削除
|
||||
// Debug.Log("Warp.OnValidate");
|
||||
}
|
||||
|
||||
internal List<Warp> ToList()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UniVRM10;
|
||||
|
||||
namespace RotateParticle
|
||||
{
|
||||
public class RotateParticleSpringboneRuntimeProvider : MonoBehaviour, IVrm10SpringBoneRuntimeProvider
|
||||
{
|
||||
public IVrm10SpringBoneRuntime CreateSpringBoneRuntime()
|
||||
{
|
||||
return new RotateParticleSpringboneRuntime();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user