protected override void OnDestroy() { text = null; button = null; base.OnDestroy(); }
protected override void Awake() { //Get Text component _text = GetComponent<UnityEngine.UI.Text>(); base.Awake(); }
protected override void Awake() { //Get Text component text = GetComponentInChildren<UnityEngine.UI.Text>(); //Get Button component button = GetComponentInChildren<UnityEngine.UI.Button>(); if (button == null) throw new Exception("Button component cannot be not found !!"); base.Awake(); }
void Awake() { _textComponent = GetComponent<UnityEngine.UI.Text>(); // If no localization key has been specified, use the text value as the key if (string.IsNullOrEmpty(Key)) { Key = _textComponent.text; } OnLocalise(); Localisation.LocaliseText.OnLocalise += OnLocalise; }
public virtual void Execute() { // FormatStringAction FormatStringAction21_Result = string.Format(@"{0}", Group.guess); ActionNode20_label = Group.label; ActionNode20_value = FormatStringAction21_Result; // ActionNode // Visit BoxGame.SetUILabel ActionNode20.label = ActionNode20_label; ActionNode20.value = ActionNode20_value; ActionNode20.System = System; ActionNode20.Execute(); }
void Start() { m_gamepad = GetComponent<HFTGamepad>(); m_renderer = GetComponent<Renderer>(); m_position = transform.localPosition; m_text = transform.FindChild("NameUI/Name").gameObject.GetComponent<UnityEngine.UI.Text>(); m_rawImage = transform.FindChild("NameUI/NameBackground").gameObject.GetComponent<UnityEngine.UI.RawImage>(); m_rawImage.material = (Material)Instantiate(m_rawImage.material); m_gamepad.OnNameChange += ChangeName; SetName(m_gamepad.Name); SetColor(m_gamepad.Color); }
public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go!=null) { _text = _go.GetComponent<UnityEngine.UI.Text>(); } DoGetTextValue(); if (!everyFrame) { Finish(); } }
void Start() { numItems = transform.childCount; itemNameUI = GameObject.Find("ItemName").GetComponent<UnityEngine.UI.Text>(); // make all particle systems loop for the demo ParticleSystem[] ps = GetComponentsInChildren<ParticleSystem>(); for (int i = 0; i < ps.Length; ++i) ps[i].loop = true; for (int i = 0; i < numItems; ++i) { GameObject item = transform.GetChild(i).gameObject; item.SetActive(false); } ActivateCurrentItem(); }
public void LocalizeText() { if (!started) return; if (string.IsNullOrEmpty(PixelCrushers.DialogueSystem.Localization.Language)) return; if (text == null) text = GetComponent<UnityEngine.UI.Text>(); if (string.IsNullOrEmpty(fieldName)) fieldName = (text != null) ? text.text : string.Empty; if (localizedTextTable == null) { localizedTextTable = DialogueManager.DisplaySettings.localizationSettings.localizedText; } if (text == null) { if (DialogueDebug.LogWarnings) Debug.LogWarning(DialogueDebug.Prefix + ": LocalizeUILabel didn't find a Text component on " + name + ".", this); } else if (localizedTextTable == null) { if (DialogueDebug.LogWarnings) Debug.LogWarning(DialogueDebug.Prefix + ": No localized text table is assigned to " + name + " or the Dialogue Manager.", this); } else if (!localizedTextTable.ContainsField(fieldName)) { if (DialogueDebug.LogWarnings) Debug.LogWarning(DialogueDebug.Prefix + ": Localized text table '" + localizedTextTable.name + "' does not have a field: " + fieldName, this); } else if (!HasCurrentLanguage()) { if (DialogueDebug.LogWarnings) Debug.LogWarning(DialogueDebug.Prefix + "Localized text table '" + localizedTextTable + "' does not have a language '" + PixelCrushers.DialogueSystem.Localization.Language + "'", this); } else { text.text = localizedTextTable[fieldName]; } }
public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go!=null) { _text = _go.GetComponent<UnityEngine.UI.Text>(); } if (resetOnExit.Value) { _originalString = _text.text; } DoSetTextValue(); if (!everyFrame) { Finish(); } }
// Use this for initialization void Start() { text = GetComponent<UnityEngine.UI.Text> (); }
/// <summary> /// Read the data using the reader. /// </summary> /// <param name="reader">Reader.</param> public override object Read(ISaveGameReader reader) { UnityEngine.UI.Text text = SaveGameType.CreateComponent <UnityEngine.UI.Text> (); ReadInto(text, reader); return(text); }
void Awake() { m_Text = GetComponent <UnityEngine.UI.Text>(); m_Text.enabled = false; }
private void CallLightning() { if (SpaceBarLabel != null) { SpaceBarLabel.CrossFadeColor(new Color(0.0f, 0.0f, 0.0f, 0.0f), 1.0f, true, true); SpaceBarLabel = null; } UnityEngine.Profiler.BeginSample("CreateLightningBolt"); System.Diagnostics.Stopwatch timer = System.Diagnostics.Stopwatch.StartNew(); lastStart = StartImage.transform.position + (Camera.main.transform.forward * DistanceSlider.value); lastEnd = EndImage.transform.position + (Camera.main.transform.forward * DistanceSlider.value); lastStart = Camera.main.ScreenToWorldPoint(lastStart); lastEnd = Camera.main.ScreenToWorldPoint(lastEnd); int count = (int)BoltCountSlider.value; float duration = DurationSlider.value; float delay = 0.0f; float chaosFactor = ChaosSlider.value; float trunkWidth = TrunkWidthSlider.value; float forkedness = ForkednessSlider.value; if (!int.TryParse(SeedInputField.text, out lastSeed)) { lastSeed = UnityEngine.Random.Range(int.MinValue, int.MaxValue); } System.Random r = new System.Random(lastSeed); float singleDuration = Mathf.Max(1.0f / 30.0f, (duration / (float)count)); float fadePercent = FadePercentSlider.value; float growthMultiplier = GrowthMultiplierSlider.value; while (count-- > 0) { LightningBoltParameters parameters = new LightningBoltParameters { Start = lastStart, End = lastEnd, Generations = (int)GenerationsSlider.value, LifeTime = (count == 1 ? singleDuration : (singleDuration * (((float)r.NextDouble() * 0.4f) + 0.8f))), Delay = delay, ChaosFactor = chaosFactor, TrunkWidth = trunkWidth, GlowIntensity = GlowIntensitySlider.value, GlowWidthMultiplier = GlowWidthSlider.value, Forkedness = forkedness, Random = r, FadePercent = fadePercent, GrowthMultiplier = growthMultiplier }; LightningBoltScript.CreateLightningBolt(parameters); delay += (singleDuration * (((float)r.NextDouble() * 0.8f) + 0.4f)); } timer.Stop(); UnityEngine.Profiler.EndSample(); UpdateStatusLabel(timer.Elapsed); }
public void cleanup() { this.onUpdateFloat = null; this.onUpdateFloatRatio = null; this.onUpdateVector2 = null; this.onUpdateVector3 = null; this.onUpdateFloatObject = null; this.onUpdateVector3Object = null; this.onUpdateColor = null; this.onComplete = null; this.onCompleteObject = null; this.onCompleteParam = null; #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 this.rectTransform = null; this.uiText = null; this.uiImage = null; this.sprites = null; #endif }
/// <summary> /// Set up the UIText with using Text /// </summary> void Awake() { //Log.Debug("AWAKE:"+gameObject.name); if(font == null) { //only load default if not yet assigned font = Resources.Load<Font>(defaultFont); } Log.Assert(font, "Missing font! Please assign a valid font!", gameObject); //check if we already has one, since it could run from Editor uiText = gameObject.GetComponent<UnityEngine.UI.Text>(); if(uiText == null) { //first time init, let's make them uiText = gameObject.AddComponent<UnityEngine.UI.Text>(); Log.Assert(uiText, "Cannot add UnityEngine.UI.Text!", gameObject); // int order = meshRenderer.sortingOrder; // if (order != 0) // { // sortingOrder = meshRenderer.sortingOrder; // } //set up defaults uiText.font = font; // uiText.anchor = anchor; // uiText.alignment = alignment; uiText.fontSize = size; uiText.lineSpacing = lineSize; uiText.fontStyle = style; uiText.color = color; uiText.text = text; } }
void InitScrollContent(GameObject scrollView) { //content_text GameObject scroll_content = new GameObject("content"); scroll_content.transform.parent = scrollView.transform; text_content = scroll_content.AddComponent<UnityEngine.UI.Text>(); text_content.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0); text_content.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 0); text_content.rectTransform.anchorMin = new Vector2(0, 0); text_content.rectTransform.anchorMax = new Vector2(1, 1); text_content.rectTransform.pivot = new Vector2(0f, 0f); text_content.color = new Color(1, 1, 1, 1f); text_content.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; text_content.fontSize = 12; text_content.alignment = TextAnchor.LowerLeft; text_content.gameObject.AddComponent<UnityEngine.UI.ContentSizeFitter>().verticalFit = UnityEngine.UI.ContentSizeFitter.FitMode.PreferredSize; scrollView.GetComponent<UnityEngine.UI.ScrollRect>().content = text_content.rectTransform; }
public new void Awake() { base.Awake(); _text = GetComponent<UnityEngine.UI.Text>(); }
public static GameObject DrawRing(int ring_index, float r_ext, float epaisseur, Dictionary <int, Bouton> boutons, float marge, Color[] couleurs ) { GameObject go = new GameObject(); go.name = "ring_" + ring_index; int nbrboutons = boutons.Count; float r_int = r_ext - epaisseur; float angle_ouverture_deg = (float)360 / nbrboutons; float angle_position_deg_init = angle_ouverture_deg / 2; foreach (Bouton bouton in boutons.Values) { float angle_position_deg = angle_position_deg_init + bouton.index * angle_ouverture_deg; GameObject btn; try { btn = RingButton.DrawButton(r_ext, r_int, angle_ouverture_deg, angle_position_deg, marge); if (btn == null) { continue; } btn.name = go.name + "_btn_" + bouton.name; btn.transform.parent = go.transform; RingButton_Manager rb = btn.AddComponent <RingButton_Manager>(); //rb._name = btn.name; rb._ring_index = ring_index; rb._index = bouton.index; rb._SetColors(couleurs[bouton.index]); //icône if (bouton.icone != null) { try { Texture texture = bouton.icone; GameObject icn = RingButton.DrawIcon(texture, 0, 0, 0); if (icn != null) { icn.transform.parent = rb.gameObject.transform; float hauteur = (r_ext - r_int - marge) / Mathf.Pow(2, 0.5f); float amplitude = r_int + hauteur / 2 + marge; float x = amplitude * Mathf.Cos((90 + angle_position_deg + angle_ouverture_deg / 2) / 180 * Mathf.PI); float y = amplitude * Mathf.Sin((90 + angle_position_deg + angle_ouverture_deg / 2) / 180 * Mathf.PI); if (angle_ouverture_deg == 360) { x = 0; y = 0; hauteur = r_ext; } icn.transform.localScale = new Vector2(hauteur, hauteur); icn.transform.Translate(x, y, -35); //icn.transform.Rotate(0, 0, angle_position_deg + angle_ouverture_deg / 2); } rb._icone = icn; } catch (System.Exception ex) { Debug.Log(ex.Message + "\n" + ex.StackTrace); } } //texte if (bouton.label != "") { GameObject canvas_go = new GameObject(); canvas_go.transform.SetParent(rb.gameObject.transform); Canvas canvas = canvas_go.gameObject.AddComponent <Canvas>(); canvas.renderMode = RenderMode.WorldSpace; canvas.worldCamera = Camera.main; float amplitude = r_int + r_ext * 0.8f; canvas.GetComponent <RectTransform>().sizeDelta = new Vector2(amplitude, amplitude); GameObject text_go = new GameObject(); text_go.transform.SetParent(canvas_go.transform); text_go.transform.Translate(0, 0, -20); text_go.transform.Rotate(0, 0, angle_position_deg + angle_ouverture_deg / 2); UnityEngine.UI.Text text = text_go.gameObject.AddComponent <UnityEngine.UI.Text>(); text.GetComponent <RectTransform>().sizeDelta = new Vector2(r_ext + r_int, r_ext + r_int); text.alignment = TextAnchor.UpperCenter; text.text = bouton.label; text.font = bouton.label_font; text.fontStyle = bouton.label_fontStyle; text.resizeTextForBestFit = bouton.label_resizeTextForBestFit; if (!bouton.label_resizeTextForBestFit) { text.fontSize = bouton.label_fontSize; } text.color = bouton.label_color; } } catch (System.Exception ex) { Debug.Log(ex.Message + "\n" + ex.StackTrace); } } return(go); }
public static GameObject DrawRing(Anneau anneau, float angle_initial, bool sens_horaire) { float r_int = anneau.r_int; float r_ext = anneau.r_ext; float marge = anneau.marge * (r_ext - r_int); GameObject go = new GameObject(); go.name = "ring_" + anneau.index; int nbrboutons = anneau.butons_on_ring.Count; float angle_ouverture_deg = (float)360 / nbrboutons; if (sens_horaire) { angle_initial = -angle_initial; } float angle_position_deg_init = angle_initial + angle_ouverture_deg / 2; foreach (RingButton_EditorMode bouton in anneau.butons_on_ring.Values) { float angle_position_deg; if (sens_horaire) { angle_position_deg = angle_position_deg_init - (bouton.button_index_on_ring_int + 1) * angle_ouverture_deg; } else { angle_position_deg = angle_position_deg_init + (bouton.button_index_on_ring_int - 1) * angle_ouverture_deg; } //Debug.Log("Bouton \"" + bouton.name + "\" angle " + (int)angle_position_deg + " sur " + (int)angle_ouverture_deg + "°"); GameObject btn; try { btn = RingButton.DrawButton(r_ext, r_int, angle_ouverture_deg, angle_position_deg, marge); if (btn == null) { continue; } btn.name = go.name + "_btn_" + bouton.name; btn.transform.parent = go.transform; RingButton_Manager rb = btn.AddComponent <RingButton_Manager>(); bouton.ringButtonManager = rb; rb._ring_index = anneau.index; rb._index = bouton.button_index_on_ring_int; rb._SetColors(bouton.button_color); //icône if (bouton.icon != null) { try { Texture texture = bouton.icon; GameObject icn = RingButton.DrawIcon(texture, r_ext, r_int, angle_position_deg + angle_ouverture_deg / 2); icn.transform.parent = rb.gameObject.transform; rb._icone = icn; } catch (System.Exception ex) { Debug.Log(ex.Message + "\n" + ex.StackTrace); } } //texte if (bouton.label.label_show && bouton.label.label != "") { GameObject canvas_go = new GameObject(); canvas_go.transform.SetParent(rb.gameObject.transform); Canvas canvas = canvas_go.gameObject.AddComponent <Canvas>(); canvas.renderMode = RenderMode.WorldSpace; canvas.worldCamera = Camera.main; float amplitude = r_int + r_ext * 0.8f; canvas.GetComponent <RectTransform>().sizeDelta = new Vector2(amplitude, amplitude); GameObject text_go = new GameObject(); text_go.transform.SetParent(canvas_go.transform); text_go.transform.Translate(0, 0, -20); text_go.transform.Rotate(0, 0, angle_position_deg + angle_ouverture_deg / 2); UnityEngine.UI.Text text = text_go.gameObject.AddComponent <UnityEngine.UI.Text>(); text.GetComponent <RectTransform>().sizeDelta = new Vector2(r_ext + r_int, r_ext + r_int); text.alignment = TextAnchor.UpperCenter; text.text = bouton.label.label; text.font = bouton.label.label_font; text.fontStyle = bouton.label.label_fontStyle; text.resizeTextForBestFit = bouton.label.label_resizeTextForBestFit; if (!bouton.label.label_resizeTextForBestFit) { text.fontSize = bouton.label.label_fontSize; } text.color = bouton.label.label_color; } //events rb._OnClick = bouton.events._OnClick; rb._OnEnter = bouton.events._OnEnter; rb._OnExit = bouton.events._OnExit; } catch (System.Exception ex) { Debug.Log(ex.Message + "\n" + ex.StackTrace); } } return(go); }
FileEntry GenerateFileEntry(System.IO.FileSystemInfo fsi, string ext, bool isfile) { FileEntry fi = new FileEntry(); PxPre.FileBrowse.FileBrowseProp.IconGroup icoGr = new PxPre.FileBrowse.FileBrowseProp.IconGroup(); if (isfile == false) { icoGr = this.properties.iconFolder; } else { icoGr = properties.GetExtIcon(ext); } GameObject goPlate = new GameObject("Plate"); goPlate.transform.SetParent(this.scrollRect.content); goPlate.transform.localRotation = Quaternion.identity; goPlate.transform.localScale = Vector3.one; RectTransform rtPlate = goPlate.AddComponent <RectTransform>(); rtPlate.anchorMin = new Vector2(0.0f, 1.0f); rtPlate.anchorMax = new Vector2(0.0f, 1.0f); rtPlate.pivot = new Vector2(0.0f, 1.0f); UnityEngine.UI.Image imgPlate = goPlate.AddComponent <UnityEngine.UI.Image>(); imgPlate.type = UnityEngine.UI.Image.Type.Sliced; UnityEngine.UI.Button btn = goPlate.AddComponent <UnityEngine.UI.Button>(); btn.onClick.AddListener( () => { this.parentBrowser.SelectFile(fsi.FullName, true); }); GameObject goIco = new GameObject("Ico"); goIco.transform.SetParent(rtPlate, false); goIco.transform.localRotation = Quaternion.identity; goIco.transform.localScale = Vector3.one; RectTransform rtIcon = goIco.AddComponent <RectTransform>(); rtIcon.anchorMin = new Vector2(0.0f, 1.0f); rtIcon.anchorMax = new Vector2(0.0f, 1.0f); rtIcon.pivot = new Vector2(0.0f, 1.0f); UnityEngine.UI.Image imgIco = goIco.AddComponent <UnityEngine.UI.Image>(); imgIco.sprite = icoGr.iconSmall; GameObject goText = new GameObject("Text"); goText.transform.SetParent(rtPlate); goText.transform.localRotation = Quaternion.identity; goText.transform.localScale = Vector3.one; RectTransform rtText = goText.AddComponent <RectTransform>(); rtText.anchorMin = new Vector2(0.0f, 1.0f); rtText.anchorMax = new Vector2(0.0f, 1.0f); rtText.pivot = new Vector2(0.0f, 1.0f); UnityEngine.UI.Text txt = goText.AddComponent <UnityEngine.UI.Text>(); txt.verticalOverflow = VerticalWrapMode.Overflow; this.properties.filenameFont.Apply(txt); txt.text = fsi.Name; fi.file = isfile; fi.icon = imgIco; fi.path = fsi.FullName; fi.text = txt; fi.plate = imgPlate; return(fi); }
public override void OnInit() { m_Result = Cop.Get <UnityEngine.UI.Text>("0"); }
// Use this for initialization void Start() { win = this.GetComponent <UnityEngine.UI.Text> (); win.enabled = false; }
public void Apply(UnityEngine.UI.Text text) { text.font = this.font; text.fontSize = this.fontSize; text.color = this.color; }
void Start() { m_gamepad = GetComponent<HFTGamepad>(); m_renderer = GetComponent<Renderer>(); m_position = transform.localPosition; m_text = transform.FindChild("NameUI/Name").gameObject.GetComponent<UnityEngine.UI.Text>(); m_rawImage = transform.FindChild("NameUI/NameBackground").gameObject.GetComponent<UnityEngine.UI.RawImage>(); m_rawImage.material = (Material)Instantiate(m_rawImage.material); m_gamepad.OnNameChange += ChangeName; SetName(m_gamepad.Name); SetColor(m_gamepad.Color); m_playerRigidbody = GetComponent<Rigidbody>(); m_impulseParticles = m_impulseParticleEffectHolder.GetComponent<ParticleSystem>(); m_impulseParticles.startColor = m_gamepad.Color; m_playerLight = GetComponentInChildren<Light>(); m_playerLight.color = m_gamepad.Color; m_gameManager = FindObjectOfType<GameManager>(); }
// Public function to move the mouse cursor to the specified position public static void MouseMove(Vector3 screenCoordinates, UnityEngine.UI.Text debugText) { int windowX = 0; int windowY = 0; int monitorWX = 0; int monitorWY = 0; int winSizeX = 0; int winSizeY = 0; bool isConvertToFullScreen = Screen.fullScreen; IntPtr hWnd = GetActiveWindow(); hWnd = GetClosestWindow(hWnd, Screen.width, Screen.height); if (hWnd != IntPtr.Zero) { RECT winRect; if (GetWindowRect(hWnd, out winRect)) { winSizeX = winRect.Right - winRect.Left; winSizeY = winRect.Bottom - winRect.Top; windowX = winRect.Left + (winSizeX - (int)Screen.width) / 2; monitorWX = winRect.Left; monitorWY = winRect.Top; if (!isConvertToFullScreen) { windowY = winRect.Top + (winSizeY - (int)Screen.height + 36) / 2; } else { windowY = winRect.Top + (winSizeY - (int)Screen.height) / 2; } // get display resolution if (monitorSize == Vector2.zero) { monitorInfo.cbSize = Marshal.SizeOf(monitorInfo); //IntPtr hMonitoŕ = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); IntPtr hMonitoŕ = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY); if (!GetMonitorInfo(hMonitoŕ, ref monitorInfo)) { monitorInfo.rcMonitor.Left = monitorInfo.rcMonitor.Top = 0; monitorInfo.rcMonitor.Right = Screen.currentResolution.width - 1; monitorInfo.rcMonitor.Bottom = Screen.currentResolution.height - 1; monitorInfo.rcWork.Left = monitorInfo.rcWork.Top = 0; monitorInfo.rcWork.Right = Screen.currentResolution.width - 1; monitorInfo.rcWork.Bottom = Screen.currentResolution.height - 1; } monitorSize.x = monitorInfo.rcMonitor.Right - monitorInfo.rcMonitor.Left + 1; monitorSize.y = monitorInfo.rcMonitor.Bottom - monitorInfo.rcMonitor.Top + 1; } if (!winRectPrinted) { Debug.Log(string.Format("monSize: ({0}, {1})", monitorSize.x, monitorSize.y)); Debug.Log(string.Format("scrSize: ({0}, {1})", Screen.width, Screen.height)); Debug.Log(string.Format("winRect: ({0}, {1}, {2}, {3})", winRect.Left, winRect.Top, winRect.Right, winRect.Bottom)); Debug.Log(string.Format("winPos: ({0}, {1})", windowX, windowY)); winRectPrinted = true; } } } else { if (monitorSize == Vector2.zero) { monitorSize.x = Screen.currentResolution.width; monitorSize.y = Screen.currentResolution.height; } } //int mouseX = 0; //int mouseY = 0; float screenX = screenCoordinates.x; float screenY = screenCoordinates.y; if (!isConvertToFullScreen) { // float screenX = windowX + screenCoordinates.x * Screen.width; // float screenY = windowY + (1f - screenCoordinates.y) * Screen.height; screenX = monitorWX + winSizeX * screenCoordinates.x; screenY = monitorWY + winSizeY * (1f - screenCoordinates.y); /* float screenRelX = screenX / monitorSize.x; * float screenRelY = screenY / monitorSize.y; * * // if(debugText) * // { * // if(!debugText.text.Contains("ScrPos")) * // { * // string sDebug = string.Format("\nScrPos: ({0:F0}, {1:F0})", screenX, screenY); * // debugText.text += sDebug; * // //Debug.Log (sDebug); * // } * // } * * mouseX = (int)(screenRelX * 65535); * mouseY = (int)(screenRelY * 65535);*/ } /* else * { * mouseX = (int)(screenCoordinates.x * 65535); * mouseY = (int)((1f - screenCoordinates.y) * 65535); * }*/ //mouse_event(MouseFlags.Absolute | MouseFlags.Move, mouseX, mouseY, 0, System.UIntPtr.Zero); SetCursorPos((int)screenX, (int)screenY); }
private void DrawFPS() { if(ui_fps_root != null) { return; } //canvas GameObject fpsRoot = new GameObject("fps"); ui_fps_root = fpsRoot; fpsRoot.transform.parent = transform; Canvas canvas = fpsRoot.AddComponent<Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; canvas.pixelPerfect = true; canvas.sortingOrder = 10000; fpsRoot.AddComponent<UnityEngine.UI.CanvasScaler>(); //text //content_text GameObject fps_content = new GameObject("text"); fps_content.transform.parent = ui_fps_root.transform; text_fps = fps_content.AddComponent<UnityEngine.UI.Text>(); text_fps.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0, 0); text_fps.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 0); text_fps.rectTransform.anchorMin = new Vector2(0, 0); text_fps.rectTransform.anchorMax = new Vector2(1, 1); text_fps.rectTransform.pivot = new Vector2(0f, 0f); text_fps.color = new Color(1, 1, 1, 1f); text_fps.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; text_fps.fontSize = 14; text_fps.alignment = TextAnchor.UpperRight; text_fps.text = "fps"; }
public void Awake() { control = GetComponent <UnityEngine.UI.Text>(); }
internal Toy(string name, string id) { this.id = id; this.name = name; button = ButtonAPI.CreateButton(ButtonAPI.ButtonType.Default, name + "\nClick to\nSet", "Click to set controll mode", (ButtonAPI.HorizontalPosition) x ++, ButtonAPI.VerticalPosition.BottomButton, ButtonAPI.MakeEmptyPage("SubMenu_1").transform, delegate(bool a) { changeHand(); }, Color.white, Color.magenta, null, true, false, false, false, null, true); toys.Add(this); GameObject slider = GameObject.Find("UserInterface/QuickMenu/UserInteractMenu/User Volume/VolumeSlider"); GameObject quickmenu = GameObject.Find("UserInterface/QuickMenu/ShortcutMenu"); GameObject speedSliderObject = GameObject.Instantiate(slider, quickmenu.transform, true); speedSlider = speedSliderObject.GetComponent <UnityEngine.UI.Slider>(); speedSlider.maxValue = 20; speedSlider.wholeNumbers = true; speedSlider.value = 0; speedSliderText = speedSlider.transform.Find("Fill Area/VolumeNumberText").GetComponent <UnityEngine.UI.Text>(); speedSliderText.text = name + " Speed: 0%"; speedSliderObject.SetActive(false); if (name.Equals("Max")) { GameObject maxSliderObject = GameObject.Instantiate(slider, quickmenu.transform, true); maxSliderObject.transform.localScale = new Vector3(0.7f, 1, 1); maxSlider = maxSliderObject.GetComponent <UnityEngine.UI.Slider>(); maxSlider.maxValue = 3; maxSlider.wholeNumbers = true; maxSlider.value = 0; Transform textTransform = maxSlider.transform.Find("Fill Area/VolumeNumberText"); textTransform.localScale = new Vector3(1, 1, 1); maxSliderText = textTransform.GetComponent <UnityEngine.UI.Text>(); maxSliderText.text = "Max Contraction: 0"; maxSliderObject.SetActive(false); } else if (name.Equals("Nora")) { rotateButton = ButtonAPI.CreateButton(ButtonAPI.ButtonType.Default, "Rotate", "Rotate Nora", ButtonAPI.HorizontalPosition.LeftOfMenu, ButtonAPI.VerticalPosition.BelowBottomButton, ButtonAPI.ShortcutMenuTransform, delegate(bool a) { rotate(); }, Color.white, Color.magenta, null, true, false, false, false, null, true); rotateButton.gameObject.GetComponent <RectTransform>().sizeDelta = new Vector2(720, 190); rotateButton.gameObject.SetActive(false); } else if (name.Equals("Edge")) { speedSlider.GetComponent <RectTransform>().sizeDelta = new Vector2(850, 160); GameObject edgeSliderObject = GameObject.Instantiate(slider, quickmenu.transform, true); edgeSliderObject.GetComponent <RectTransform>().sizeDelta = new Vector2(850, 160); edgeSlider = edgeSliderObject.GetComponent <UnityEngine.UI.Slider>(); edgeSlider.maxValue = 20; edgeSlider.wholeNumbers = true; edgeSlider.value = 0; Transform textTransform = edgeSlider.transform.Find("Fill Area/VolumeNumberText"); textTransform.localScale = new Vector3(1, 1, 1); edgeSliderText = textTransform.GetComponent <UnityEngine.UI.Text>(); edgeSliderText.text = "Edge Speed: 0%"; edgeSliderObject.SetActive(false); } }
private void Awake() { PauseText = transform.GetChild(0).gameObject.GetComponent <UnityEngine.UI.Text>(); }
void Awake() { #if UNITY_PSP2 UnityEngine.PSVita.Diagnostics.enableHUD = true; #endif Application.targetFrameRate = 60; DontDestroyOnLoad(gameObject); stopwatch_ = new System.Diagnostics.Stopwatch(); stopwatch_.Start(); rendering_front_ = 0; Instance.init(); Options.Instance.init(); InputManager.Instance.init(); GameManager.Instance.init(); TaskManager.Instance.init(); MyCollider.createPool(); LockTarget.createPool(); Missile.createPool(); Bullet.createPool(); Enemy.createPool(); EnemyBullet.createPool(); Debris.Instance.init(debris_material_); Spark.Instance.init(spark_material_); Beam.Instance.init(beam_material_); Trail.Instance.init(trail_material_); Explosion.Instance.init(explosion_material_); Hahen.Instance.init(hahen_material_); HUD.Instance.init(); draw_buffer_ = new DrawBuffer[2]; for (int i = 0; i < 2; ++i) { draw_buffer_[i].init(); } manual_reset_event_ = new System.Threading.ManualResetEvent(false); setFPS(DefaultFps); update_frame_ = 0; update_sync_frame_ = 0; update_time_ = 0f; render_frame_ = 0; render_sync_frame_ = 0; pause_ = false; camera_ = GameObject.Find("MainCamera").GetComponent<Camera>(); // Camera.main; ProjectionMatrix = camera_.projectionMatrix; camera_.enabled = false; if (player_prefab_ != null) { player_go_ = Instantiate(player_prefab_) as GameObject; } if (zako_prefab_ != null) { zako_pool_ = new GameObject[ZAKO_MAX]; for (var i = 0; i < ZAKO_MAX; ++i) { zako_pool_[i] = Instantiate(zako_prefab_) as GameObject; zako_pool_[i].SetActive(false); } } uv_scroller_list_ = new UVScroller[8]; // pause menu pausemenu_canvas_go_ = GameObject.Find("Canvas"); if (pausemenu_canvas_go_ != null) { var go = GameObject.Find("FPSValue"); fps_text_ = go.GetComponent<UnityEngine.UI.Text>(); fps_text_.text = "1/" + fps_.ToString(); pausemenu_canvas_go_.SetActive(false); } // audio audio_sources_bullet_ = new AudioSource[AUDIOSOURCE_BULLET_MAX]; for (var i = 0; i < AUDIOSOURCE_BULLET_MAX; ++i) { audio_sources_bullet_[i] = gameObject.AddComponent<AudioSource>(); audio_sources_bullet_[i].clip = se_bullet_; audio_sources_bullet_[i].volume = 0.05f; } audio_source_bullet_index_ = 0; audio_sources_explosion_ = new AudioSource[AUDIOSOURCE_EXPLOSION_MAX]; for (var i = 0; i < AUDIOSOURCE_EXPLOSION_MAX; ++i) { audio_sources_explosion_[i] = gameObject.AddComponent<AudioSource>(); audio_sources_explosion_[i].clip = se_explosion_; audio_sources_explosion_[i].volume = 0.25f; } audio_source_explosion_index_ = 0; audio_sources_missile_ = new AudioSource[AUDIOSOURCE_MISSILE_MAX]; for (var i = 0; i < AUDIOSOURCE_MISSILE_MAX; ++i) { audio_sources_missile_[i] = gameObject.AddComponent<AudioSource>(); audio_sources_missile_[i].clip = se_missile_; audio_sources_missile_[i].volume = 0.25f; } audio_source_missile_index_ = 0; audio_sources_lockon_ = new AudioSource[AUDIOSOURCE_LOCKON_MAX]; for (var i = 0; i < AUDIOSOURCE_LOCKON_MAX; ++i) { audio_sources_lockon_[i] = gameObject.AddComponent<AudioSource>(); audio_sources_lockon_[i].clip = se_lockon_; audio_sources_lockon_[i].volume = 0.25f; } audio_source_lockon_index_ = 0; audio_sources_voice_ikuyo_ = gameObject.AddComponent<AudioSource>(); audio_sources_voice_ikuyo_.clip = se_voice_ikuyo_; audio_sources_voice_ikuyo_.volume = 0.75f; audio_sources_voice_uwaa_ = gameObject.AddComponent<AudioSource>(); audio_sources_voice_uwaa_.clip = se_voice_uwaa_; audio_sources_voice_uwaa_.volume = 0.75f; audio_sources_voice_sorosoro_ = gameObject.AddComponent<AudioSource>(); audio_sources_voice_sorosoro_.clip = se_voice_sorosoro_; audio_sources_voice_sorosoro_.volume = 0.75f; audio_sources_voice_ototo_ = gameObject.AddComponent<AudioSource>(); audio_sources_voice_ototo_.clip = se_voice_ototo_; audio_sources_voice_ototo_.volume = 0.75f; audio_sources_voice_yoshi_ = gameObject.AddComponent<AudioSource>(); audio_sources_voice_yoshi_.clip = se_voice_yoshi_; audio_sources_voice_yoshi_.volume = 0.75f; audio_sources_bgm_ = gameObject.AddComponent<AudioSource>(); audio_sources_bgm_.clip = bgm01_; audio_sources_bgm_.volume = 0.5f; audio_sources_bgm_.loop = true; gc_start_count_ = System.GC.CollectionCount(0 /* generation */); }
public void Create(PxPre.FileBrowse.FileBrowseProp prop, FileBrowser browser) { this.prop = prop; this.browser = browser; GameObject goLabel = new GameObject("FontLabel"); goLabel.transform.SetParent(this.transform); goLabel.transform.localScale = Vector3.one; goLabel.transform.localRotation = Quaternion.identity; UnityEngine.UI.Text txtLabel = goLabel.AddComponent <UnityEngine.UI.Text>(); this.prop.inputLabel.Apply(txtLabel); txtLabel.horizontalOverflow = HorizontalWrapMode.Overflow; txtLabel.verticalOverflow = VerticalWrapMode.Overflow; txtLabel.alignment = TextAnchor.MiddleLeft; txtLabel.text = "Filename"; RectTransform rtLabel = txtLabel.rectTransform; TextGenerationSettings tgsLabel = txtLabel.GetGenerationSettings(new Vector2(float.PositiveInfinity, float.PositiveInfinity)); tgsLabel.scaleFactor = 1.0f; TextGenerator tgLabel = txtLabel.cachedTextGenerator; float labelWidth = tgLabel.GetPreferredWidth(txtLabel.text, tgsLabel); rtLabel.pivot = new Vector2(0.0f, 0.5f); rtLabel.anchorMin = new Vector2(0.0f, 0.0f); rtLabel.anchorMax = new Vector2(0.0f, 1.0f); rtLabel.offsetMin = new Vector2(0.0f, 0.0f); rtLabel.offsetMax = new Vector2(labelWidth, 0.0f); GameObject goInput = new GameObject("Input"); goInput.transform.SetParent(this.transform); goInput.transform.localScale = Vector3.one; goInput.transform.localRotation = Quaternion.identity; UnityEngine.UI.Image imgInput = goInput.AddComponent <UnityEngine.UI.Image>(); imgInput.type = UnityEngine.UI.Image.Type.Sliced; imgInput.sprite = this.prop.inputPlateSprite; RectTransform rtInput = imgInput.rectTransform; rtInput.anchorMin = Vector2.zero; rtInput.anchorMax = Vector2.one; rtInput.offsetMin = new Vector2(labelWidth + this.prop.inputLabelInputPadding, 0.0f); rtInput.offsetMax = Vector2.zero; GameObject goInputText = new GameObject("InputText"); goInputText.transform.SetParent(goInput.transform); goInputText.transform.localScale = Vector3.one; goInputText.transform.localRotation = Quaternion.identity; UnityEngine.UI.Text textInput = goInputText.AddComponent <UnityEngine.UI.Text>(); this.prop.inputText.Apply(textInput); textInput.alignment = TextAnchor.MiddleLeft; textInput.verticalOverflow = VerticalWrapMode.Overflow; RectTransform rtText = textInput.rectTransform; rtText.anchorMin = Vector2.zero; rtText.anchorMax = Vector2.one; rtText.pivot = new Vector2(0.0f, 0.5f); rtText.offsetMin = new Vector2(this.prop.inputPadding, 0.0f); rtText.offsetMax = new Vector2(-this.prop.inputPadding, 0.0f); this.input = goInput.AddComponent <UnityEngine.UI.InputField>(); this.input.textComponent = textInput; this.input.onValidateInput += this.OnValidateInput; this.input.lineType = UnityEngine.UI.InputField.LineType.MultiLineNewline; }
// Use this for initialization void Start() { text = GetComponent <UnityEngine.UI.Text>(); ReSetText(); }
void Start() { currentTestText = CurrentTestText.GetComponent<UnityEngine.UI.Text>(); nextTestText = NextTestText.GetComponent<UnityEngine.UI.Text>(); StartCoroutine(RunAllTests()); }
public void Awake() { control = GetComponent <UnityEngine.UI.Text>(); audioSource = GetComponent <AudioSource>(); }
void ClearBinds() { Text = null; }
/// <summary> /// Read the data into the specified value. /// </summary> /// <param name="value">Value.</param> /// <param name="reader">Reader.</param> public override void ReadInto(object value, ISaveGameReader reader) { UnityEngine.UI.Text text = (UnityEngine.UI.Text)value; foreach (string property in reader.Properties) { switch (property) { case "font": if (text.font == null) { text.font = reader.ReadProperty <UnityEngine.Font> (); } else { reader.ReadIntoProperty <UnityEngine.Font> (text.font); } break; case "text": text.text = reader.ReadProperty <System.String> (); break; case "supportRichText": text.supportRichText = reader.ReadProperty <System.Boolean> (); break; case "resizeTextForBestFit": text.resizeTextForBestFit = reader.ReadProperty <System.Boolean> (); break; case "resizeTextMinSize": text.resizeTextMinSize = reader.ReadProperty <System.Int32> (); break; case "resizeTextMaxSize": text.resizeTextMaxSize = reader.ReadProperty <System.Int32> (); break; case "alignment": text.alignment = reader.ReadProperty <UnityEngine.TextAnchor> (); break; case "alignByGeometry": text.alignByGeometry = reader.ReadProperty <System.Boolean> (); break; case "fontSize": text.fontSize = reader.ReadProperty <System.Int32> (); break; case "horizontalOverflow": text.horizontalOverflow = reader.ReadProperty <UnityEngine.HorizontalWrapMode> (); break; case "verticalOverflow": text.verticalOverflow = reader.ReadProperty <UnityEngine.VerticalWrapMode> (); break; case "lineSpacing": text.lineSpacing = reader.ReadProperty <System.Single> (); break; case "fontStyle": text.fontStyle = reader.ReadProperty <UnityEngine.FontStyle> (); break; case "maskable": text.maskable = reader.ReadProperty <System.Boolean> (); break; case "color": text.color = reader.ReadProperty <UnityEngine.Color> (); break; case "raycastTarget": text.raycastTarget = reader.ReadProperty <System.Boolean> (); break; case "material": if (text.material == null) { text.material = reader.ReadProperty <UnityEngine.Material> (); } else { reader.ReadIntoProperty <UnityEngine.Material> (text.material); } break; case "useGUILayout": text.useGUILayout = reader.ReadProperty <System.Boolean> (); break; case "enabled": text.enabled = reader.ReadProperty <System.Boolean> (); break; case "tag": text.tag = reader.ReadProperty <System.String> (); break; case "name": text.name = reader.ReadProperty <System.String> (); break; case "hideFlags": text.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> (); break; } } }
void Awake() { instance = this; if(!TooltipText) TooltipText = GetComponentInChildren<Text>(); HideTooltip(); }
void SetupBinds() { Text = transform.Find("Text").GetComponent <UnityEngine.UI.Text>(); }
public void Apply() { this.text.text = this.finder.Get; }
static int _m_DOText(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.Text gen_to_be_invoked = (UnityEngine.UI.Text)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 6 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4) && translator.Assignable <DG.Tweening.ScrambleMode>(L, 5) && (LuaAPI.lua_isnil(L, 6) || LuaAPI.lua_type(L, 6) == LuaTypes.LUA_TSTRING)) { string _endValue = LuaAPI.lua_tostring(L, 2); float _duration = (float)LuaAPI.lua_tonumber(L, 3); bool _richTextEnabled = LuaAPI.lua_toboolean(L, 4); DG.Tweening.ScrambleMode _scrambleMode; translator.Get(L, 5, out _scrambleMode); string _scrambleChars = LuaAPI.lua_tostring(L, 6); DG.Tweening.Tweener gen_ret = gen_to_be_invoked.DOText(_endValue, _duration, _richTextEnabled, _scrambleMode, _scrambleChars); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 5 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4) && translator.Assignable <DG.Tweening.ScrambleMode>(L, 5)) { string _endValue = LuaAPI.lua_tostring(L, 2); float _duration = (float)LuaAPI.lua_tonumber(L, 3); bool _richTextEnabled = LuaAPI.lua_toboolean(L, 4); DG.Tweening.ScrambleMode _scrambleMode; translator.Get(L, 5, out _scrambleMode); DG.Tweening.Tweener gen_ret = gen_to_be_invoked.DOText(_endValue, _duration, _richTextEnabled, _scrambleMode); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4)) { string _endValue = LuaAPI.lua_tostring(L, 2); float _duration = (float)LuaAPI.lua_tonumber(L, 3); bool _richTextEnabled = LuaAPI.lua_toboolean(L, 4); DG.Tweening.Tweener gen_ret = gen_to_be_invoked.DOText(_endValue, _duration, _richTextEnabled); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { string _endValue = LuaAPI.lua_tostring(L, 2); float _duration = (float)LuaAPI.lua_tonumber(L, 3); DG.Tweening.Tweener gen_ret = gen_to_be_invoked.DOText(_endValue, _duration); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.UI.Text.DOText!")); }
public static void MutliText(this UnityEngine.UI.Text text, string key) { text.text = WordDic.Get(key); }
private static void UpdateTextComponent(UnityEngine.UI.InputField body, UnityEngine.UI.Text value) { body.textComponent = value; body.ForceLabelUpdate(); }
public static int getLineCount(this UnityEngine.UI.Text text) => text.cachedTextGenerator.lineCount;
// Use this for initialization void Start() { if (Text == null) Text = GetComponent<UnityEngine.UI.Text>(); Assert.IsNotNull(Text, "You either have to specify a Text component, or attach the Score Display to a gameobject that contains one."); _player = GameManager.Instance.GetPlayer(); _level = GameManager.Instance.Levels == null ? null : GameManager.Instance.Levels.Selected; if (!string.IsNullOrEmpty(LocalisationKey)) _localisationString = LocaliseText.Get(LocalisationKey); UpdateDisplay(); }
public static int getFirstCharIndexAtLine(this UnityEngine.UI.Text text, int line) => text.cachedTextGenerator.GetLinesArray()[line].startCharIdx;
void InitInput(GameObject windows) { GameObject input_obj = new GameObject("input"); input_obj.transform.parent = windows.transform; UnityEngine.UI.Image img_input = input_obj.AddComponent<UnityEngine.UI.Image>(); img_input.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0); img_input.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, -15, 30); img_input.rectTransform.anchorMin = new Vector2(0, 0.3f); img_input.rectTransform.anchorMax = new Vector2(1, 0.3f); img_input.rectTransform.pivot = new Vector2(0f, 0f); img_input.color = new Color(0, 0, 0, 1); GameObject input_placeholder = new GameObject("placeHolder"); input_placeholder.transform.parent = input_obj.transform; UnityEngine.UI.Text text_holder = input_placeholder.AddComponent<UnityEngine.UI.Text>(); text_holder.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0); text_holder.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 5, -10); text_holder.rectTransform.anchorMin = new Vector2(0, 0); text_holder.rectTransform.anchorMax = new Vector2(1, 1); text_holder.rectTransform.pivot = new Vector2(0.5f, 0.5f); text_holder.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; text_holder.color = Color.grey; text_holder.text = ">"; GameObject input_page = new GameObject("pageamount"); input_page.transform.parent = input_obj.transform; text_pageCount = input_page.AddComponent<UnityEngine.UI.Text>(); text_pageCount.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0); text_pageCount.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 5, -10); text_pageCount.rectTransform.anchorMin = new Vector2(0, 0); text_pageCount.rectTransform.anchorMax = new Vector2(1, 1); text_pageCount.rectTransform.pivot = new Vector2(0.5f, 0.5f); text_pageCount.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; text_pageCount.color = Color.grey; text_pageCount.text = currentPersent + "%"; text_pageCount.alignment = TextAnchor.MiddleRight; GameObject input_text_obj = new GameObject("inputText"); input_text_obj.transform.parent = input_obj.transform; UnityEngine.UI.Text text_input = input_text_obj.AddComponent<UnityEngine.UI.Text>(); text_input.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 10, -20); text_input.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 5, -10); text_input.rectTransform.anchorMin = new Vector2(0, 0); text_input.rectTransform.anchorMax = new Vector2(1, 1); text_input.rectTransform.pivot = new Vector2(0.5f, 0.5f); text_input.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; text_input.color = Color.white; text_input.supportRichText = false; input = input_obj.AddComponent<UnityEngine.UI.InputField>(); input.textComponent = text_input; //input.placeholder = text_holder; //input.ActivateInputField(); ///Init event input.onEndEdit.AddListener(ProcessInput); }
public static void forceRedraw(this UnityEngine.UI.Text text, string str) { var rt = text.transform as RectTransform; text.cachedTextGenerator.Populate(str, text.GetGenerationSettings(rt.rect.size)); }
//---------------------------------------------------------------------- End 3P ---------- /// <summary> /// Parse the content of the dictionary /// and create a new gameobject with this parameters /// </summary> public virtual void Parse(Dictionary<string,object> dict) { //base.Parse(dict); //GameObject gameObject = new GameObject(); //this.gameObject = gameObject; //and set the id //this.gameObject.name = dict["id"].ToString(); // Debug.Log("<color=yellow>UIText gameObject:</color> " + this.gameObject); // foreach(KeyValuePair<string,object> entry in dict) // { // Debug.Log(entry.Key + ": " + entry.Value.ToString()); // } // GameObject text46 = new GameObject(); // text46.name = objId; //gameObject.transform.parent = GameObject.Find("Canvas").transform; uiText = gameObject.GetComponent<UnityEngine.UI.Text>(); if (uiText == null) { uiText = gameObject.AddComponent<UnityEngine.UI.Text>(); } I18nManager i18n = I18nManager.Instance; Debug.Log("uiText:" + uiText); uiText.text = i18n.Get(dict["id"].ToString()); //Debug.Log("GetPixelAdjustedRect: " + t.GetPixelAdjustedRect()); if(dict.ContainsKey("position")) { string pos = dict["position"].ToString(); float px = System.Convert.ToSingle(pos.Split(',')[0]); float py = System.Convert.ToSingle(pos.Split(',')[1]); Log.Debug("Position:"+px+","+py); // this.gameObject.transform.position = new Vector3(px, py, 0); anchoredPosition = new Vector2(px * 100, py * 100); //this.gameObject.name = dict["position"].ToString(); } if(dict.ContainsKey("rotation")) { string rot = dict["rotation"].ToString(); float rx = System.Convert.ToSingle(rot.Split(',')[0]); float ry = System.Convert.ToSingle(rot.Split(',')[1]); //Log.Debug("Rotation:"+rot+":"+rx+","+ry); this.gameObject.transform.localRotation = Quaternion.Euler(new Vector3(rx, ry, 0)); //this.gameObject.name = dict["position"].ToString(); } if(dict.ContainsKey("scale")) { string sc = dict["scale"].ToString(); float sx = System.Convert.ToSingle(sc.Split(',')[0]); float sy = System.Convert.ToSingle(sc.Split(',')[1]); this.gameObject.transform.localScale = new Vector3(sx * 10, sy * 10, 0); //TODO } if(dict.ContainsKey("order")) { SortingOrder = System.Convert.ToInt32(dict["order"].ToString()); } if(dict.ContainsKey("layer")) { string layer = dict["layer"].ToString(); this.gameObject.layer = LayerMask.NameToLayer(layer); } if(dict.ContainsKey("fontSize")) { FontSize = System.Convert.ToInt32(dict["fontSize"].ToString()); } if(dict.ContainsKey("spacing")) { string value = dict["spacing"].ToString(); LineSpacing = float.Parse(value); } if(dict.ContainsKey("fontStyle")) { //TODO implement possibility to disply UIText in Bold or Italic string fontStyleDef = dict["fontStyle"].ToString(); if(fontStyleDef == "bold") FontStyleDef = FontStyle.Bold; else if(fontStyleDef == "italic") FontStyleDef = FontStyle.Italic; else if(fontStyleDef == "bold and italic") FontStyleDef = FontStyle.BoldAndItalic; } if(dict.ContainsKey("color")) { string color = dict["color"].ToString(); byte red = System.Convert.ToByte(color.Split(',')[0]); byte green = System.Convert.ToByte(color.Split(',')[1]); byte blue = System.Convert.ToByte(color.Split(',')[2]); byte alpha = System.Convert.ToByte(color.Split(',')[3]); Debug.Log(string.Format("<color=yellow>{0}: {1},{2},{3},{4}</color>", name, red, green, blue, alpha)); FontColor = new Color32(red, green, blue, alpha); } else { FontColor = color; } if(dict.ContainsKey("localized")) { string value = dict["localized"].ToString(); isLocalized = (value == "true" ) ? true : false; textId = dict["id"].ToString(); } if(dict.ContainsKey("font")) { uiText.font = Resources.Load<Font>(dict["font"].ToString()); Log.Debug("font:"+font); } if(dict.ContainsKey("anchor")) { string value = dict["anchor"].ToString(); if(value == "middle center") uiText.alignment = TextAnchor.MiddleCenter; else if(value == "middle left") uiText.alignment = TextAnchor.MiddleLeft; else if(value == "middle right") uiText.alignment = TextAnchor.MiddleRight; else if(value == "upper left") uiText.alignment = TextAnchor.UpperLeft; else if(value == "upper center") uiText.alignment = TextAnchor.UpperCenter; else if(value == "upper right") uiText.alignment = TextAnchor.UpperRight; else if(value == "lower left") uiText.alignment = TextAnchor.UpperLeft; else if(value == "lower center") uiText.alignment = TextAnchor.UpperCenter; else if(value == "lower right") uiText.alignment = TextAnchor.UpperRight; } // if(dict.ContainsKey("alignment")) // { // string value = dict["alignment"].ToString(); // if(value == "left") // Alignment = TextAlignment.Left; // else if(value == "center") // Alignment = TextAlignment.Center; // else if(value == "right") // Alignment = TextAlignment.Right; // } if(dict.ContainsKey("wrapsize")) { string value = dict["wrapsize"].ToString(); this.wrapSize = Convert.ToInt32(value); } if(dict.ContainsKey("maxlength")) { string value = dict["maxlength"].ToString(); this.maxLength = Convert.ToInt32(value); } if(dict.ContainsKey("format")) { string value = dict["format"].ToString(); this.format = value; } if(dict.ContainsKey("numeric")) { string value = dict["numeric"].ToString(); this.isNumeric = (value == "true" ) ? true : false; } if(dict.ContainsKey("text")) { Text = dict["text"].ToString(); } // uiText.rectTransform.sizeDelta = new Vector2(uiText.preferredWidth, uiText.preferredHeight); // Debug.Log(string.Format("<color=yellow>UIText: {0} : ({1}, {2})</color>", name, uiText.rectTransform.sizeDelta.x, uiText.rectTransform.sizeDelta.y)); }
/// <inheritdoc /> protected override void Awake() { base.Awake(); mTextElement = GetComponent <UIText>(); }
public void FindUIElements() { // Only find if none of the critical UI elements are assigned: if (mainGraphic == null && nameText == null && reticleInRange == null) { var elements = FindObjectOfType<UnityUISelectorElements>(); if (elements == null) { if (DialogueDebug.LogWarnings) Debug.LogWarning("Dialogue System: UnityUISelectorDisplay can't find UI elements", this); } else { if (mainGraphic == null) mainGraphic = elements.mainGraphic; if (nameText == null) nameText = elements.nameText; if (useMessageText == null) useMessageText = elements.useMessageText; inRangeColor = elements.inRangeColor; outOfRangeColor = elements.outOfRangeColor; if (reticleInRange == null) reticleInRange = elements.reticleInRange; if (reticleOutOfRange == null) reticleOutOfRange = elements.reticleOutOfRange; animationTransitions = elements.animationTransitions; } } if (mainGraphic != null) animator = GetComponentInChildren<Animator>(); }
internal Text (GameObject obj) : base (obj, true, false) { text = obj.GetComponent<UnityEngine.UI.Text> (); }
public void Awake() { control = GetComponent<UnityEngine.UI.Text>(); audioSource = GetComponent<AudioSource>(); }
void Start() { partIcon = (partIcon == null) ? (GetComponentInChildren <UnityEngine.UI.Image>()) : (partIcon); partNameText = (partNameText == null) ? (GetComponentInChildren <UnityEngine.UI.Text>()) : (partNameText); Part = Part; //initializes the current part according to it's current value }
// This method is only for internal use public void init() { this.hasInitiliazed = true; // Set time based on current timeScale /*if( !this.useEstimatedTime ){ this.time = this.time*Time.timeScale; }*/ // Initialize From Values switch (this.type) { case TweenAction.MOVE: this.from = trans.position; break; case TweenAction.MOVE_X: this.from.x = trans.position.x; break; case TweenAction.MOVE_Y: this.from.x = trans.position.y; break; case TweenAction.MOVE_Z: this.from.x = trans.position.z; break; case TweenAction.MOVE_LOCAL_X: this.from.x = trans.localPosition.x; break; case TweenAction.MOVE_LOCAL_Y: this.from.x = trans.localPosition.y; break; case TweenAction.MOVE_LOCAL_Z: this.from.x = trans.localPosition.z; break; case TweenAction.SCALE_X: this.from.x = trans.localScale.x; break; case TweenAction.SCALE_Y: this.from.x = trans.localScale.y; break; case TweenAction.SCALE_Z: this.from.x = trans.localScale.z; break; case TweenAction.ALPHA: #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 if(trans.gameObject.renderer){ this.from.x = trans.gameObject.renderer.material.color.a; }else if(trans.childCount>0){ foreach (Transform child in trans) { if(child.gameObject.renderer!=null){ Color col = child.gameObject.renderer.material.color; this.from.x = col.a; break; } } } break; #else SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>(); if (ren != null) { this.from.x = ren.color.a; } else { if (trans.gameObject.GetComponent<Renderer>() != null && trans.gameObject.GetComponent<Renderer>().material.HasProperty("_Color")) { this.from.x = trans.gameObject.GetComponent<Renderer>().material.color.a; } else if (trans.gameObject.GetComponent<Renderer>() != null && trans.gameObject.GetComponent<Renderer>().material.HasProperty("_TintColor")) { Color col = trans.gameObject.GetComponent<Renderer>().material.GetColor("_TintColor"); this.from.x = col.a; } else if (trans.childCount > 0) { foreach (Transform child in trans) { if (child.gameObject.GetComponent<Renderer>() != null) { Color col = child.gameObject.GetComponent<Renderer>().material.color; this.from.x = col.a; break; } } } } break; #endif case TweenAction.MOVE_LOCAL: this.from = trans.localPosition; break; case TweenAction.MOVE_CURVED: case TweenAction.MOVE_CURVED_LOCAL: case TweenAction.MOVE_SPLINE: case TweenAction.MOVE_SPLINE_LOCAL: this.from.x = 0; break; case TweenAction.ROTATE: this.from = trans.eulerAngles; this.to = new Vector3(LeanTween.closestRot(this.from.x, this.to.x), LeanTween.closestRot(this.from.y, this.to.y), LeanTween.closestRot(this.from.z, this.to.z)); break; case TweenAction.ROTATE_X: this.from.x = trans.eulerAngles.x; this.to.x = LeanTween.closestRot(this.from.x, this.to.x); break; case TweenAction.ROTATE_Y: this.from.x = trans.eulerAngles.y; this.to.x = LeanTween.closestRot(this.from.x, this.to.x); break; case TweenAction.ROTATE_Z: this.from.x = trans.eulerAngles.z; this.to.x = LeanTween.closestRot(this.from.x, this.to.x); break; case TweenAction.ROTATE_AROUND: this.lastVal = 0.0f; // optional["last"] this.from.x = 0.0f; this.origRotation = trans.rotation; // optional["origRotation" break; case TweenAction.ROTATE_AROUND_LOCAL: this.lastVal = 0.0f; // optional["last"] this.from.x = 0.0f; this.origRotation = trans.localRotation; // optional["origRotation" break; case TweenAction.ROTATE_LOCAL: this.from = trans.localEulerAngles; this.to = new Vector3(LeanTween.closestRot(this.from.x, this.to.x), LeanTween.closestRot(this.from.y, this.to.y), LeanTween.closestRot(this.from.z, this.to.z)); break; case TweenAction.SCALE: this.from = trans.localScale; break; case TweenAction.GUI_MOVE: this.from = new Vector3(this.ltRect.rect.x, this.ltRect.rect.y, 0); break; case TweenAction.GUI_MOVE_MARGIN: this.from = new Vector2(this.ltRect.margin.x, this.ltRect.margin.y); break; case TweenAction.GUI_SCALE: this.from = new Vector3(this.ltRect.rect.width, this.ltRect.rect.height, 0); break; case TweenAction.GUI_ALPHA: this.from.x = this.ltRect.alpha; break; case TweenAction.GUI_ROTATE: if (this.ltRect.rotateEnabled == false) { this.ltRect.rotateEnabled = true; this.ltRect.resetForRotation(); } this.from.x = this.ltRect.rotation; break; case TweenAction.ALPHA_VERTEX: this.from.x = trans.GetComponent<MeshFilter>().mesh.colors32[0].a; break; case TweenAction.CALLBACK: break; case TweenAction.CALLBACK_COLOR: this.diff = new Vector3(1.0f, 0.0f, 0.0f); break; case TweenAction.COLOR: #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 if(trans.gameObject.renderer){ Color col = trans.gameObject.renderer.material.color; this.setFromColor( col ); }else if(trans.childCount>0){ foreach (Transform child in trans) { if(child.gameObject.renderer!=null){ Color col = child.gameObject.renderer.material.color; this.setFromColor( col ); break; } } } #else SpriteRenderer renColor = trans.gameObject.GetComponent<SpriteRenderer>(); if (renColor != null) { Color col = renColor.color; this.setFromColor(col); } else { if (trans.gameObject.GetComponent<Renderer>() != null && trans.gameObject.GetComponent<Renderer>().material.HasProperty("_Color")) { Color col = trans.gameObject.GetComponent<Renderer>().material.color; this.setFromColor(col); } else if (trans.gameObject.GetComponent<Renderer>() != null && trans.gameObject.GetComponent<Renderer>().material.HasProperty("_TintColor")) { Color col = trans.gameObject.GetComponent<Renderer>().material.GetColor("_TintColor"); this.setFromColor(col); } else if (trans.childCount > 0) { foreach (Transform child in trans) { if (child.gameObject.GetComponent<Renderer>() != null) { Color col = child.gameObject.GetComponent<Renderer>().material.color; this.setFromColor(col); break; } } } } #endif break; #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 case TweenAction.CANVAS_ALPHA: this.uiImage = trans.gameObject.GetComponent<UnityEngine.UI.Image>(); if (this.uiImage != null) this.from.x = this.uiImage.color.a; break; case TweenAction.CANVAS_COLOR: this.uiImage = trans.gameObject.GetComponent<UnityEngine.UI.Image>(); if (this.uiImage != null) this.setFromColor(this.uiImage.color); break; case TweenAction.TEXT_ALPHA: this.uiText = trans.gameObject.GetComponent<UnityEngine.UI.Text>(); if (this.uiText != null) this.from.x = this.uiText.color.a; break; case TweenAction.TEXT_COLOR: this.uiText = trans.gameObject.GetComponent<UnityEngine.UI.Text>(); if (this.uiText != null) this.setFromColor(this.uiText.color); break; case TweenAction.CANVAS_MOVE: this.from = this.rectTransform.anchoredPosition3D; break; case TweenAction.CANVAS_ROTATEAROUND: case TweenAction.CANVAS_ROTATEAROUND_LOCAL: this.lastVal = 0.0f; this.from.x = 0.0f; this.origRotation = this.rectTransform.rotation; break; case TweenAction.CANVAS_SCALE: this.from = this.rectTransform.localScale; break; case TweenAction.CANVAS_PLAYSPRITE: this.uiImage = trans.gameObject.GetComponent<UnityEngine.UI.Image>(); this.from.x = 0f; break; #endif } if (this.type != TweenAction.CALLBACK_COLOR && this.type != TweenAction.COLOR && this.type != TweenAction.TEXT_COLOR && this.type != TweenAction.CANVAS_COLOR) this.diff = this.to - this.from; if (this.onCompleteOnStart) { if (this.onComplete != null) { this.onComplete(); } else if (this.onCompleteObject != null) { this.onCompleteObject(this.onCompleteParam); } } }
/// <summary> /// Finds the UI Text object that displays the current floor in the HUD /// </summary> protected virtual void Start() { LevelText = GameObject.FindGameObjectWithTag("LevelText").GetComponent <UnityEngine.UI.Text>(); }
public void AssignColorsToSelection(GameObject gameObject) { recursiveLevel++; if (gameObject.GetComponent <UnityEngine.UI.Button>()) { UnityEngine.UI.Button button = gameObject.GetComponent <UnityEngine.UI.Button>(); SetColorBlock(button); SetDetailColor(gameObject); EditorUtility.SetDirty(button); } else if (gameObject.GetComponent <UnityEngine.UI.InputField>()) { UnityEngine.UI.InputField input = gameObject.GetComponent <UnityEngine.UI.InputField>(); SetColorBlock(input); input.selectionColor = highlighted; Undo.RecordObject(input.textComponent, "Change Text color"); input.textComponent.color = pressed; Undo.RecordObject(input.placeholder, "Change Placeholder color"); input.placeholder.color = highlighted; EditorUtility.SetDirty(input); EditorUtility.SetDirty(input.textComponent); EditorUtility.SetDirty(input.placeholder); } else if (gameObject.GetComponent <UnityEngine.UI.Scrollbar>()) { UnityEngine.UI.Scrollbar sb = gameObject.GetComponent <UnityEngine.UI.Scrollbar>(); SetColorBlock(sb); Undo.RecordObject(gameObject.GetComponent <UnityEngine.UI.Image>(), "Change Image color"); gameObject.GetComponent <UnityEngine.UI.Image>().color = disabled; EditorUtility.SetDirty(sb); EditorUtility.SetDirty(gameObject.GetComponent <UnityEngine.UI.Image>()); } else if (gameObject.GetComponent <UnityEngine.UI.Slider>()) { UnityEngine.UI.Slider slider = gameObject.GetComponent <UnityEngine.UI.Slider>(); SetColorBlock(slider); Undo.RecordObject(slider.fillRect.gameObject.GetComponent <UnityEngine.UI.Image>(), "Change Image color"); slider.fillRect.gameObject.GetComponent <UnityEngine.UI.Image>().color = normal; SetTextColorRecursive(gameObject); EditorUtility.SetDirty(slider); EditorUtility.SetDirty(slider.fillRect.gameObject.GetComponent <UnityEngine.UI.Image>()); } else if (gameObject.GetComponent <UnityEngine.UI.Toggle>()) { UnityEngine.UI.Toggle toggle = gameObject.GetComponent <UnityEngine.UI.Toggle>(); SetColorBlock(toggle); Undo.RecordObject(toggle.graphic, "Change Image color"); toggle.graphic.color = normal; SetTextColorRecursive(gameObject); EditorUtility.SetDirty(toggle); EditorUtility.SetDirty(toggle.graphic); } else if (gameObject.transform.childCount > 0) // Recursive search for components { for (int i = 0; i < gameObject.transform.childCount; i++) { AssignColorsToSelection(gameObject.transform.GetChild(i).gameObject); } } else if (recursiveLevel == 1) { if (gameObject.GetComponent <UnityEngine.UI.Image>()) { UnityEngine.UI.Image image = gameObject.GetComponent <UnityEngine.UI.Image>(); Undo.RecordObject(image, "Change color"); image.color = normal; EditorUtility.SetDirty(image); } else if (gameObject.GetComponent <UnityEngine.UI.Text>()) { UnityEngine.UI.Text text = gameObject.GetComponent <UnityEngine.UI.Text>(); Undo.RecordObject(text, "Change color"); text.color = normal; EditorUtility.SetDirty(text); } } }
void Start() { m_gamepad = GetComponent<HFTGamepad>(); m_renderer = GetComponent<Renderer>(); m_position = transform.localPosition; m_text = transform.FindChild("NameUI/Name").gameObject.GetComponent<UnityEngine.UI.Text>(); m_rawImage = transform.FindChild("NameUI/NameBackground").gameObject.GetComponent<UnityEngine.UI.RawImage>(); m_rawImage.material = (Material)Instantiate(m_rawImage.material); // Notify us if the name changes. m_gamepad.OnNameChange += ChangeName; // Delete ourselves if disconnected m_gamepad.OnDisconnect += Remove; SetName(m_gamepad.Name); SetColor(m_gamepad.Color); }
/// <summary> /// Displays the horizontal aligment control. /// </summary> /// <param name="position">Position.</param> /// <param name="property">Property.</param> private void DisplayHorizontalAligmentControl(Rect position, SerializedProperty property) { TextAnchor intValue = (TextAnchor)property.intValue; HorizontalTextAligment horizontalAlignment = intValue.GetHorizontalAlignment(); bool flag = horizontalAlignment == HorizontalTextAligment.Left; bool flag2 = horizontalAlignment == HorizontalTextAligment.Center; bool flag3 = horizontalAlignment == HorizontalTextAligment.Right; if (property.hasMultipleDifferentValues) { Object[] targetObjects = property.serializedObject.targetObjects; for (int i = 0; i < targetObjects.Length; i++) { Object obj = targetObjects [i]; UnityEngine.UI.Text text = obj as UnityEngine.UI.Text; horizontalAlignment = text.alignment.GetHorizontalAlignment(); flag = flag || horizontalAlignment == HorizontalTextAligment.Left; flag2 = flag2 || horizontalAlignment == HorizontalTextAligment.Center; flag3 = flag3 || horizontalAlignment == HorizontalTextAligment.Right; } } position.width = 20f; EditorGUI.BeginChangeCheck(); EditorToggle( position, !flag ? s_Styles.GetStaticFieldValue <GUIContent>("m_LeftAlignText") : s_Styles.GetStaticFieldValue <GUIContent>("m_LeftAlignTextActive"), flag, s_Styles.GetStaticFieldValue <GUIStyle>("alignmentButtonLeft") ); if (EditorGUI.EndChangeCheck()) { SetHorizontalAlignment(property, HorizontalTextAligment.Left); } position.x += position.width; EditorGUI.BeginChangeCheck(); EditorToggle( position, !flag2 ? s_Styles.GetStaticFieldValue <GUIContent>("m_CenterAlignText") : s_Styles.GetStaticFieldValue <GUIContent>("m_CenterAlignTextActive"), flag2, s_Styles.GetStaticFieldValue <GUIStyle>("alignmentButtonMid") ); if (EditorGUI.EndChangeCheck()) { SetHorizontalAlignment(property, HorizontalTextAligment.Center); } position.x += position.width; EditorGUI.BeginChangeCheck(); EditorToggle( position, !flag3 ? s_Styles.GetStaticFieldValue <GUIContent>("m_RightAlignText") : s_Styles.GetStaticFieldValue <GUIContent>("m_RightAlignTextActive"), flag3, s_Styles.GetStaticFieldValue <GUIStyle>("alignmentButtonRight") ); if (EditorGUI.EndChangeCheck()) { this.SetHorizontalAlignment(property, HorizontalTextAligment.Right); } }
internal Text (GameObject parent, string content, bool visible) : base (Addon.Instantiate (parent, "Text"), visible) { text = GameObject.GetComponent<UnityEngine.UI.Text> (); Content = content; }