Example #1
0
        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);
                }
            }
        }