internal static GUIContent GetDefaultToolbarIcon(Type editorToolType) { GUIContent res; if (s_EditorToolDefaulToolbarIcons.TryGetValue(editorToolType, out res)) { return(res); } var name = GetToolName(editorToolType); res = new GUIContent() { tooltip = name }; var attrib = GetEditorToolAttribute(editorToolType); if (attrib != null && attrib.targetType != null) { res.image = AssetPreview.GetMiniTypeThumbnailFromType(attrib.targetType); } else { res.image = EditorGUIUtility.LoadIconRequired("CustomTool"); } s_EditorToolDefaulToolbarIcons.Add(editorToolType, res); return(res); }
private static Texture GetIconForName(string fileName) { if (String.IsNullOrEmpty(fileName)) { return(null); } Texture texture; // Note: a previous texture may have been destroyed // by the system on the c++ side. if (!s_ImageCache.TryGetValue(fileName, out texture) || texture == null) { if (fileName.EndsWith(kIconMipSuffix)) { texture = EditorGUIUtility.FindTexture(fileName) as Texture; } else { texture = EditorGUIUtility.LoadIconRequired(fileName) as Texture; } s_ImageCache.Remove(fileName); s_ImageCache.Add(fileName, texture); } return(texture); }
public virtual int DoChartGUI(Rect chartRect, int currentFrame, bool active) { if (Event.current.type == EventType.Repaint) { string[] labels = new string[m_Series.Length]; for (int s = 0; s < m_Series.Length; s++) { string name = m_Data.hasOverlay ? "Selected" + m_Series[s].name : m_Series[s].name; if (usesCounters) { labels[s] = ProfilerDriver.GetFormattedCounterValue(currentFrame, m_Series[s].category, name); } else { labels[s] = ProfilerDriver.GetFormattedCounterValue(currentFrame, m_Area, name); } } m_Data.AssignSelectedLabels(labels); } if (legendHeaderLabel == null) { legendHeaderLabel = new GUIContent(m_LocalizedName, EditorGUIUtility.LoadIconRequired(m_IconName), Tooltip); } return(DoGUI(chartRect, m_Type, currentFrame, m_Data, active)); }
private static Texture GetIconForName(string fileName) { Texture result; if (string.IsNullOrEmpty(fileName)) { result = null; } else { Texture texture; if (!SoftLockUIData.s_ImageCache.TryGetValue(fileName, out texture) || texture == null) { if (fileName.EndsWith(" Icon")) { texture = EditorGUIUtility.FindTexture(fileName); } else { texture = EditorGUIUtility.LoadIconRequired(fileName); } SoftLockUIData.s_ImageCache.Remove(fileName); SoftLockUIData.s_ImageCache.Add(fileName, texture); } result = texture; } return(result); }
public TilePaletteOpenPalette() : base(SceneViewOpenTilePaletteHelper.OpenTilePalette) { name = "Open Tile Palette"; AddToClassList(k_ToolSettingsClass); icon = EditorGUIUtility.LoadIconRequired("Tilemap Icon"); text = k_LabelText; tooltip = k_TooltipText; }
private void ConnectionStateGUI() { if (HolographicEmulationWindow.s_ConnectedTexture == null) { HolographicEmulationWindow.s_ConnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot3_sml"); HolographicEmulationWindow.s_ConnectingTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot4_sml"); HolographicEmulationWindow.s_DisconnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot6_sml"); } Texture2D image; GUIContent label; GUIContent content; switch (this.m_ConnectionState) { case HolographicStreamerConnectionState.Disconnected: IL_5E: image = HolographicEmulationWindow.s_DisconnectedTexture; label = HolographicEmulationWindow.s_ConnectionStateDisconnectedText; content = HolographicEmulationWindow.s_ConnectionButtonConnectText; goto IL_A3; case HolographicStreamerConnectionState.Connecting: image = HolographicEmulationWindow.s_ConnectingTexture; label = HolographicEmulationWindow.s_ConnectionStateConnectingText; content = HolographicEmulationWindow.s_ConnectionButtonDisconnectText; goto IL_A3; case HolographicStreamerConnectionState.Connected: image = HolographicEmulationWindow.s_ConnectedTexture; label = HolographicEmulationWindow.s_ConnectionStateConnectedText; content = HolographicEmulationWindow.s_ConnectionButtonDisconnectText; goto IL_A3; } goto IL_5E; IL_A3: EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel(HolographicEmulationWindow.s_ConnectionStatusText, "Button"); float singleLineHeight = EditorGUIUtility.singleLineHeight; Rect rect = GUILayoutUtility.GetRect(singleLineHeight, singleLineHeight, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); GUI.DrawTexture(rect, image); EditorGUILayout.LabelField(label, new GUILayoutOption[0]); EditorGUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(this.m_InPlayMode); bool flag = EditorGUILayout.ButtonMouseDown(content, FocusType.Passive, EditorStyles.miniButton, new GUILayoutOption[0]); EditorGUI.EndDisabledGroup(); if (flag) { this.HandleButtonPress(); } }
private void ConnectionStateGUI() { Texture2D textured; GUIContent content; GUIContent content2; if (s_ConnectedTexture == null) { s_ConnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot3_sml"); s_ConnectingTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot4_sml"); s_DisconnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot6_sml"); } switch (this.m_ConnectionState) { case HolographicStreamerConnectionState.Connecting: textured = s_ConnectingTexture; content = s_ConnectionStateConnectingText; content2 = s_ConnectionButtonDisconnectText; break; case HolographicStreamerConnectionState.Connected: textured = s_ConnectedTexture; content = s_ConnectionStateConnectedText; content2 = s_ConnectionButtonDisconnectText; break; default: textured = s_DisconnectedTexture; content = s_ConnectionStateDisconnectedText; content2 = s_ConnectionButtonConnectText; break; } EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel(s_ConnectionStatusText, "Button"); float singleLineHeight = EditorGUIUtility.singleLineHeight; GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.ExpandWidth(false) }; GUI.DrawTexture(GUILayoutUtility.GetRect(singleLineHeight, singleLineHeight, options), textured); EditorGUILayout.LabelField(content, new GUILayoutOption[0]); EditorGUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(this.m_InPlayMode); bool flag = EditorGUILayout.ButtonMouseDown(content2, FocusType.Passive, EditorStyles.miniButton, new GUILayoutOption[0]); EditorGUI.EndDisabledGroup(); if (flag) { this.HandleButtonPress(); } }
void FocusModeChanged() { var content = m_None; switch (GridPaintPaletteWindow.focusMode) { case GridPaintPaletteWindow.TilemapFocusMode.Tilemap: content = m_Tilemap; break; case GridPaintPaletteWindow.TilemapFocusMode.Grid: content = m_Grid; break; } text = content.text; tooltip = content.tooltip; icon = EditorGUIUtility.LoadIconRequired("TilemapRenderer Icon"); }
void ConnectionStateGUI() { if (s_ConnectedTexture == null) { s_ConnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot3_sml"); s_ConnectingTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot4_sml"); s_DisconnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot6_sml"); } Texture2D iconTexture; GUIContent labelContent; GUIContent buttonContent; HolographicStreamerConnectionState connectionState = PerceptionRemotingPlugin.GetConnectionState(); switch (connectionState) { case HolographicStreamerConnectionState.Disconnected: default: iconTexture = s_DisconnectedTexture; labelContent = s_ConnectionStateDisconnectedText; buttonContent = s_ConnectionButtonConnectText; break; case HolographicStreamerConnectionState.Connecting: iconTexture = s_ConnectingTexture; labelContent = s_ConnectionStateConnectingText; buttonContent = s_ConnectionButtonDisconnectText; break; case HolographicStreamerConnectionState.Connected: iconTexture = s_ConnectedTexture; labelContent = s_ConnectionStateConnectedText; buttonContent = s_ConnectionButtonDisconnectText; break; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(s_ConnectionStatusText, "Button"); float iconSize = EditorGUIUtility.singleLineHeight; Rect iconRect = GUILayoutUtility.GetRect(iconSize, iconSize, GUILayout.ExpandWidth(false)); GUI.DrawTexture(iconRect, iconTexture); EditorGUILayout.LabelField(labelContent); EditorGUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(m_InPlayMode); bool pressed = EditorGUILayout.DropdownButton(buttonContent, FocusType.Passive, EditorStyles.miniButton); EditorGUI.EndDisabledGroup(); if (pressed) { if (EditorGUIUtility.editingTextField) { EditorGUIUtility.editingTextField = false; GUIUtility.keyboardControl = 0; } //we delay the call to let the RemoteMachineAddress control commit the value EditorApplication.CallDelayed(() => { HandleButtonPress(); }, 0f); } }
private void ConnectionStateGUI() { if (HolographicEmulationWindow.s_ConnectedTexture == null) { HolographicEmulationWindow.s_ConnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot3_sml"); HolographicEmulationWindow.s_ConnectingTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot4_sml"); HolographicEmulationWindow.s_DisconnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot6_sml"); } Texture2D image; GUIContent label; GUIContent content; switch (PerceptionRemotingPlugin.GetConnectionState()) { case HolographicStreamerConnectionState.Disconnected: IL_5D: image = HolographicEmulationWindow.s_DisconnectedTexture; label = HolographicEmulationWindow.s_ConnectionStateDisconnectedText; content = HolographicEmulationWindow.s_ConnectionButtonConnectText; goto IL_A2; case HolographicStreamerConnectionState.Connecting: image = HolographicEmulationWindow.s_ConnectingTexture; label = HolographicEmulationWindow.s_ConnectionStateConnectingText; content = HolographicEmulationWindow.s_ConnectionButtonDisconnectText; goto IL_A2; case HolographicStreamerConnectionState.Connected: image = HolographicEmulationWindow.s_ConnectedTexture; label = HolographicEmulationWindow.s_ConnectionStateConnectedText; content = HolographicEmulationWindow.s_ConnectionButtonDisconnectText; goto IL_A2; } goto IL_5D; IL_A2: EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel(HolographicEmulationWindow.s_ConnectionStatusText, "Button"); float singleLineHeight = EditorGUIUtility.singleLineHeight; Rect rect = GUILayoutUtility.GetRect(singleLineHeight, singleLineHeight, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); GUI.DrawTexture(rect, image); EditorGUILayout.LabelField(label, new GUILayoutOption[0]); EditorGUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(this.m_InPlayMode); bool flag = EditorGUILayout.DropdownButton(content, FocusType.Passive, EditorStyles.miniButton, new GUILayoutOption[0]); EditorGUI.EndDisabledGroup(); if (flag) { if (EditorGUIUtility.editingTextField) { EditorGUIUtility.editingTextField = false; GUIUtility.keyboardControl = 0; } EditorApplication.CallDelayed(delegate { this.HandleButtonPress(); }, 0f); } }
public static Texture2D LoadIcon(string iconName) { return(EditorGUIUtility.LoadIconRequired(iconName == null ? null : ResolveIcon(iconName))); }
/* For tests */ public static Texture2D LoadIconRequired(string path) { return(EditorGUIUtility.LoadIconRequired(path)); }
public ToolButton(Tool targetTool) { m_TargetTool = targetTool; name = targetTool + "Tool"; tooltip = L10n.Tr(targetTool + " Tool"); this.RegisterValueChangedCallback((evt) => { if (evt.newValue) { Tools.current = m_TargetTool; } // Keep the toggle checked if target is still the current tool if (m_TargetTool == Tools.current) { SetValueWithoutNotify(true); } }); switch (targetTool) { case Tool.View: m_PanViewIcon = EditorGUIUtility.LoadIconRequired("ViewToolMove"); m_PanViewOnIcon = EditorGUIUtility.LoadIconRequired("ViewToolMove On"); m_FpsViewIcon = m_OrbitViewIcon = EditorGUIUtility.LoadIconRequired("ViewToolOrbit"); m_FpsViewOnIcon = m_OrbitViewOnIcon = EditorGUIUtility.LoadIconRequired("ViewToolOrbit On"); m_ZoomViewIcon = EditorGUIUtility.LoadIconRequired("ViewToolZoom"); m_ZoomViewOnIcon = EditorGUIUtility.LoadIconRequired("ViewToolZoom On"); break; case Tool.Move: onIcon = EditorGUIUtility.LoadIconRequired("MoveTool On"); offIcon = EditorGUIUtility.LoadIconRequired("MoveTool"); break; case Tool.Rotate: onIcon = EditorGUIUtility.LoadIconRequired("RotateTool On"); offIcon = EditorGUIUtility.LoadIconRequired("RotateTool"); break; case Tool.Scale: onIcon = EditorGUIUtility.LoadIconRequired("ScaleTool On"); offIcon = EditorGUIUtility.LoadIconRequired("ScaleTool"); break; case Tool.Transform: onIcon = EditorGUIUtility.LoadIconRequired("TransformTool On"); offIcon = EditorGUIUtility.LoadIconRequired("TransformTool"); break; case Tool.Rect: onIcon = EditorGUIUtility.FindTexture("RectTool On"); offIcon = EditorGUIUtility.FindTexture("RectTool"); break; } UpdateState(); RegisterCallback <AttachToPanelEvent>(OnAttachedToPanel); RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel); }