Skip to content

Instantly share code, notes, and snippets.

@sfszh
Last active December 17, 2015 12:29
Show Gist options
  • Save sfszh/5610169 to your computer and use it in GitHub Desktop.
Save sfszh/5610169 to your computer and use it in GitHub Desktop.
make refresh the collider in NGUI widgets a little bit easier
using UnityEngine;
using UnityEditor;
using System.Collections;
static public class UIToolExtension{
//add this to NGUImenu.cs
[MenuItem("NGUI/Refresh a Collider #&r")]
static public void RefreshCollider() {
GameObject go = Selection.activeGameObject;
if (NGUIEditorTools.WillLosePrefab(go)) {
if (go != null) {
NGUIEditorTools.RegisterUndo("Refresh Widget Collider", go);
Collider col = go.GetComponent<Collider>();
if (col != null) {
DestroyObj.DestroyImmediate(col);
}
NGUITools.AddWidgetCollider(go);
}
else {
Debug.Log("You must select a game object first, such as your button.");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment