Please, help me. How can I add the icon in the EditorWIndow tab?
And one more : can I add my EditorWindow right in tabs like AssetServer or Inspector Window?
I’d like to know about the icon thing, also… Can any of the UT guys chime in here, if you have a second?
I asked this same question and the answer is that you can’t customize the icon.
Well, that’s no fun.
It should be pretty easy for them to expose the icon if enough people want it, so be sure to wish-list it if you haven’t already.
-Jeremy
It would also be nice if the ICanHazCustomMenu interface was exposed so that our editor windows can implement it and have custom right-click menus. This is the part that goes above the “Add Tab” popout item (like Debug / Normal items in inspector).
For anyone still interested, I found a way, using Reflection and accessing a hidden getter in the EditorWindow class.
I added it as a simple method in my HOUnityLibs open-source library, inside the HOEditorUtils.HOPanelUtils static class. You can simply call:
HOPanelUtils.SetWindowTitle(EditorWindow editorWindow, Texture icon, string title);
If you’re curious about the code to do it, it’s here.
I found that if you give your EditorWindow the title “UnityEditor.DebugInspectorWindow” it gets an icon automatically. I am trying to figure out how this happens.
It’s just a matter of accessing the cachedTitleContent property in EditorWindow (though it has to be accessed via Reflection since it’s private) and changing it. You can add icons because it’s a GUIContent. Probably the UnityEditor.DebugInspectorWindow title corresponds to some already present icon.
The image of the cached title is reset each time using “LoadGeneratedIconOrNormalIcon”.
Interesting. Where is that method? Can’t see it when inspecting EditorWindow
The icon in the inspector can be loaded using:
Texture2D t = EditorGUIUtility.Load(“Icons/UnityEditor.DebugInspectorWindow.png”) as Texture2D;
If we can place a custom image in the “Icons” location then it will get picked automatically.
Sorry missed your post, it is deep within UnityEditorInternal namespace
I’ve worked it out:
Create the folder:
Assets/Editor Default Resources/Icons/Your.Icon.png
There must be a dot in the name of your icon for this to work. Then use the title for your window “Your.Icon”
Also your image must not be too large otherwise it doesn’t seem to get loaded.
This looks very cool, thanks for sharing But! Can the Editor Default Resources folder be placed somewhere else or it can only be in the Assets folder? Otherwise you can’t keep all you editorWindow assets in one place, which is a thing required by the Asset Store.
It has to be in that exact folder. The default built-in ones are somehow placed into that path virtually. So there might be a way to load a resource with that asset path virtually also, but I am not sure how that works.
PlayMaker actually does include the paths:
Assets/Gizmos/…
Assets/PlayMaker/…
Assets/iTween/…
So it must be possible to do the same thing for this, though it is undocumented and I am uncertain as to whether this would be approved by the asset store team. If there was a way to integrate this into your DLL then this would probably be okay. I would contact the asset store team, they usually get back quite quickly.
Great, thanks again
Okay, the editor resources are loaded using: EditorGUIUtility.GetEditorAssetBundle().Load(filename, type);
So there may lie a clue for someone who understands how asset bundles work.
And the answer to the “Add Tab” menu is that it is a fixed array of panel types. I have asked one of the Unity developers about adding items to the context menu (which requires the currently internal interface ICanHazCustomMenu) and they have agreed to make this fellow public. Unfortunately it doesn’t seem that this will be available for Unity 3.x users and I was told that it probably wouldn’t see the light of day until 4.1
Update on this. I’ve been testing in Unity 4 and the following seems to work fine for me.
Create the /Assets/Editor Default Resources/Icons/YourWindowName.png file.
No need for the dot in the name as stated before (the Your.Icon.png thing)
It can be 16x16 and include transpaent areas, PNG is good for this.
If you don’t see it then 1st restart Unity before assuming it is not working.
I’ve tried moving the Icons and DefRes folders to my package folder root, the Editor path, etc, nothing else worked than the exact path above. So the problem now is that the Asset Store won’t pick it up as a dependancy when you want to submit a package. Any other ideas than the reflection thing? I would like to do it in a “normal” Unity way.
[edit] Just thought of something. I could make a material in my package’s folder and use that texture and thus make it a dependancy. I just want it included in the final pcakge uploaded to the AS and as far as I know these “dependancy” folders are also uploaded. A bit hack-ish though. I wonder if there is a cleaner way.