過去に何度か デフォルト Insepector 拡張を行って来ましたが CanEditMultipleObjects を用いて
複数選択に対応すると不具合が生じていましたが、CreateEditor
時に targets
を指定することで解決できました
using UnityEditor; using UnityEngine; [CustomEditor(typeof(Transform))] [CanEditMultipleObjects] public class InternalEditorExtensionAbstract : Editor { private Editor _editor; private Transform _transform; private void OnEnable() { var type = typeof(EditorApplication).Assembly.GetType("UnityEditor.TransformInspector"); _editor = CreateEditor(targets, type); _transform = target as Transform; } private void OnDisable() { DestroyImmediate(_editor); } public sealed override void OnInspectorGUI() { _editor.OnInspectorGUI(); using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.LabelField("World"); EditorGUILayout.Vector3Field("Position", _transform.position); EditorGUILayout.Vector3Field("Rotation", _transform.rotation.eulerAngles); EditorGUILayout.Vector3Field("Scale", _transform.lossyScale); } } }