Favourites icon indicating copy to clipboard operation
Favourites copied to clipboard

Doesn't work in Unity 2022.2.8

Open seannowotny opened this issue 1 year ago • 1 comments

In FavouritesTreeView.cs this line results in an exception.

PropertyInfo prop = asm.GetType("UnityEditorInternal.EditorResourcesUtility").GetProperty("folderIconName", (BindingFlags.Static | BindingFlags.Public));

NullReferenceException: Object reference not set to an instance of an object FavouritesEd.FavouritesTreeView.FolderIconName () (at Assets/Favourites/Editor/FavouritesTreeView.cs:296) FavouritesEd.FavouritesTreeView.LoadAndUpdate (FavouritesEd.FavouritesAsset favsAsset) (at Assets/Favourites/Editor/FavouritesTreeView.cs:52) FavouritesEd.FavouritesEdWindow.UpdateTreeview () (at Assets/Favourites/Editor/FavouritesEdWindow.cs:59) FavouritesEd.FavouritesEdWindow.AddCategory (FavouritesEd.TextInputWindow wiz) (at Assets/Favourites/Editor/FavouritesEdWindow.cs:103) FavouritesEd.TextInputWindow.Update () (at Assets/Favourites/Editor/TextInputWindow.cs:35) UnityEditor.HostView.SendUpdate () (at <3d77f9e52a364b2f825fba70966192a5>:0) UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <3d77f9e52a364b2f825fba70966192a5>:0)

seannowotny avatar Mar 16 '23 14:03 seannowotny

Try this

private static string FolderIconName()
{
#if UNITY_2018_3_OR_NEWER
	return UnityEditor.Experimental.EditorResources.iconsPath;
#else
	if (Invoke_folderIconName == null)
	{
		Assembly asm = Assembly.GetAssembly(typeof(Editor));
		PropertyInfo prop = asm.GetType("UnityEditorInternal.EditorResourcesUtility").GetProperty("folderIconName", (BindingFlags.Static | BindingFlags.Public));
		MethodInfo method = prop.GetGetMethod(true);
		Invoke_folderIconName = (System.Func<string>)System.Delegate.CreateDelegate(typeof(System.Func<string>), method);
	}
	return Invoke_folderIconName();
#endif
}

luty4ng avatar Jan 18 '24 06:01 luty4ng