public static void AddInputField(MenuCommand menuCommand) { GameObject inputFieldGO = DefaultControls.CreateInputField(GetStandardResources()); InputField inputField = inputFieldGO.GetComponent <InputField>(); var textChild = inputFieldGO.transform.FindChild("Text").gameObject; var text = textChild.GetComponent <Text>(); Object.DestroyImmediate(text); UnivText unvText = textChild.AddComponent <UnivText>(); unvText.text = ""; unvText.color = Color.black; unvText.supportRichText = false; inputField.textComponent = unvText; var placeholderChild = inputFieldGO.transform.FindChild("Placeholder").gameObject; var placeholderText = placeholderChild.GetComponent <Text>(); Object.DestroyImmediate(placeholderText); UnivText placeholderUnvText = placeholderChild.AddComponent <UnivText>(); placeholderUnvText.text = "הכנס טקסט..."; placeholderUnvText.fontStyle = FontStyle.Italic; // Make placeholder color half as opaque as normal text color. Color placeholderColor = unvText.color; placeholderColor.a *= 0.5f; placeholderUnvText.color = placeholderColor; inputField.placeholder = placeholderUnvText; PlaceUIElementRoot(inputFieldGO, menuCommand); }
static public void AddText(MenuCommand menuCommand) { GameObject go = DefaultControls.CreateText(GetStandardResources()); var text = go.GetComponent <Text>(); Object.DestroyImmediate(text); UnivText unvText = go.AddComponent <UnivText>(); unvText.text = "New Text"; PlaceUIElementRoot(go, menuCommand); }