public static void Create(string text, Vector2 position) { if (prefab == null) { prefab = Resources.Load <GameObject>("Prefabs/Scrolling Popup"); } ScrollingPopup scrollingPopup = ObjectPool.Spawn(prefab, Vector3.zero, Quaternion.identity).GetComponent <ScrollingPopup>(); scrollingPopup.transform.SetParent(UIManager.Instance.HudObject.transform); scrollingPopup.transform.position = Camera.main.WorldToScreenPoint(new Vector2(position.x + Random.Range(-0.5f, 0.5f), position.y + Random.Range(-0.5f, 0.5f))); scrollingPopup.Text.text = text; }
private void OnTriggerEnter2D(Collider2D collider) { if (collider.tag != "Segment") { return; } if (collider.name == Enum.GetName(typeof(EnemyType), type)) { GameManager.Current.Points += points; ScrollingPopup.Create("+1 Point!", transform.position); } else { GameManager.Current.Lives -= 1; ScrollingPopup.Create("-1 Life!", transform.position); } ObjectPool.Destroy(gameObject); }