Skip to content

Instantly share code, notes, and snippets.

@autch
Created November 27, 2023 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save autch/e09b02dac18f78f88499176d37f6545d to your computer and use it in GitHub Desktop.
Save autch/e09b02dac18f78f88499176d37f6545d to your computer and use it in GitHub Desktop.
UniVRM-1.x で Play 中に SpringBone パラメータの変更を反映させる
using UnityEngine;
using UniVRM10;
public class RefreshSBParams : MonoBehaviour
{
public GameObject target;
public bool updateEveryFrame;
private Vrm10Instance inst;
// Start is called before the first frame update
void Start()
{
if (target == null)
{
target = gameObject;
}
inst = target.GetComponent<Vrm10Instance>();
}
// Update is called once per frame
void Update()
{
if(updateEveryFrame)
DoUpdate();
}
public void DoUpdate()
{
inst.Runtime.ReconstructSpringBone();
}
}
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(RefreshSBParams))]
public class RefreshSBParamsEditor : Editor
{
/// <summary>
/// InspectorのGUIを更新
/// </summary>
public override void OnInspectorGUI()
{
//元のInspector部分を表示
base.OnInspectorGUI ();
RefreshSBParams refreshSbParams = target as RefreshSBParams;
//ボタンを表示
if (Application.isPlaying && !refreshSbParams.updateEveryFrame
&& GUILayout.Button("Update SpringBone params"))
{
refreshSbParams.DoUpdate();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment