/// <summary> /// To create a text, call TextManager.Create<typeoftext>Text(string Text, Transform location, float? range). /// location is the position of the created text, range is a random range x interal which the text will be created around. /// To change text, call TextManager.SetText(string text); ///</summary> static TextManager() { GameObject screen_canvas = Resources.Load <GameObject>("Prefabs/Text/ScreenCanvas"); if (screen_canvas == null) { Debug.LogError("Could not load canvas resources"); } m_screen_canvas = Instantiate(screen_canvas); m_world_canvas = Resources.Load <GameObject>("Prefabs/Text/WorldCanvas"); if (m_world_canvas == null) { Debug.LogError("Could not load canvas resources"); } m_damage_text = Resources.Load <APopupText>("Prefabs/Text/DamageTextParent"); if (m_damage_text == null) { Debug.LogError("Could not load damage text prefab"); } m_conversation_text = Resources.Load <APopupText>("Prefabs/Text/ConversationTextParent"); if (m_conversation_text == null) { Debug.LogError("Could not load conversation text prefab"); } m_yell_text = Resources.Load <APopupText>("Prefabs/Text/YellTextParent"); if (m_yell_text == null) { Debug.LogError("Could not load yell text prefab"); } }
void FixedUpdate() { m_time += Time.deltaTime; m_time_2 += Time.deltaTime; if (m_time > 0.1) { m_time = 0; if (m_test_dmg == true) { TextManager.CreateDamageText(Random.Range(-10, 10).ToString(), this.transform, 0.5f); } else { TextManager.CreateHealText(Random.Range(-10, 10).ToString(), this.transform, 0.5f); } } if (m_time_2 >= 1) { m_time_2 = 0; iteration++; if (iteration == 3) { conversation = TextManager.CreateConversationText("TESTING", this.transform); } if (iteration == 6) { conversation.SetText("This"); m_test_dmg = false; } if (iteration == 9) { conversation.SetColor(TextManager.DAMAGE_COLOR); conversation.SetText("asdasdasdasd asd asdasdasdasdas asddasdasdasdasdasdasd sdas asd"); } if (iteration == 14) { m_test_dmg = true; conversation.DestroyText(); TextManager.CreateYellText("ARGH", this.transform); } if (iteration == 18) { iteration = 0; } } }
/// <summary> /// To create a text, call TextManager.Create<typeoftext>Text(string Text, Transform location, float? range). /// location is the position of the created text, range is a random range x interal which the text will be created around. /// To change text, call TextManager.SetText(string text); ///</summary> static TextManager() { GameObject screen_canvas = PrefabRepository.instance.TextManagerScreenCanvas; if (screen_canvas == null) { Debug.LogError("Could not load canvas resources"); } m_screen_canvas = Instantiate(screen_canvas); m_damage_text = PrefabRepository.instance.DamageTextParent; if (m_damage_text == null) { Debug.LogError("Could not load damage text prefab"); } }
private static APopupText CreatePopupText(string text, Transform transform, APopupText popuptext, Color32 color, bool attach_to_object = false, float pad_x = 0, float pad_y = 0) { APopupText instance = Instantiate(popuptext); Vector2 screen; screen = Camera.main.WorldToScreenPoint(new Vector2(transform.position.x + pad_x, transform.position.y + pad_y)); if (!m_screen_canvas) { GameObject screen_canvas = PrefabRepository.instance.TextManagerScreenCanvas; m_screen_canvas = Instantiate(screen_canvas); } instance.transform.SetParent(m_screen_canvas.transform, false); instance.transform.position = screen; instance.SetText(text); instance.SetColor(color); return(instance); }