private float calcBoxHeight(int page, int subHead)
    {
        float num = 15f;

        num        = (articley = num + 20f);
        strArticle = GetArticle(page, subHead);
        GUIStyle style = GUI.skin.GetStyle("ArticleLabel");
        float    num2  = style.CalcHeight(new GUIContent(strArticle), 720f);

        num += num2;
        return(num + 15f);
    }
        private void DrawQuests()
        {
            if ((scrollView != null))
            {
                float  contentY                = padding;
                string currentGroup            = null;
                var    isCurrentGroupCollapsed = false;
                foreach (var questInfo in quests)
                {
                    // Check for new group:
                    if (!string.Equals(questInfo.Group, currentGroup))
                    {
                        currentGroup = questInfo.Group;
                        if (!string.IsNullOrEmpty(currentGroup))
                        {
                            isCurrentGroupCollapsed = collapsedGroups.Contains(currentGroup);
                            var groupHeadingHeight = GroupHeadingHeight(currentGroup);
                            //---Was: GUI.Label(new Rect(padding, contentY, scrollView.contentWidth - (2 * padding), groupHeadingHeight), currentGroup, GetGroupHeadingStyle());
                            if (GUI.Button(new Rect(padding, contentY, scrollView.contentWidth - (2 * padding), groupHeadingHeight), currentGroup, GetGroupHeadingStyle()))
                            {
                                ClickQuestGroup(currentGroup);
                            }
                            contentY += groupHeadingHeight;
                        }
                    }

                    // Draw quest:
                    if (!isCurrentGroupCollapsed)
                    {
                        bool  isSelectedQuest = IsSelectedQuest(questInfo);
                        float headingHeight   = QuestHeadingHeight(questInfo);
                        if (GUI.Button(new Rect(padding, contentY, scrollView.contentWidth - (2 * padding), headingHeight), questInfo.Heading.text, GetQuestHeadingStyle(isSelectedQuest)))
                        {
                            ClickQuest(questInfo.Title);
                        }
                        contentY += headingHeight;
                        if (isSelectedQuest)
                        {
                            contentY = DrawQuestDescription(questInfo, contentY);
                            contentY = DrawQuestEntries(questInfo, contentY);
                            contentY = DrawQuestButtons(questInfo, contentY);
                        }
                    }
                }
                if (quests.Length == 0)
                {
                    GUIStyle noQuestsStyle     = UnityGUITools.GetGUIStyle(noQuestsGuiStyleName, GUI.skin.label);
                    float    descriptionHeight = noQuestsStyle.CalcHeight(new GUIContent(noQuestsMessage), scrollView.contentWidth - 4);
                    GUI.Label(new Rect(2, contentY, scrollView.contentWidth, descriptionHeight), noQuestsMessage, noQuestsStyle);
                    contentY += descriptionHeight;
                }
            }
        }
Example #3
0
        public void DisplayList()
        {
            if (m_isClickedComboButton)
            {
                Rect listRect = new Rect(m_rect.x, m_rect.y + m_listStyle.CalcHeight(m_listContent[0], 1.0f),
                                         m_rect.width, m_listStyle.CalcHeight(m_listContent[0], 1.0f) * m_listContent.Length);

                GUI.Box(listRect, "", m_boxStyle);
                int newSelectedItemIndex = GUI.SelectionGrid(listRect, m_selectedItemIndex, m_listContent, 1, m_listStyle);
                if (newSelectedItemIndex != m_selectedItemIndex)
                {
                    m_selectedItemIndex = newSelectedItemIndex;
                    m_buttonContent     = m_listContent[m_selectedItemIndex];
                }
            }

            if (m_done)
            {
                m_isClickedComboButton = false;
            }
        }
Example #4
0
    // Draw text and increment Y position
    private Vector2 drawText(Vector2 pos, string text)
    {
        Vector2 size = new Vector2(1000, 300);

        Rect r = new Rect(pos, size);

        GUI.Label(r, text, Style);

        float height = Style.CalcHeight(new GUIContent(text), size.x);

        return(new Vector2(pos.x, pos.y + height + Spacing));
    }
 private float QuestDescriptionHeight(QuestInfo questInfo)
 {
     questBodyStyle = UseGUIStyle(questBodyStyle, questBodyGuiStyleName, GUI.skin.label);
     if (questHeadingSource == QuestHeadingSource.Name)
     {
         return(questBodyStyle.CalcHeight(new GUIContent(questInfo.Description.text), scrollView.contentWidth - (2 * padding)));
     }
     else
     {
         return(0);
     }
 }
Example #6
0
    private void WatchVarWindow(int windowID)
    {
        GUI.Box(this.scrollRect, string.Empty);
        this.innerRect.height    = (((float)this.innerHeight >= this.scrollRect.height) ? ((float)this.innerHeight) : this.scrollRect.height);
        this._watchVarsScrollPos = GUI.BeginScrollView(this.scrollRect, this._watchVarsScrollPos, this.innerRect, false, true);
        int   num = 0;
        float y   = 0f;

        this.valueRect.y = y;
        this.nameRect.y  = y;
        this.nameRect.x  = this.messageLine.x;
        float    num2     = this.messageLine.width - this.messageLine.x;
        GUIStyle textArea = GUI.skin.textArea;

        foreach (KeyValuePair <string, WatchVarBase> current in this._watchVarTable)
        {
            GUIContent content    = new GUIContent(string.Format("{0}:", current.Value.Name));
            GUIContent gUIContent = new GUIContent(current.Value.ToString());
            float      num3;
            float      num4;
            this.labelStyle.CalcMinMaxWidth(content, out num3, out num4);
            float num5;
            float num6;
            textArea.CalcMinMaxWidth(gUIContent, out num5, out num6);
            if (num4 > num2)
            {
                this.nameRect.width  = num2 - num5;
                this.valueRect.width = num5;
            }
            else if (num6 + num4 > num2)
            {
                this.valueRect.width = num2 - num3;
                this.nameRect.width  = num3;
            }
            else
            {
                this.valueRect.width = num6;
                this.nameRect.width  = num4;
            }
            this.nameRect.height  = this.labelStyle.CalcHeight(content, this.nameRect.width);
            this.valueRect.height = textArea.CalcHeight(gUIContent, this.valueRect.width);
            this.valueRect.x      = num2 - this.valueRect.width + this.nameRect.x;
            GUI.Label(this.nameRect, content);
            GUI.TextArea(this.valueRect, gUIContent.text);
            float num7 = Mathf.Max(this.nameRect.height, this.valueRect.height) + 4f;
            this.nameRect.y  = this.nameRect.y + num7;
            this.valueRect.y = this.valueRect.y + num7;
            this.innerHeight = ((this.valueRect.y <= this.scrollRect.height) ? ((int)this.scrollRect.height) : ((int)this.valueRect.y));
            num++;
        }
        GUI.EndScrollView();
        this.DrawBottomControls();
    }
Example #7
0
        /// <summary>
        /// Calc height needed, right now is always 20
        /// </summary>
        public override float GetHeight()
        {
            GUIStyle style = "HelpBox";

            return(Mathf.Max(
                       style.CalcHeight(
                           new GUIContent(HelpAttribute.Help),
                           Screen.width - 21
                           ),
                       20
                       ));
        }
Example #8
0
        public int Show(Rect rect)
        {
            bool done     = false;
            int  activeID = GUIUtility.GetControlID(FocusType.Passive);

            switch (Event.current.GetTypeForControl(controlID))
            {
            case EventType.MouseUp:
            {
                if (isClickedComboButton)
                {
                    done = true;
                }
            }
            break;
            }

            if (GUI.Button(rect, buttonContent, buttonStyle))
            {
                if (controlID == -1)
                {
                    controlID            = activeID;
                    isClickedComboButton = false;
                }
                isClickedComboButton = !isClickedComboButton;
                GUI.FocusControl(null);
            }

            if (isClickedComboButton)
            {
                Rect listRect = new Rect(rect.x, rect.y + listStyle.CalcHeight(listContent[0], 1.0f), rect.width, listStyle.CalcHeight(listContent[0], 1.0f) * listContent.Length);
                if (!closeOnOutsideClick(listRect))
                {
                    for (int i = 0; i < _darknessFactor; i++)
                    {
                        GUI.Box(listRect, "", boxStyle);
                    }
                    int newSelectedItemIndex = GUI.SelectionGrid(listRect, selectedItemIndex, listContent, 1, listStyle);
                    if (newSelectedItemIndex != selectedItemIndex)
                    {
                        selectedItemIndex = newSelectedItemIndex;
                        buttonContent     = listContent[selectedItemIndex];
                    }
                }

                if (done)
                {
                    isClickedComboButton = false;
                }
            }
            return(selectedItemIndex);
        }
Example #9
0
        /**
         * <summary>Draws the element using OnGUI</summary>
         * <param name = "_style">The GUIStyle to draw with</param>
         * <param name = "_slot">Ignored by this subclass</param>
         * <param name = "zoom">The zoom factor</param>
         * <param name = "isActive">If True, then the element will be drawn as though highlighted</param>
         */
        public override void Display(GUIStyle _style, int _slot, float zoom, bool isActive)
        {
            if (Application.isPlaying)
            {
                switch (labelType)
                {
                case AC_LabelType.DialogueLine:
                    if (useCharacterColour)
                    {
                        _style.normal.textColor = speechColour;
                    }

                    if (updateIfEmpty || !string.IsNullOrEmpty(newLabel))
                    {
                        if (autoAdjustHeight && sizeType == AC_SizeType.Manual)
                        {
                            GUIContent content = new GUIContent(newLabel);
                            relativeRect.height = _style.CalcHeight(content, relativeRect.width);
                        }
                    }
                    break;

                case AC_LabelType.DialogueSpeaker:
                    if (useCharacterColour)
                    {
                        _style.normal.textColor = speechColour;
                    }
                    break;

                default:
                    break;
                }
            }

            base.Display(_style, _slot, zoom, isActive);

            _style.wordWrap  = true;
            _style.alignment = anchor;
            if (zoom < 1f)
            {
                _style.fontSize = (int)((float)_style.fontSize * zoom);
            }

            if (textEffects != TextEffects.None)
            {
                AdvGame.DrawTextEffect(ZoomRect(relativeRect, zoom), newLabel, _style, Color.black, _style.normal.textColor, outlineSize, textEffects);
            }
            else
            {
                GUI.Label(ZoomRect(relativeRect, zoom), newLabel, _style);
            }
        }
Example #10
0
            protected override void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
            {
                GUIStyle styleWrapped = this.GetStyleWrapped(column.headerTextAlignment);
                float    num          = styleWrapped.CalcHeight(column.headerContent, headerRect.width);
                Rect     position     = headerRect;

                position.yMin += position.height - num - 1f;
                GUI.Label(position, column.headerContent, styleWrapped);
                if (base.canSort && column.canSort)
                {
                    base.SortingButton(column, headerRect, columnIndex);
                }
            }
        public static float GetStyleHeight(this GUIStyle style, string text)
        {
            float max;
            float min;
            var   content = new GUIContent(text);

            style.CalcMinMaxWidth(content, out min, out max);

            return
                (style.padding.top +
                 style.padding.bottom +
                 style.CalcHeight(content, max));
        }
Example #12
0
        public NodeToolTipView(object parent, string toolTip) : base("Tooltip")
        {
            this.parent = parent;
            text        = toolTip;

            style          = skin.label;
            style.padding  = new RectOffset(6, 6, 7, 7);
            style.wordWrap = true;
            float w = StaticMethods.Clamp(style.CalcSize(new GUIContent(toolTip)).x, 1, 200);

            size  = new Vector2(w, style.CalcHeight(new GUIContent(toolTip), w));
            delay = /*80f*/ 5; // why does this throttle?
        }
Example #13
0
        private Vector2 GetSizeVertical(string content)
        {
            m_content.text = content;
            Vector2 size = m_standardNormalStyle.CalcSize(m_content);

            size.x = Mathf.Max(size.x, VERT_MIN_NODE_WIDTH);
            size.y = Mathf.Max(size.y, VERT_MIN_NODE_HEIGHT);
            if (size.x > VERT_MAX_NODE_WIDTH)
            {
                size.x = VERT_MAX_NODE_WIDTH;
                size.y = Mathf.Min(m_standardNormalStyle.CalcHeight(m_content, size.x), VERT_MAX_NODE_HEIGHT);
            }

            size.x += NODE_BORDER;

            float snapSize = BTEditorCanvas.Current.SnapSize * 2;

            size.x = (float)Mathf.Round(size.x / snapSize) * snapSize;
            size.y = (float)Mathf.Round(size.y / snapSize) * snapSize;

            return(size);
        }
Example #14
0
    public static Vector2 CalcSize(string style, string text, float width)
    {
        GUIStyle style2 = GUI.skin.GetStyle(style);
        Vector2  result = style2.CalcSize(new GUIContent(text));

        if (result.x > width)
        {
            float y = style2.CalcHeight(new GUIContent(text), width);
            result.x = width;
            result.y = y;
        }
        return(result);
    }
Example #15
0
 public static bool CalcHeight(GUIStyle __instance, ref float __result, GUIContent content, float width)
 {
     if (allThreads2.TryGetValue(CurrentThread, out ThreadInfo threadInfo))
     {
         Func <object[], object> safeFunction = p => __instance.CalcHeight((GUIContent)p[0], (float)p[1]);
         threadInfo.safeFunctionRequest = new object[] { safeFunction, new object[] { content, width } };
         mainThreadWaitHandle.Set();
         threadInfo.eventWaitStart.WaitOne();
         __result = (float)threadInfo.safeFunctionResult;
         return(false);
     }
     return(true);
 }
Example #16
0
        public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
        {
            float height = 0;

            if (!string.IsNullOrEmpty(noteAttribute.text))
            {
                GUIContent content = new GUIContent(noteAttribute.text);
                GUIStyle   style   = GUI.skin.GetStyle("helpbox");
                height += style.CalcHeight(content, EditorGUIUtility.currentViewWidth);
            }
            height += noteAttribute.margin;
            return(height);
        }
Example #17
0
 private float QuestDescriptionHeight(string quest)
 {
     questBodyStyle = UseGUIStyle(questBodyStyle, questBodyGuiStyleName, GUI.skin.label);
     if (questHeadingSource == QuestHeadingSource.Name)
     {
         openQuestDescription = FormattedText.Parse(QuestLog.GetQuestDescription(quest), DialogueManager.MasterDatabase.emphasisSettings).text;
         return(questBodyStyle.CalcHeight(new GUIContent(openQuestDescription), scrollView.contentWidth - (2 * padding)));
     }
     else
     {
         return(0);
     }
 }
 private float QuestButtonsHeight(QuestInfo questInfo)
 {
     if (questInfo.Trackable || questInfo.Abandonable)
     {
         questButtonStyle          = UseGUIStyle(questButtonStyle, questEntryButtonStyleName, GUI.skin.button);
         questButtonStyle.wordWrap = false;
         return(questButtonStyle.CalcHeight(new GUIContent("Abandon"), scrollView.contentWidth - (2 * padding)));
     }
     else
     {
         return(0);
     }
 }
Example #19
0
        public override float GetHeight(SerializedObject serializedObject)
        {
            var attrib = this.Attribute as RequireLayerAttribute;

            if (attrib == null)
            {
                return(0f);
            }

            GUIStyle style = GUI.skin.GetStyle("HelpBox");

            return(Mathf.Max(40f, style.CalcHeight(EditorHelper.TempContent("This component requires the current layer to be set to '" + LayerMask.LayerToName(attrib.Layer) + "'."), EditorGUIUtility.currentViewWidth)));
        }
Example #20
0
    void OnGUI()
    {
        float margin      = 0.025f * Screen.height;
        float smallMargin = 0.0125f * Screen.height;

        float   bottomMargin = 0.05f * Screen.height;
        Vector2 buttonSize   = new Vector2(0.1f * Screen.width, 0.05f * Screen.height);

        // Next
        if (GUI.Button(new Rect(0.5f * Screen.width + margin, Screen.height - bottomMargin - buttonSize.y, buttonSize.x, buttonSize.y), "Next"))
        {
            activeObjectIdx++;
            if (activeObjectIdx >= objects.Length)
            {
                activeObjectIdx = 0;
            }

            SetActiveObject(objects[activeObjectIdx]);
        }

        // Previous
        if (GUI.Button(new Rect(0.5f * Screen.width - margin - buttonSize.x, Screen.height - bottomMargin - buttonSize.y, buttonSize.x, buttonSize.y), "Previous"))
        {
            activeObjectIdx--;
            if (activeObjectIdx < 0)
            {
                activeObjectIdx = objects.Length - 1;
            }

            SetActiveObject(objects[activeObjectIdx]);
        }

        UpdateMeshInfo();

        GUIStyle style = GUI.skin.label;

        float height = style.CalcHeight(new GUIContent("ABC"), Screen.width);
        Rect  rect   = new Rect(0.0f, 0.0f, Screen.width, height);

        style.fontStyle = FontStyle.Bold;
        GUI.Label(rect, new GUIContent(activeObject.name.ToString()));
        style.fontStyle = FontStyle.Normal;
        rect.y          = rect.yMax + smallMargin;
        GUI.Label(rect, new GUIContent("LOD Count: " + lodCount.ToString()));
        rect.y = rect.yMax + smallMargin;
        GUI.Label(rect, new GUIContent("Mesh Count (LOD 0): " + meshCount.ToString()));
        rect.y = rect.yMax + smallMargin;
        //GUI.Label(rect, new GUIContent("Total Vertex Count: " + totalVertexCount.ToString()));
        //rect.y = rect.yMax + smallMargin;
        GUI.Label(rect, new GUIContent("Total Tris: " + (totalTriangles / 3)));
    }
Example #21
0
    void OnGUI()
    {
        if (active && alpha > 0)
        {
            Vector2 scaledOffset = new Vector2(offset.x * transform.lossyScale.x, offset.y * transform.lossyScale.y);
            Vector2 screenPos    = RectTransformUtility.WorldToScreenPoint(ChartEditor.Instance.uiServices.uiCamera, ((Vector2)transform.position + scaledOffset));
            screenPos.y = Screen.height - screenPos.y;      // Alter for GUI label position

            // Apply matrix transformations
            const float NATIVE_WIDTH  = 1920.0f;
            const float NATIVE_HEIGHT = 1080.0f;
            float       rx            = Screen.width / NATIVE_WIDTH;
            float       ry            = Screen.height / NATIVE_HEIGHT;
            GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(rx, ry, 1));

            // Apply fading
            GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, alpha);

            // Calculate the size of the textbox
            Vector2 size = style.CalcSize(new GUIContent(localisedMessage));
            size.x += 1;        // Some weird Unity 2018 thing is cutting text off by a single pixel. Thanks Unity.
            if (size.x > MAX_TEXTBOX_WIDTH)
            {
                size.x = MAX_TEXTBOX_WIDTH;
                size.y = style.CalcHeight(new GUIContent(localisedMessage), MAX_TEXTBOX_WIDTH);
            }

            // Check if the box is going to appear offscreen and fix
            if (screenPos.x < 0)
            {
                screenPos.x = 0;
            }

            if (screenPos.x + size.x * rx > Screen.width)
            {
                screenPos.x = Screen.width - size.x * rx;
            }

            if (screenPos.y < 0)
            {
                screenPos.y = 0;
            }

            if (screenPos.y + size.y * ry > Screen.height)
            {
                screenPos.y = Screen.height - size.y * ry;
            }

            GUI.Label(new Rect(screenPos.x / rx, screenPos.y / ry, size.x, size.y), localisedMessage, style);
        }
    }
Example #22
0
        private void PreviewLog(int r_, LogEntry entry_)
        {
            if (!_logPref.TryGetValue(entry_.level, out var pref))
            {
                pref = _logPref[LogStream.custom];
            }
            if (!pref.show ||
                (_filterKeep.Count > 0 && _filterKeep.All(s => !entry_.content.Contains(s))) ||
                (_filterRemove.Count > 0 && _filterRemove.Any(s => entry_.content.Contains(s)))
                )
            {
                return;
            }
            float size = _fullLogPreview || selected == r_
                ? Max(_styleLogPreview.CalcHeight(new GUIContent(entry_.content), _logPreviewWidth), logLineHeight)
                : logLineHeight;

            var logStart = _scrollSize;

            _scrollSize += size;
            Space(size);
            if (_scrollSize < _scrollStart || logStart > _scrollEnd)
            {
                goto end;
            }
            var rect = new Rect(logTypeTexSize + 1, logStart, position.width - logTypeTexSize - 1, size);

            if (selected == r_)
            {
                GUI.DrawTexture(rect, _texSelectedBG);
            }
            if (GUI.Button(rect, entry_.content, _styleLogPreview))
            {
                Select(r_);
            }
            rect.x     = 0;
            rect.width = logTypeTexSize;
            if (pref.tex == null)
            {
                RefreshConfig();
            }
            GUI.DrawTexture(rect, pref.tex);
            rect.x    += rect.width;
            rect.width = 1;
            GUI.DrawTexture(rect, _texLine);
end:
            if (selected == r_ && _selectionChanged && Event.current.type == EventType.Repaint)
            {
                _selectionRect = GUILayoutUtility.GetLastRect();
            }
        }
Example #23
0
        private void OnGUI()
        {
            if (mainCam == null)
            {
                mainCam = Camera.main;
            }
            if (DisplayTime > 0)
            {
                constantViewTime += Time.deltaTime;
                Vector3 pos = mainCam.WorldToScreenPoint(transform.position);
                pos.y = Screen.height - pos.y;

                Rect r = new Rect(0, 0, 400 * MainMenu.Instance.rr, 200 * MainMenu.Instance.rr)
                {
                    center = pos
                };
                label = item.name;
                if (constantViewTime > 0.5f && amount > 1)
                {
                    label += " \n x" + amount;
                }
                if (constantViewTime > 1f)
                {
                    label += " \n Level " + item.level;
                    if (lifetime < 61)
                    {
                        label += " \n Deleting in " + lifetime.ToString();
                    }
                }

                GUIStyle style = new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.UpperCenter, font = MainMenu.Instance.MainFont, fontSize = Mathf.RoundToInt(40 * MainMenu.Instance.rr)
                };
                float height = style.CalcHeight(new GUIContent(label), r.width);
                style.margin = new RectOffset(10, 10, 10, 10);
                Rect bg = new Rect(r)
                {
                    height = height
                };
                GUI.color = new Color(MainMenu.RarityColors[item.Rarity].r, MainMenu.RarityColors[item.Rarity].g, MainMenu.RarityColors[item.Rarity].b, DisplayTime);
                GUI.Box(bg, string.Empty);
                GUI.Label(r, label, style);
                GUI.color    = new Color(1, 1, 1, 1);
                DisplayTime -= Time.deltaTime;
            }
            else
            {
                constantViewTime = 0;
            }
        }
            public override Vector2 GetWindowSize()
            {
                if (_height == 0f)
                {
                    InitializeStyles();

                    List <GeneratorTreeItem> items;

                    if (_openCategory == null)
                    {
                        items = _generatorTree;

                        _height += _titleStyle.CalcHeight(GUIContent.none, _width);
                    }
                    else
                    {
                        items = _openCategory.items;

                        _height += _titleStyle.CalcHeight(GUIContent.none, _width);
                    }

                    foreach (var item in items)
                    {
                        if (item is GeneratorTreeCategory)
                        {
                            var category = (GeneratorTreeCategory)item;
                            _height += _categoryStyle.CalcHeight(category.content, _width);
                        }
                        else if (item is GeneratorTreeGenerator)
                        {
                            var generator = (GeneratorTreeGenerator)item;
                            _height += _generatorStyle.CalcHeight(generator.content, _width);
                        }
                    }
                }

                return(new Vector2(_width, _height));
            }
Example #25
0
        public static void CheckLayer()
        {
            Handles.BeginGUI();

            checkLayer = LayerMask.NameToLayer("Player");
            var rect = new Rect();

            if (checkLayer != 8 || !IsAxisAvailable("LeftAnalogHorizontal"))
            {
                if (style == null)
                {
                    style           = new GUIStyle(EditorStyles.whiteLabel);
                    style.fontSize  = 30;
                    style.alignment = TextAnchor.MiddleCenter;
                    style.fontStyle = FontStyle.Bold;
                    style.wordWrap  = true;
                    style.clipping  = TextClipping.Overflow;
                }

                var color = GUI.color;
                GUI.color = Color.black * 0.5f;

                string myString = "Missing ProjectSettings\nGo to the Menu Invector/Import ProjectSettings";
                GUILayout.Space(-20);
                GUILayout.Box("", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                rect = GUILayoutUtility.GetLastRect();
                var height = style.CalcHeight(new GUIContent(myString), rect.width);
                rect.y     += (rect.height / 2f) - height / 2f;
                rect.height = height;

                GUI.color = color;
                GUI.Label(rect, myString, style);

                var buttonRect = rect;
                buttonRect.y     += rect.height + 20f;
                buttonRect.x      = rect.width / 2f;
                buttonRect.x     -= (rect.width * 0.2f) / 2f;
                buttonRect.width  = rect.width * 0.2f;
                buttonRect.height = 25f;

                //if (GUI.Button(buttonRect, "Import ProjectSettings"))
                //{
                //    SceneView.onSceneGUIDelegate -= OnScene;
                //    AssetDatabase.ImportPackage(vInvectorWelcomeWindow._projectSettingsPath, true);
                //    EditorApplication.delayCall += ResetMethod;
                //}
            }

            Handles.EndGUI();
        }
            protected override void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
            {
                GUIStyle style = GetStyleWrapped(column.headerTextAlignment);

                float labelHeight = style.CalcHeight(column.headerContent, headerRect.width);
                Rect  labelRect   = headerRect;

                labelRect.yMin += labelRect.height - labelHeight - 1;
                GUI.Label(labelRect, column.headerContent, style);
                if (canSort && column.canSort)
                {
                    SortingButton(column, headerRect, columnIndex);
                }
            }
Example #27
0
    void showTooltip()
    {
        if (GUI.tooltip.Equals(""))
        {
            return;
        }

        float    mouseX   = Input.mousePosition.x;
        float    mouseY   = Screen.height - Input.mousePosition.y;
        GUIStyle style    = skin.GetStyle("tooltip");
        float    height   = style.CalcHeight(new GUIContent(GUI.tooltip), 190f);
        float    maxWidth = 0;
        float    minWidth = 0;

        style.CalcMinMaxWidth(new GUIContent(GUI.tooltip), out minWidth,
                              out maxWidth);
        float yOffset = 0;
        float xOffset = 0;

        if (mouseY + height > Screen.height)
        {
            yOffset = mouseY + height - Screen.height;
        }
        if (mouseX + 210 > Screen.width)
        {
            xOffset = 220;
        }

        if (mouseX + maxWidth + 18 > Screen.width)
        {
            xOffset = maxWidth + 31;
        }
        else
        {
            xOffset = 0;
        }
        int    nameLength  = GUI.tooltip.IndexOf('\n');
        string itemName    = GUI.tooltip.Substring(0, nameLength);
        string description = GUI.tooltip.Replace(itemName + '\n', "");

        GUI.Box(new Rect(mouseX + 11 - xOffset, mouseY - yOffset - 7,
                         maxWidth + 18, height + 14), "");
        GUI.Label(new Rect(mouseX + 20 - xOffset, mouseY - yOffset,
                           160, 23), itemName, "tooltip");
        skin.FindStyle("tooltip").normal.textColor = Color.yellow;
        GUI.Label(new Rect(mouseX + 20 - xOffset, mouseY + 17 - yOffset,
                           160, height - 23), description, "tooltip");
        skin.FindStyle("tooltip").normal.textColor = new Color(203f / 255f,
                                                               220f / 255f, 220f / 255f);
    }
Example #28
0
    /// <summary>
    /// InfoBoxの高さを取得する
    /// </summary>
    /// <returns>InfoBoxの高さ</returns>
    public float GetInfoBoxHeight()
    {
        // GUI要素のスタイル情報を作成する
        var style = new GUIStyle("HelpBox");
        // GUIに何をレンダリングするかの情報を作成する
        var content = new GUIContent(InfoBoxAttribute.message);
        // InfoMessageTypeがNoneなら21,それ以外なら53をメッセージのサイズにする
        var infoMessageSize = InfoBoxAttribute.type != InfoMessageType.None ? 53 : 21;
        // contentとinfoMessageSizeを使用してレンダリングした時の高さ
        var calcHeight = style.CalcHeight(content, Screen.width - infoMessageSize);

        // レンダリングした時の高さと40で大きい方を高さとして返す(最低の高さを40にする)
        return(Mathf.Max(calcHeight, 40));
    }
Example #29
0
    public void doGUI(float left, float right)
    {
        this.left  = left;
        this.right = right;
        if (needsScrollSet)
        {
            setScrollPosition();
            needsScrollSet = false;
            hasScroller    = getHeight(left, right) > consoleHeight;
        }
        if (GameGUI.mapGenerator.isInCharacterPlacement())
        {
            return;
        }
        GUIStyle st           = getLogMessageStyle(Color.white);
        float    consoleWidth = Screen.width;
        float    height       = getHeight(left, right);
        float    width        = consoleWidth - left - right - 5.0f;
        float    consoleX     = 0.0f;
        float    x            = left + 5.0f;
        float    y            = Screen.height - consoleHeight;
        Rect     logRect      = new Rect(consoleX, y, consoleWidth, consoleHeight);

        y += 2.0f;
        //	GUIStyle boxStyle = new GUIStyle("Box");
        //	boxStyle.normal.background = boxStyle.active.background = boxStyle.hover.background = logTexture as Texture2D;
        //	GUI.Box(logRect,"", boxStyle);
        float lX         = logRect.x;
        float textWidth  = 775;
        int   textHeight = 259;

        //	Debug.Log(logRect.width + logRect.x);
        while (lX < logRect.width + logRect.x)
        {
            GUI.DrawTexture(new Rect(lX, logRect.y, textWidth, textHeight), logTexture as Texture2D);
            lX += textWidth;
            //	Debug.Log("logX: " + logX);
        }
        scrollPosition = GUI.BeginScrollView(new Rect(x, y, width, consoleHeight - 4.0f), scrollPosition, new Rect(x, y, width - 16.0f, height));
        y += logY;
        x += logX;
        foreach (LogMessage s in messages)
        {
            st = getLogMessageStyle(s.color);
            float h = st.CalcHeight(s.message, width - 16.0f);
            GUI.Label(new Rect(x, y, width - 16.0f, h), s.message, st);
            y += h;
        }
        GUI.EndScrollView();
    }
Example #30
0
        public override float GetHeight(SerializedObject serializedObject)
        {
            var attrib = this.Attribute as RequireColliderAttribute;

            if (attrib == null || this.Validate(serializedObject))
            {
                return(0f);
            }
            else
            {
                GUIStyle style = GUI.skin.GetStyle("HelpBox");
                return(Mathf.Max(40f, style.CalcHeight(EditorHelper.TempContent(string.Format(MSG_FRM, this.ComponentType.Name)), EditorGUIUtility.currentViewWidth)));
            }
        }