很多时候,我们需要批量修改大量预制体同一属性,这时候手动修改效率太低,用工具操作就方便多了
比如修改Text组件属性,以BestFit为例,上代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using UnityEngine.UI;
public class EditorTest2 : EditorWindow
{
EditorTest2()
{
this.titleContent = new GUIContent("测试窗口2");
this.maxSize = new Vector2(300,400);
this.minSize = new Vector2(300, 400);
}
[MenuItem("Tools/测试窗口2")]
static void CreateWin()
{
EditorWindow.GetWindow(typeof(EditorTest2));
}
int selectIdx;
private void OnGUI()
{
//设置项目中所有Text组件为BestFit
GUI.skin.label.fontSize = 20;
GUILayout.Label("设置Text组件的BestFit");
string[] selectItem = { "true", "false" };
selectIdx = EditorGUILayout.Popup("BestFit:", selectIdx, selectItem);
//Debug.Log("selec