編輯器工具--NGUI--圖集相關--選中預設指定圖集深度修改

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);
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章