Version: 2022.1
言語: 日本語
public static Texture2D GetIconForObject (Object obj);

パラメーター

obj The GameObject or MonoScript to query

戻り値

Texture2D Returns the custom icon associated with the object. If there is no custom icon associated with the object, returns null.

説明

Gets the custom icon associated with an object. Only GameObjects and MonoScripts have associated custom icons.

using UnityEngine;
using UnityEditor;

class Example { [MenuItem("Examples/Get Icon for GameObject")] public static void GetIconForGameObject() { var go = GameObject.Find("Main Camera"); var icon = EditorGUIUtility.GetIconForObject(go); Debug.Log("Icon for " + go + " is " + icon); }

[MenuItem("Examples/Get Icon for MonoScript")] public static void GetIconForMonoScript() { var monoScript = AssetDatabase.LoadAssetAtPath<MonoScript>("Assets/MyMonoBehaviour.cs"); var icon = EditorGUIUtility.GetIconForObject(monoScript); Debug.Log("Icon for " + monoScript.GetClass().FullName + " is " + icon); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961