private void RenderIcons() { var currIconIndex = 0; while (currIconIndex < m_iconNames.Count) { var numIconsOnRow = 0; var currWidth = 0.0f; var maxHeight = 0.0f; for (numIconsOnRow = 0; currIconIndex + numIconsOnRow < m_iconNames.Count;) { var icon = IconManager.GetIcon(m_iconNames[numIconsOnRow + currIconIndex]); maxHeight = Mathf.Max(icon.height, maxHeight); if (currWidth + icon.width < EditorGUIUtility.currentViewWidth) { currWidth += icon.width; ++numIconsOnRow; } else { break; } } if (numIconsOnRow == 0) { break; } var rect = EditorGUILayout.GetControlRect(false, maxHeight); for (int i = 0; i < numIconsOnRow && currIconIndex < m_iconNames.Count; ++i, ++currIconIndex) { var icon = IconManager.GetIcon(m_iconNames[currIconIndex]); rect.width = icon.width; rect.height = icon.height; using (new GUI.ColorBlock(IconManager.ActiveColor)) UnityEngine.GUI.DrawTexture(rect, icon); rect.x += icon.width; } if (currIconIndex < m_iconNames.Count) { InspectorGUI.DashedBrandSeparator(1, 6); } } }
private void RenderIcons(Vector2 size) { var numIconsPerRow = (int)(position.width / size.x); var currIconIndex = 0; while (currIconIndex < m_iconNames.Count) { var rect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(false, size.y)); rect.width = size.x; for (int i = 0; currIconIndex < m_iconNames.Count && i < numIconsPerRow; ++currIconIndex, ++i) { using (new GUI.ColorBlock(IconManager.ActiveColor)) UnityEngine.GUI.DrawTexture(rect, IconManager.GetIcon(m_iconNames[currIconIndex])); rect.x += rect.width + 4.0f; } } }
private void RenderButtons(Vector2 buttonSize, bool buttonsEnabled, bool buttonsActive) { GUILayout.Label(GUI.MakeLabel(buttonsEnabled && buttonsActive ? "Enabled and active" : buttonsEnabled == buttonsActive ? "Disabled and inactive" : buttonsEnabled ? "Enabled and inactive" : "Disabled and active??????????"), InspectorGUISkin.Instance.LabelMiddleCenter); var numIconsPerRow = (int)(position.width / buttonSize.x); var currIconIndex = 0; while (currIconIndex < m_iconNames.Count) { var rect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(false, buttonSize.y)); rect.width = buttonSize.x; for (int i = 0; currIconIndex < m_iconNames.Count && i < numIconsPerRow; ++currIconIndex, ++i) { var buttonType = i == 0 && m_iconNames.Count - currIconIndex - 1 == 0 ? InspectorGUISkin.ButtonType.Normal : i == 0 ? InspectorGUISkin.ButtonType.Left : i == numIconsPerRow - 1 || currIconIndex == m_iconNames.Count - 1 ? InspectorGUISkin.ButtonType.Right : InspectorGUISkin.ButtonType.Middle; var content = new GUIContent(IconManager.GetIcon(m_iconNames[currIconIndex]), m_iconNames[currIconIndex] + $" | active: {buttonsActive}, enabled: {buttonsEnabled}"); var pressed = ToolButton(rect, content, buttonType, buttonsActive, buttonsEnabled); if (pressed) { EditorGUIUtility.systemCopyBuffer = m_iconNames[currIconIndex]; } rect.x += rect.width; } } }
public static bool ToolButton(Rect rect, GUIContent content, InspectorGUISkin.ButtonType buttonType, bool active, bool enabled) { var disabledScope = new EditorGUI.DisabledScope(!enabled); var buttonContent = content.image != null?ToolButtonTooltip(content) : content; var pressed = UnityEngine.GUI.Button(rect, buttonContent, InspectorEditor.Skin.GetButton(active, buttonType)); if (buttonContent == s_tooltipContent && content.image != null) { using (IconManager.ForegroundColorBlock(active, enabled)) UnityEngine.GUI.DrawTexture(IconManager.GetIconRect(rect), content.image); } disabledScope.Dispose(); return(pressed); }
public sealed override void OnInspectorGUI() { if (Utils.KeyHandler.HandleDetectKeyOnGUI(this.targets, Event.current)) { return; } if (IsMainEditor && !typeof(ScriptableObject).IsAssignableFrom(target.GetType())) { var controlRect = EditorGUILayout.GetControlRect(false, 0.0f); if (m_icon == null) { m_icon = IconManager.GetIcon("algoryx_white_shadow_icon"); } if (m_icon != null) { if (m_hideTexture == null) { #if UNITY_2019_3_OR_NEWER var hideColor = Color.Lerp(InspectorGUI.BackgroundColor, Color.white, 0.03f); #else var hideColor = InspectorGUI.BackgroundColor; #endif m_hideTexture = GUI.CreateColoredTexture(1, 1, hideColor); } var hideRect = new Rect(controlRect.x, #if UNITY_2019_3_OR_NEWER controlRect.y - 1.25f * EditorGUIUtility.singleLineHeight - 2, #else controlRect.y - 1.00f * EditorGUIUtility.singleLineHeight - 1, #endif 18, EditorGUIUtility.singleLineHeight + 2); UnityEngine.GUI.DrawTexture(hideRect, m_hideTexture); var iconRect = new Rect(hideRect); iconRect.height = 14.0f; iconRect.width = 14.0f; #if UNITY_2019_3_OR_NEWER iconRect.y += 2.5f; #else iconRect.y += 1.5f; #endif iconRect.x += 3.0f; UnityEngine.GUI.DrawTexture(iconRect, m_icon); } InspectorGUI.BrandSeparator(); } GUILayout.BeginVertical(); ToolManager.OnPreTargetMembers(this.targets); DrawMembersGUI(this.targets, null, serializedObject); ToolManager.OnPostTargetMembers(this.targets); GUILayout.EndVertical(); }