public void CreatingText(string text) { FloatingText instance = Instantiate(screenText); instance.transform.SetParent(this.transform, false); instance.GetComponent <FloatingText>().SetText(text); instance.GetComponent <FloatingText>().button.onClick.AddListener(Flag); }
private void OnFloatingTextCreator(object sender, MessageArgs args) { FloatingText go = Instantiate(textPref, args.Position, Quaternion.identity) as FloatingText; go.transform.SetParent(_canvasTrans); go.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); go.Initialize(floatingTextSpeed, new Vector3(0, 1, 0), 3); go.GetComponent <Text>().text = args.Msg; go.GetComponent <Text>().color = args.MsgColor; }
public virtual void ShowFloatingText(string text, Color color, float dTime = 1, float sSpeed = 15, float sizeMult = 1.0f) { FloatingText floatingText = GameObject.Instantiate(Resources.Load <FloatingText>("Prefabs/UI/FloatingText") as FloatingText, Position, Quaternion.identity); floatingText.SetOffset(Vector3.up * (Body.mAABB.HalfSize.y * 2 + 10)); floatingText.text.characterSize = floatingText.text.characterSize * sizeMult; floatingText.duration = dTime; floatingText.scrollSpeed = sSpeed; floatingText.GetComponent <TextMesh>().text = "" + text; floatingText.GetComponent <TextMesh>().color = color; }
public static void CreateFloatingText(string text, Transform location) { //return; if (pause) { return; } if (popupText == null) { Initialize(); } FloatingText instance = Instantiate(popupText); try { instance.transform.SetParent(canvas.transform, false); }catch (System.Exception e) { Initialize(); instance.transform.SetParent(canvas.transform, false); } Vector2 screenPosition = Camera.main.WorldToScreenPoint(new Vector2(location.position.x + Random.Range(-.5f, .5f), location.position.y + Random.Range(-.5f, .5f))); instance.transform.position = screenPosition; instance.GetComponent <FloatingText>().SetText(text); }
public void EatGhost(Vector3 position) { AddScore(ghostScores[eatenGhostCount]); Vector2 floatingPosition = gameCamera.WorldToScreenPoint(position); floatingPosition.x += gameScreen.rectTransform.offsetMin.x; floatingPosition.y += gameScreen.rectTransform.offsetMin.y; FloatingText scoreValue = Instantiate(scoreValuePrefab); scoreValue.transform.SetParent(canvas.transform); scoreValue.transform.localScale = new Vector3(1, 1, 1); scoreValue.GetComponent <RectTransform>().anchoredPosition = floatingPosition; scoreValue.Print(ghostScores[eatenGhostCount].ToString()); if (eatenGhostCount + 1 < ghostScores.Length) { eatenGhostCount++; } }
public void CreateFloatingText(Transform transform, string text) { FloatingText floatText = GameObject.Instantiate(floatingTextPrefab, transform.position, Quaternion.identity); floatText.GetComponent <TextMeshPro>().text = text; }