调用EditorGUIUtility.IconContent(“icon name”) 填充editor ui 内容。
GUIContent defines what to render and GUIStyle defines how to render it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class MyUnityTextureWindow : EditorWindow {
[MenuItem(("Window/My UnityTextureWindow"))]
static void Init(){
EditorWindow.GetWindow<MyUnityTextureWindow>("MyUnityTextureWindow");
}
Vector2 m_Scroll;
List<string> m_Icons = null;
void Awake(){
m_Icons = new List<string>();
Texture2D[] t = Resources.FindObjectsOfTypeAll<Texture2D>();
foreach(Texture2D x in t){
Debug.unityLogger.logEnabled = false;
GUIContent gc = EditorGUIUtility.IconContent(x.name);
Debug.unityLogger.logEnabled = true;
if(gc != null && gc.image != null){
m_Icons.Add(x.name);
}

在Unity中,可以通过EditorGUIUtility.IconContent方法获取内置图标,并用于编辑器UI内容的展示。GUIContent负责定义渲染的内容,而GUIStyle则规定了内容的渲染样式。
最低0.47元/天 解锁文章
756

被折叠的 条评论
为什么被折叠?



