Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the <see cref="AssetIcons.AssetIconTools"/> class.
        /// </summary>
        static AssetIconTools()
        {
            IconProviders = BuildIconDatabase();

#if UNITY_2017_1_OR_NEWER
            try
            {
                Assembly editorAssembly     = Assembly.GetAssembly(typeof(SerializedProperty));
                Type     ObjectListAreaType = editorAssembly.GetType("UnityEditor.ObjectListArea");

                EventInfo postAssetIconDrawCallbackEvent = ObjectListAreaType.GetEvent("postAssetIconDrawCallback", BindingFlags.Static | BindingFlags.NonPublic);

                IconDelegate eventHandler = AllItemsGUI;

                MethodInfo addMethod = postAssetIconDrawCallbackEvent.GetAddMethod(true);

                Type delegateType = ObjectListAreaType.GetNestedType("OnAssetIconDrawDelegate", BindingFlags.NonPublic);

                object param1 = Cast(eventHandler, delegateType);

                addMethod.Invoke(null, new object[1] {
                    param1
                });
            }
            catch
            {
                EditorApplication.projectWindowItemOnGUI += ItemOnGUI;
            }
#else
            EditorApplication.projectWindowItemOnGUI += ItemOnGUI;
#endif

            EditorApplication.delayCall += () => {
                isEnabled = EditorPrefs.GetBool("AssetIconUtility_Draw", true);

                Menu.SetChecked(MenuLocation + "/Draw Custom Asset Icons", isEnabled);
            };
        }
Ejemplo n.º 2
0
 public void SetIconDelegate(IconDelegate method)
 {
     _icon_delegate = method;
 }