Last active
January 29, 2019 17:12
-
-
Save sukedon/91c6c4e9617b2414f9dfd02d60e0bffb to your computer and use it in GitHub Desktop.
Animatorの再生確認用ボタンを追加する拡張
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 UnityEditor.Animations; | |
using UnityEngine; | |
[CustomEditor(typeof(Animator))] | |
public class AnimatorCustomEditor : Editor { | |
public override void OnInspectorGUI() | |
{ | |
base.OnInspectorGUI(); | |
if (!Application.isPlaying) | |
{ | |
return; | |
} | |
var anim = target as Animator; | |
var controller = anim.runtimeAnimatorController as AnimatorController; | |
// 複数レイヤーは普段使わないから、、 | |
var animatorStates = controller.layers[0].stateMachine.states; | |
foreach (var animatorState in animatorStates) | |
{ | |
var state = animatorState.state; | |
if (GUILayout.Button("Play:" + state.name)) | |
{ | |
anim.Play(state.name); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment