public ulong ShowNewDialog(string text) { ulong returnId = 0; if ((allDialogs != null) && (allDialogs.Length > 0) && (hiddenDialogs.Count > 0)) { // Find a new dialog PopUpDialog newDialog = hiddenDialogs.Dequeue(); // Set the dialog's unique ID newDialog.ID = NextId; // Update dialog text newDialog.Label.CurrentText = text; allLoggedTexts.Add(newDialog.ID, text); // Update the dialog's transform newDialog.CachedTransform.SetAsLastSibling(); newDialog.CachedTransform.anchoredPosition = startingPosition; newDialog.TargetAnchorPosition = startingPosition; // Show the dialog newDialog.Show(); //// Check if pop-ups are supposed to be visible //if (IsPopUpEnabled == true) //{ // // Show the dialog // newDialog.Show(); //} //else //{ // // Queue the dialog to show later // delayedShowDialogs.Add(newDialog); // if (everyFrame == null) // { // everyFrame = new System.Action<float>(EveryFrame); // Singleton.Instance.OnUpdate += everyFrame; // } //} // Keep track of the new dialog visibleDialogs.Insert(0, newDialog); // Check to see if we reached the max number of dialogs if (visibleDialogs.Count > maxNumberOfDialogs) { // If so, hide the last dialog RemoveLastVisibleDialog(false); } // Return this dialog's ID returnId = newDialog.ID; // Indicate dialogs need to be re-positioned repositionDialogs = true; } return(returnId); }
void HideDialog(PopUpDialog removeDialog) { // Hide the dialog removeDialog.Hide(); // Push it back to the hidden dialog list hiddenDialogs.Enqueue(removeDialog); // Indicate dialogs need to be re-positioned repositionDialogs = true; }
void AppendDialogs(float yPosition) { // Check to see if there's more texts to display if ((allDialogs != null) && (allDialogs.Length > 0) && (allLoggedTexts.Count > visibleDialogs.Count)) { // Calculate position targetPosition.y = yPosition; // Append dialogs while ((allLoggedTexts.Count > visibleDialogs.Count) && (visibleDialogs.Count < maxNumberOfDialogs) && (hiddenDialogs.Count > 0)) { // Find the string to display index = 0; foreach (KeyValuePair <ulong, string> info in allLoggedTexts) { if (index >= visibleDialogs.Count) { // Find a new dialog PopUpDialog newDialog = hiddenDialogs.Dequeue(); // Set the dialog's unique ID newDialog.ID = info.Key; // Update dialog text newDialog.Label.CurrentText = info.Value; // Update the dialog's transform newDialog.CachedTransform.SetAsFirstSibling(); newDialog.CachedTransform.anchoredPosition = targetPosition; newDialog.TargetAnchorPosition = targetPosition; // Show the dialog newDialog.Show(); visibleDialogs.Add(newDialog); // Indicate dialogs need to be re-positioned repositionDialogs = true; break; } ++index; } // This shouldn't happen, but in case we don't find the string to display, stop appending dialogs if (index >= allLoggedTexts.Count) { break; } } } }
float YPositionBelow(PopUpDialog dialog) { float returnYPos = startingPosition.y; if (dialog != null) { returnYPos = dialog.TargetAnchorPosition.y; if (dialog.Height > 0) { returnYPos -= dialog.Height; returnYPos -= spacing; } } return(returnYPos); }