void RenderPrompt() { UIPrompt closest = null; float closestDistance = 0; foreach (KeyValuePair <Transform, UIPrompt> prompt in prompts) { float distance = Vector3.Distance(player.position, prompt.Key.position); if (closest == null || distance < closestDistance) { closest = prompt.Value; closestDistance = distance; } } if (currentPrompt != closest) { if (currentPrompt != null) { currentPrompt.DestroyCanvas(); currentPrompt = null; } if (closest != null) { currentPrompt = closest; currentPrompt.CreateCanvas(); } } }
public void RemovePrompt(UIPrompt prompt, Transform location) { if (prompts.TryGetValue(location, out UIPrompt value)) { prompts.Remove(location); } }
public void AddPrompt(UIPrompt prompt, Transform location) { if (!prompts.TryGetValue(location, out UIPrompt value)) { prompts.Add(location, prompt); } }
private void UMHSInteractionCopyUIModel_Validating(object sender, ValidatingEventArgs e) { if (this.INTERACTIONS.Value.Count > 0) { var prompt = new UIPrompt(); prompt.Text = "Copy iteraction complete"; prompt.ButtonStyle = UIPromptButtonStyle.Ok; prompt.ImageStyle = UIPromptImageStyle.Information; this.Prompts.Add(prompt); } }
public void SetData(string title, string content, List <UIPromptInfo> promptInfo) { m_TitleLabel.text = title; m_ContentText.text = content; for (int i = 0; i < promptInfo.Count; i++) { GameObject promptObj = (GameObject)Instantiate(m_PromptPrefab, m_PromptsBar); UIPrompt prompt = promptObj.GetComponent <UIPrompt>(); if (prompt != null) { prompt.SetIcon(promptInfo[i].m_IconSprite); // TODO need a way to associate the icons with the input so that they can be set together prompt.SetLabel(promptInfo[i].m_LabelText); } } }
// set the current screen prompts public virtual void SetPrompts(Transform parent, GameObject prefab, List <UIPromptInfo> newPrompts) { for (int i = 0; i < newPrompts.Count; i++) { GameObject promptObj = (GameObject)Instantiate(prefab, parent); UIPrompt prompt = promptObj.GetComponent <UIPrompt>(); if (prompt != null) { prompt.SetIcon(newPrompts[i].m_IconSprite); prompt.SetLabel(newPrompts[i].m_LabelText); } else { Debug.LogErrorFormat("No prompt script attached to {0} on the {1} screen.", promptObj.name, name); } } }