// For drawing temporary text on the screen public void addTempText(string text, Vector2 textGridPos, float duration) { GameObject textObj = GameObject.Instantiate(popupTextPrefab) as GameObject; textObj.transform.parent = transform; tk2dTextMesh textToAdd = textObj.GetComponent <tk2dTextMesh>(); TemporaryText tempText = textObj.AddComponent <TemporaryText>(); tempText.timeVisible = duration; float textX = textGridPos.x; if (textX < 2) { textX = 2; } if (textX > 13) { textX = 13; } float textY = textGridPos.y + 1; _popupText.anchor = TextAnchor.LowerCenter; if (textY > Globals.ROOM_HEIGHT - 2) { textY = textGridPos.y; _popupText.anchor = TextAnchor.UpperCenter; } Vector2 actualPos = toActualCoordinates(new Vector2(textX, textY)); textToAdd.transform.localPosition = new Vector3(actualPos.x, actualPos.y - Globals.CELL_SIZE / 2, textToAdd.transform.localPosition.z); textToAdd.text = text; textToAdd.Commit(); textToAdd.gameObject.SetActive(true); }
private static TemporaryText CreateBuffCaption() { TemporaryText result = TemporaryText.Create(); result.gameObject.name = "text_BuffCaption"; SetRectTransformSize(result.gameObject, itemSize_BuffCaption); return(result); }
private static new GameWarning Create() { GameWarning result = TemporaryText.Create <GameWarning>(); result.gameObject.transform.SetParent(Design.visibleArea.transform); Utils.ProvideCanvas(result.gameObject); RectTransform rt = result.gameObject.transform as RectTransform; RectTransform rtp = result.gameObject.transform.parent as RectTransform; rt.offsetMin = (rtp.offsetMax - rtp.offsetMin - size) / 2; rt.offsetMax = rt.offsetMin + size; return(result); }