Created
November 27, 2023 13:06
-
-
Save autch/e09b02dac18f78f88499176d37f6545d to your computer and use it in GitHub Desktop.
UniVRM-1.x で Play 中に SpringBone パラメータの変更を反映させる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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