InteractionToast SpawnInteractionToast() { InteractionToast it = Instantiate(interactionTextPrefab, transform); it.SetToastActive(false); interactionToastList.Add(it); return(it); }
InteractionToast GetInteractionToast() { InteractionToast it = null; foreach (InteractionToast toast in interactionToastList) { if (!toast.IsActive()) { it = toast; break; } } return(it); }
/// <summary> /// interaction types: 0-damage 1-armour 2-modify damage 3-modify health /// </summary> /// <param name="interactionType"></param> public void ToastInteraction(Vector3 screenPosition, float value, int interactionType, string prefix) { /// interaction types 0-damage 1-armour 2-modifyStats InteractionToast toast = GetInteractionToast(); if (toast == null) { toast = SpawnInteractionToast(); } Sprite interationSprite = interactionSpriteArray[interactionType]; Color interactionColor = interactionColorArray[interactionType]; Vector3 interactionOffset = interactionOffsetArray[interactionType]; toast.SetInteractionDetails(interationSprite, prefix + value.ToString("F0"), interactionColor, interactionOffset); Vector3 toastPosition = screenPosition; toast.transform.position = toastPosition; toast.SetToastActive(true); }