修改预制中的Table组件字体大小

using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;




///<summary>
///tabel 字体大小改变
///</summary>
public class ChangeTabelSixe
{
    [MenuItem("NGUI/Change Tabel Size")]
    public static void ExecuteLabelChange()
    {
        foreach (UnityEngine.Object o in Selection.objects)
        {
            if (o != null)
            {
                GameObject go = o as GameObject;    
                if (go != null)
                {
                    GameObject prefabGameObject = PrefabUtility.InstantiatePrefab(go) as GameObject;        
                    SetLabelSize(prefabGameObject);
                    PrefabUtility.ReplacePrefab(prefabGameObject, go, ReplacePrefabOptions.Default);
                    MonoBehaviour.DestroyImmediate(prefabGameObject);
                }
            }
        }
        AssetDatabase.SaveAssets();
    }


    public static void SetLabelSize(GameObject go = null)
    {
        if (go != null)
        {
            UILabel[] label = go.GetComponentsInChildren<UILabel>(true);
            foreach (var item in label)
            {
                item.fontSize = item.fontSize - 3;
            }
        }
    }


}

猜你喜欢

转载自blog.csdn.net/Fivelin/article/details/79891549