有时候在做编辑器的时候想用系统按钮的图标,可是不知道怎么写怎么办? Unity的系统图标分为两种, 一个是鼠标的图标(当鼠标放在一个Rect区域时的样式)、还有就是按钮的图标。
鼠标的图标unity提供了枚举,我遍历一下就出来了, 可是系统图标unity是用字符串的形式加载的,那么我反编译了一下editor的dll用正则提取出来了。 如下图所示
为了让大家更好的对上号, 我又重新截了一张图。
然后是图标名字。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
TreeEditor.AddLeaves TreeEditor.AddBranches TreeEditor.Trash TreeEditor.Duplicate TreeEditor.Refresh editicon.sml tree_icon_branch_frond tree_icon_branch tree_icon_frond tree_icon_leaf tree_icon animationvisibilitytoggleon animationvisibilitytoggleoff MonoLogo AgeiaLogo AboutWindow.MainHeader Animation.AddEvent lightMeter/greenLight lightMeter/lightRim lightMeter/orangeLight lightMeter/redLight Animation.PrevKey Animation.NextKey Animation.AddKeyframe Animation.EventMarker Animation.Play Animation.Record AS Badge Delete AS Badge Move AS Badge New WelcomeScreen.AssetStoreLogo preAudioAutoPlayOff preAudioAutoPlayOn preAudioPlayOff preAudioPlayOn preAudioLoopOff preAudioLoopOn AvatarInspector/BodySilhouette AvatarInspector/HeadZoomSilhouette AvatarInspector/LeftHandZoomSilhouette AvatarInspector/RightHandZoomSilhouette AvatarInspector/Torso AvatarInspector/Head AvatarInspector/LeftArm AvatarInspector/LeftFingers AvatarInspector/RightArm AvatarInspector/RightFingers AvatarInspector/LeftLeg AvatarInspector/RightLeg AvatarInspector/HeadZoom AvatarInspector/LeftHandZoom AvatarInspector/RightHandZoom AvatarInspector/DotFill AvatarInspector/DotFrame AvatarInspector/DotFrameDotted AvatarInspector/DotSelection SpeedScale AvatarPivot Avatar Icon Mirror AvatarInspector/BodySIlhouette AvatarInspector/BodyPartPicker AvatarInspector/MaskEditor_Root AvatarInspector/LeftFeetIk AvatarInspector/RightFeetIk AvatarInspector/LeftFingersIk AvatarInspector/RightFingersIk BuildSettings.SelectedIcon SocialNetworks.UDNLogo SocialNetworks.LinkedInShare SocialNetworks.FacebookShare SocialNetworks.Tweet SocialNetworks.UDNOpen Clipboard Toolbar Minus ClothInspector.PaintValue EditCollider EyeDropper.Large ColorPicker.CycleColor ColorPicker.CycleSlider PreTextureMipMapLow PreTextureMipMapHigh PreTextureAlpha PreTextureRGB Icon Dropdown UnityLogo Profiler.PrevFrame Profiler.NextFrame GameObject Icon Prefab Icon PrefabNormal Icon PrefabModel Icon ScriptableObject Icon sv_icon_none PreMatLight0 PreMatLight1 Toolbar Plus Camera Icon PreMatSphere PreMatCube PreMatCylinder PreMatTorus PlayButton PauseButton HorizontalSplit VerticalSplit BuildSettings.Web.Small js Script Icon cs Script Icon boo Script Icon Shader Icon TextAsset Icon AnimatorController Icon AudioMixerController Icon RectTransformRaw RectTransformBlueprint MoveTool MeshRenderer Icon Terrain Icon SceneviewLighting SceneviewFx SceneviewAudio SettingsIcon TerrainInspector.TerrainToolRaise TerrainInspector.TerrainToolSetHeight TerrainInspector.TerrainToolSmoothHeight TerrainInspector.TerrainToolSplat TerrainInspector.TerrainToolTrees TerrainInspector.TerrainToolPlants TerrainInspector.TerrainToolSettings RotateTool ScaleTool RectTool MoveTool On RotateTool On ScaleTool On RectTool On ViewToolOrbit ViewToolMove ViewToolZoom ViewToolOrbit On ViewToolMove On ViewToolZoom On StepButton PlayButtonProfile PlayButton On PauseButton On StepButton On PlayButtonProfile On PlayButton Anim PauseButton Anim StepButton Anim PlayButtonProfile Anim WelcomeScreen.MainHeader WelcomeScreen.VideoTutLogo WelcomeScreen.UnityBasicsLogo WelcomeScreen.UnityForumLogo WelcomeScreen.UnityAnswersLogo Toolbar Plus More |
最后是代码,注意!我的代码是把上面的图名保存在本件用Resources.Load完成的。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
using UnityEngine; using UnityEditor; using System; class MyWindow : EditorWindow { static string []text; [MenuItem("Window/My Window")] public static void ShowWindow() { EditorWindow.GetWindow(typeof(MyWindow)); text = Resources.Load<TextAsset>("t").text.Split("\n"[0]); } public Vector2 scrollPosition; void OnGUI() { scrollPosition = GUILayout.BeginScrollView(scrollPosition); //鼠标放在按钮上的样式 foreach (MouseCursor item in Enum.GetValues(typeof(MouseCursor))) { GUILayout.Button(Enum.GetName(typeof(MouseCursor), item)); EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), item); GUILayout.Space(10); } //内置图标 for(int i =0; i< text.Length; i+=8) { GUILayout.BeginHorizontal(); for (int j =0; j < 8; j++) { int index = i + j; if(index < text.Length) GUILayout.Button(EditorGUIUtility.IconContent(text[index]), GUILayout.Width(50), GUILayout.Height(30)); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } } |
- 本文固定链接: https://www.xuanyusong.com/archives/3777
- 转载请注明: 雨松MOMO 于 雨松MOMO程序研究院 发表
捐 赠写博客不易,如果您想请我喝一杯星巴克的话?就进来看吧!
Window如果加载不到图片 建议使用楼上哥们解决方案 源码40行稍微改一下,去掉字符串前后的空白字符GUILayout.Button(EditorGUIUtility.IconContent(text[index].Trim()), GUILayout.Width(50), GUILayout.Height(30));
为什么一直报这个错:ArgumentException: Illegal characters in path. 请问雨松大大:如何反编译?谢谢
应该是 windows 上换行符导致的,可以将源码40行稍微改一下,去掉字符串前后的空白字符GUILayout.Button(EditorGUIUtility.IconContent(text[index].Trim()), GUILayout.Width(50), GUILayout.Height(30));
雨松大大~~~我们team现在iOS主工程已经完工,要集成unity项目进去,我看unity只能导出完整工程啊,怎样将unity嵌入iOS项目?拜谢~~~
貌似获取不到图标,是我的Unity版本的原因吗?
我的版本是5.2.2
我用的是5.2.1,都获取不到,指针的枚举倒是都能用的
突然感觉到一股蛋疼的味道…………
[亲亲] [亲亲]
雨松大大用的什么反编译软件呢
顶雨松大
赞!!!!![威武]