//---------------------------------------------- // NGUI: Next-Gen UI kit // Copyright © 2011-2015 Tasharen Entertainment //---------------------------------------------- using UnityEngine; using UnityEditor; using System.Collections.Generic; /// /// Inspector class used to edit UISprites. /// [CustomEditor(typeof(UIImageButton))] public class UIImageButtonInspector : Editor { public override void OnInspectorGUI () { EditorGUILayout.HelpBox("Image Button component's functionality is now a part of UIButton. You no longer need UIImageButton.", MessageType.Warning, true); if (GUILayout.Button("Auto-Upgrade")) { UIImageButton img = target as UIImageButton; UIButton btn = img.GetComponent(); if (btn == null) { btn = img.gameObject.AddComponent(); if (img.target != null) btn.tweenTarget = img.target.gameObject; else btn.tweenTarget = img.gameObject; UISprite sp = btn.tweenTarget.GetComponent(); if (sp != null) sp.spriteName = img.normalSprite; } btn.hoverSprite = img.hoverSprite; btn.pressedSprite = img.pressedSprite; btn.disabledSprite = img.disabledSprite; btn.pixelSnap = img.pixelSnap; NGUITools.DestroyImmediate(img); } } }