Sage_禅
qq交流群:106864335
加群連接配接:

q群初建,歡迎大家加入交流。
微信公衆号:zhimeng-1314 名稱:Unity不瘋魔不成活
開發mmoarpg項目很長時間了,現在總結一些項目中自寫的一些工具作為記錄和分享。
項目中用的是NGUI3.9.4,本篇介紹工具:選中預設指定圖集深度修改,代碼如下。
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
/// 我的工具庫--通用編輯器工具
/// 注:可以用,不可以改
/// 所有的相似工具類在此下添加
/// <summary>
/// 選中預設指定圖集深度修改
/// </summary>
public class WTool_ChangeAtlaDepth : EditorWindow
{
#region 菜單添加
[MenuItem("WTools/Atlas/修改圖集深度")]
public static void Open()
{
EditorWindow.GetWindow(typeof(WTool_ChangeAtlaDepth));
}
#endregion
#region 編輯器視窗繪制
public UIAtlas 指定圖集;
public string depth;
private static UIAtlas toChangeAtla;
private static string toChangeDepth;
private void OnGUI()
{
指定圖集 = (UIAtlas)EditorGUILayout.ObjectField(指定圖集, typeof(UIAtlas), true, GUILayout.MinWidth(100f));
toChangeAtla = 指定圖集;
GUILayout.Label("圖集的深度要修改為:");
depth = EditorGUILayout.TextField(depth, GUILayout.MinWidth(100f));
toChangeDepth = depth;
if (GUILayout.Button("w圖集深度變變變!"))
{
Change();
}
}
#endregion
public static void Change()
{
int num = 0;
List<UISprite> sprites = WEditorTools.SelectCompount<UISprite>();
foreach (UISprite item in sprites)
{
if (item != null && item.atlas == toChangeAtla)
{
item.depth = int.Parse(toChangeDepth);
num++;
}
}
Debug.Log("修改完成,共修改的次數為" + num);
}
}