New answers tagged

0

Welp, seems a bunch of RegEx works... if (Pattern.matches("[A-Za-z0-9\\s_\\+\\-\\.,!@#\\$%\\^&\\*\\(\\);\\\\/\\|<>\"'\\[\\]\\?=]", String.valueOf(Keyboard.getEventCharacter()))) { value += Keyboard.getEventCharacter(); }


0

Attach this script to the "UI Text prefab" that you are creating Dynamically. using UnityEngine; using UnityEngine.EventSystems; public class TextClick : MonoBehaviour,IPointerClickHandler { #region IPointerClickHandler implementation public void OnPointerClick (PointerEventData eventData) { if (eventData.button == ...


0

Add this where you add the code to the string: value += String.valueOf(Keyboard.getEventCharacter()); value = value .replaceAll("[^\\w\\s\\]","");


0

If it's a bitmap font, you need to make sure that the letters in the sprite sheet are white so that colors will be applied correctly with Unity's default text shader. Most tools, including Unity's "Create Editable Copy," create black letters, but this will lead to the exact symptoms you describe. If you have an existing sprite sheet with black letters, you ...


0

You need to check for Character.isLetterOrDigit(char), and if it returns false, skip it.


0

I suppose that when you create the UI Text objects, you are adding to them a RectTransform component, just like I answered you here: How to dynamically create an UI text Object in Unity 5?. Knowing that, one simple and very efficient solution for what you want is to detect if the desired mouse button was pressed AND if mouse cursor is over the RecTransform ...


4

I think what you are looking for is something like following: GameObject CreateText(Transform canvas_transform, float x, float y, string text_to_print, int font_size, Color text_color) { GameObject UItextGO = new GameObject("Text2"); UItextGO.transform.SetParent(canvas_transform); RectTransform trans = ...


2

If you are looking for a quick&dirty solution for debugging, you can still use the old Unity 4 solution. Implement the OnGUI event of any MonoBehavior you have always active to call the GUI class to add some UI element to the current rendering frame. void OnGUI() { GUI.Label(new Rect(10, 10, 100, 20), "Hello World!"); } If you want to use the ...


2

1 do you mean you want change the uitext dynamically? If you want to change it, first u have to attach your script to gameobject. Then bind your variables. Tutorials could be found here transform.gameObject.GetComponent<Text>().text = "123"; 2 If you want to create uitext which is not in Hierarchy beforehand. You could use GUI. GUI Label Put ...


1

First of all if you don't already know the basics of Java, you should learn them first. :) When you have, you will need some kind of graphics library. I know that LWJGL is a good graphics library. LWJGL Link :) According to some people over at stack overflow, Minecraft was made with this. But, as I said it's probably best (if you don't already know ...



Top 50 recent answers are included