ソースコード
using System; using UnityEditor; using UnityEngine; [CustomEditor( typeof( Animation ) )] public sealed class AnimationInspector : Editor { private static readonly Type BASE_EDITOR_TYPE = typeof( Editor ) .Assembly .GetType( "UnityEditor.AnimationEditor" ); public override void OnInspectorGUI() { var animation = ( Animation ) target; using ( new EditorGUILayout.HorizontalScope() ) { if ( GUILayout.Button( "Open Animation Window" ) ) { EditorApplication.ExecuteMenuItem( "Window/Animation/Animation" ); } } var editor = CreateEditor( animation, BASE_EDITOR_TYPE ); editor.OnInspectorGUI(); } }
使用例
注意
SerializedObjectNotCreatableException: Object at index 0 is null UnityEditor.Editor.CreateSerializedObject () (at <9818991d79ec4437bcb28429e46862ef>:0) UnityEditor.Editor.GetSerializedObjectInternal () (at <9818991d79ec4437bcb28429e46862ef>:0) UnityEditor.Editor.get_serializedObject () (at <9818991d79ec4437bcb28429e46862ef>:0) UnityEditor.AnimatorInspector.OnEnable () (at <9818991d79ec4437bcb28429e46862ef>:0)
このエディタ拡張を導入して Animation の Inspector を開いた状態で
コンパイルが完了すると上記の例外が発生することがあります
その場合は Unity エディタを再起動すると例外が発生しなくなります