using System.Linq;
using UnityEditor;
using UnityEngine;
[CanEditMultipleObjects]
[CustomEditor( typeof( BoxCollider ), true )]
public sealed class BoxColliderInspector : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var boxCollider = target as BoxCollider;
if ( boxCollider == null ) return;
var uiWidget = boxCollider.GetComponent<UIWidget>();
if ( uiWidget == null ) return;
EditorGUI.BeginChangeCheck();
serializedObject.Update();
if ( GUILayout.Button( "Adjust To Match" ) )
{
NGUITools.UpdateWidgetCollider( boxCollider, true );
}
serializedObject.ApplyModifiedProperties();
if ( !EditorGUI.EndChangeCheck() ) return;
foreach ( var n in targets.OfType<BoxCollider>() )
{
NGUITools.UpdateWidgetCollider( n, true );
}
}
}
関連記事