36 lines
1005 B
C#
36 lines
1005 B
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using System.Reflection;
|
|
|
|
|
|
namespace Thousandto.DIY
|
|
{
|
|
public class MyMenuItems
|
|
{
|
|
[MenuItem("Tool/添加button和boxcollider/")]
|
|
public static void AddBoxcolliderAndButton()
|
|
{
|
|
var gos = Selection.gameObjects;
|
|
for(int i = 0; gos != null && i < gos.Length; ++i)
|
|
{
|
|
GameObject go = gos[i];
|
|
UISprite sp = go.GetComponent<UISprite>();
|
|
if (sp == null) continue;
|
|
sp.autoResizeBoxCollider = true;
|
|
UIButton bt = go.GetComponent<UIButton>();
|
|
BoxCollider box = go.GetComponent<BoxCollider>();
|
|
if (bt == null) bt = go.AddComponent<UIButton>();
|
|
if (box == null) box = go.AddComponent<BoxCollider>();
|
|
|
|
sp.autoResizeBoxCollider = true;
|
|
box.size = sp.localSize;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|