/// <summary> /// Makes sure the guiStyle property is up-to-date. /// </summary> protected void SetGUIStyle() { if (guiStyle == null) { guiStyle = UnityGUITools.GetGUIStyle(guiStyleName, DefaultGUIStyle); } }
private void DrawQuests() { if ((quests != null) && (scrollView != null)) { float contentY = padding; foreach (string quest in quests) { float headingHeight = QuestHeadingHeight(quest); if (GUI.Button(new Rect(padding, contentY, scrollView.contentWidth - (2 * padding), headingHeight), QuestHeading(quest), questHeadingStyle)) { openQuest = string.Equals(quest, openQuest) ? null : quest; } contentY += headingHeight; if (string.Equals(quest, openQuest)) { contentY = DrawQuestDescription(quest, contentY); contentY = DrawQuestEntries(quest, contentY); } } if (quests.Length == 0) { string description = (questStateToShow == QuestState.Active) ? noActiveQuestsMessage : noCompletedQuestsMessage; GUIStyle noQuestsStyle = UnityGUITools.GetGUIStyle(noQuestsGuiStyleName, GUI.skin.label); float descriptionHeight = noQuestsStyle.CalcHeight(new GUIContent(description), scrollView.contentWidth - 4); GUI.Label(new Rect(2, contentY, scrollView.contentWidth, descriptionHeight), description, noQuestsStyle); contentY += descriptionHeight; } } }
private void DrawQuests() { if ((scrollView != null)) { float contentY = padding; foreach (var questInfo in Quests) { 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; } } }
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; } } }
/// <summary> /// Draws the bark text using Unity GUI. /// </summary> public virtual void OnGUI() { GUI.skin = UnityGUITools.GetValidGUISkin(guiSkin); if (guiStyle == null) { guiStyle = UnityGUITools.ApplyFormatting(formattingToApply, new GUIStyle(UnityGUITools.GetGUIStyle(guiStyleName, GUI.skin.label))); guiStyle.alignment = TextAnchor.UpperCenter; size = guiStyle.CalcSize(new GUIContent(message)); if ((maxWidth >= 1) && (size.x > maxWidth)) { size = new Vector2(maxWidth, guiStyle.CalcHeight(new GUIContent(message), maxWidth)); } } UpdateBarkPosition(); guiStyle.normal.textColor = UnityGUITools.ColorWithAlpha(guiStyle.normal.textColor, alpha); if (screenPos.z < 0) { return; } Rect rect = new Rect(screenPos.x - (size.x / 2), (Screen.height - screenPos.y) - (size.y / 2), size.x, size.y); UnityGUITools.DrawText(rect, message, guiStyle, textStyle, textStyleColor); }
private GUIStyle UseGUIStyle(GUIStyle guiStyle, string guiStyleName, GUIStyle defaultStyle) { return((guiStyle != null) ? guiStyle : UnityGUITools.GetGUIStyle(guiStyleName, defaultStyle)); }