/// <summary> /// 创建输入文本 /// </summary> /// <returns>The input field.</returns> /// <param name="imgurl">Imgurl.</param> /// <param name="tip">Tip.</param> public UIInputField CreateInputField(string imgurl, string tip) { InputField go = CreateUI <InputField> (); AppendComponent <Image> (go); UIText placeholder = CreateText(tip, 16); placeholder.name = "Placeholder"; AddChild(go, placeholder); UIText text = CreateText("", 16); text.SupportRichText = false; AddChild(go, text); UIInputField ui = AppendControl <UIInputField> (go); ui.TargetGraphic = go.image; ui.Background.Url = imgurl; ui.Placeholder = placeholder.GetComponent <Text>(); ui.LabelComponent = text.GetComponent <Text>(); ui.InputType = InputField.InputType.Standard; return(ui); }
public override void UpdateItem(List <object> list) { ItemInfo info = list[index] as ItemInfo; textItem.text = info.title; textItem.color = AppRes.colorTitle; TextureUtil.UpdateImageTexture(imageItem.image, info.pic, true); RectTransform rctran = imageItem.GetComponent <RectTransform>(); float w = imageItem.image.sprite.texture.width; //rectTransform.rect.width; float h = imageItem.image.sprite.texture.height; //rectTransform.rect.height; RectTransform rctranText = textItem.GetComponent <RectTransform>(); RectTransform rctranContent = objContent.GetComponent <RectTransform>(); float oft_y = rctranText.rect.height; float scalex = width / w; float scaley = (height - oft_y) / h; float scale = Mathf.Min(scalex, scaley); Debug.Log(" rctranContent.RECT=" + rctranContent.rect + " width=" + width + " height=" + height + "w =" + w); imageItem.transform.localScale = new Vector3(scale, scale, 1.0f); float x = 0; float y = oft_y / 2; rctran.anchoredPosition = new Vector2(x, y); }
protected void Start() { AddItemClickListener(ItemClicked); UIText introText = GetItem <UIText>("LblIntro"); LerpColor lerpColor = introText.GetComponent <LerpColor>(); lerpColor.PlayIn(); }
IEnumerator ShowText() { for (int i = 0; i < sentences.Length; i++) { Btn.SetActive(false); currentText = sentences.Substring(0, i + 1); UIText.GetComponent <UnityEngine.UI.Text>().text = currentText; yield return(new WaitForSeconds(delay)); if (Input.GetMouseButton(0)) { UIText.GetComponent <UnityEngine.UI.Text>().text = sentences; break; } } showButton(); }
public void Kembang6() { deskripsi = "Sedap Malam, Merupakan salah satu bunga yang memiliki bau yang sangat harum sehingga minyaknya sering digunakan sebagai bahan pembuatan parfum"; UIText.GetComponent <UnityEngine.UI.Text>().text = deskripsi; WinPopped(); PopKb6.SetActive(true); //lainnya false PopKeris.SetActive(false); PopBatiq.SetActive(false); PopKb1.SetActive(false); PopKb2.SetActive(false); PopKb3.SetActive(false); PopKb4.SetActive(false); PopKb5.SetActive(false); PopWayang.SetActive(false); PopKb7.SetActive(false); }
public void Kembang7() { deskripsi = "Kenanga, Merupakan salah satu jenis bunga yang cukup populer di Indonesia. Selain sering digunakan sebagai campuran obat herbal, tumbuhan ini juga sering dikaitkan dengan hal-hal mistis."; UIText.GetComponent <UnityEngine.UI.Text>().text = deskripsi; WinPopped(); PopKb7.SetActive(true); //lainnya false PopKeris.SetActive(false); PopBatiq.SetActive(false); PopKb1.SetActive(false); PopKb2.SetActive(false); PopKb3.SetActive(false); PopKb4.SetActive(false); PopKb5.SetActive(false); PopKb6.SetActive(false); PopWayang.SetActive(false); }
public void Kembang4() { deskripsi = "Kantil, Merupakan salah satu jenis bunga yang sering digunakan dalam upacara atau ritual tradisional dalam adat tertentu di Indonesia. Tumbuhan bunga kantil dianggap sebagai salah satu tanaman yang paling disukai oleh makhluk halus."; UIText.GetComponent <UnityEngine.UI.Text>().text = deskripsi; WinPopped(); PopKb4.SetActive(true); //lainnya false PopKeris.SetActive(false); PopBatiq.SetActive(false); PopKb1.SetActive(false); PopKb2.SetActive(false); PopKb3.SetActive(false); PopWayang.SetActive(false); PopKb5.SetActive(false); PopKb6.SetActive(false); PopKb7.SetActive(false); }
public void Kembang5() { deskripsi = "Melati, Merupakan tanaman yang populer di Indonesia. Karena harumnya yang semerbak, melati sering digunakan dalam berbagai ritual sakral, seperti upacara pernikahan dan berbagai hal mistis"; UIText.GetComponent <UnityEngine.UI.Text>().text = deskripsi; WinPopped(); PopKb5.SetActive(true); //lainnya false PopKeris.SetActive(false); PopBatiq.SetActive(false); PopKb1.SetActive(false); PopKb2.SetActive(false); PopKb3.SetActive(false); PopKb4.SetActive(false); PopWayang.SetActive(false); PopKb6.SetActive(false); PopKb7.SetActive(false); }
public void Kembang3() { deskripsi = "Cempaka, Merupakan tanaman hias dengan ciri khas warna kuning dan putih pada kelopaknya. Biji dari bunga ini sangat disukai oleh burung sebagai makanan."; UIText.GetComponent <UnityEngine.UI.Text>().text = deskripsi; WinPopped(); PopKb3.SetActive(true); //lainnya false PopKeris.SetActive(false); PopBatiq.SetActive(false); PopKb1.SetActive(false); PopKb2.SetActive(false); PopWayang.SetActive(false); PopKb4.SetActive(false); PopKb5.SetActive(false); PopKb6.SetActive(false); PopKb7.SetActive(false); }
public void Kembang2() { deskripsi = "Mawar Putih, Sejenis tanaman semak dengan ciri khas bunga yang merekah dan harum. Mawar merupakan satu dari sekian jenis bunga yang sering digunakan untuk ritual mistis di Indonesia"; UIText.GetComponent <UnityEngine.UI.Text>().text = deskripsi; WinPopped(); PopKb2.SetActive(true); //lainnya false PopKeris.SetActive(false); PopBatiq.SetActive(false); PopKb1.SetActive(false); PopWayang.SetActive(false); PopKb3.SetActive(false); PopKb4.SetActive(false); PopKb5.SetActive(false); PopKb6.SetActive(false); PopKb7.SetActive(false); }
public void Btk() { deskripsi = "Lurik, Kain dengan motif garis-garis yang kemudian digunakan sebagai pakaian tradisional Jawa untuk kaum pria. Makna dari garis-garis tersebut adalah simbol dari kesederhanaan."; UIText.GetComponent <UnityEngine.UI.Text>().text = deskripsi; WinPopped(); PopBatiq.SetActive(true); //lainnya false PopKeris.SetActive(false); PopWayang.SetActive(false); PopKb1.SetActive(false); PopKb2.SetActive(false); PopKb3.SetActive(false); PopKb4.SetActive(false); PopKb5.SetActive(false); PopKb6.SetActive(false); PopKb7.SetActive(false); }
public void Krs() { deskripsi = "Keris, Merupakan senjata tradisional sejenis belati yang fungsinya untuk menikam. Saat ini, keris banyak digunakan dalam berbagai ritual mistis, maupun aksesoris pakaian khas Jawa untuk prias"; UIText.GetComponent <UnityEngine.UI.Text>().text = deskripsi; WinPopped(); PopKeris.SetActive(true); //lainnya false PopWayang.SetActive(false); PopBatiq.SetActive(false); PopKb1.SetActive(false); PopKb2.SetActive(false); PopKb3.SetActive(false); PopKb4.SetActive(false); PopKb5.SetActive(false); PopKb6.SetActive(false); PopKb7.SetActive(false); }
//deskripsi item public void Wyng() { deskripsi = "Wayang, Merupakan seni pertunjukan asli Indonesia yang kisah-kisahnya erat dengan kebudayaan di Jawa, serta kaya akan nilai kehidupan"; UIText.GetComponent <UnityEngine.UI.Text>().text = deskripsi; WinPopped(); PopWayang.SetActive(true); //lainnya false PopKeris.SetActive(false); PopBatiq.SetActive(false); PopKb1.SetActive(false); PopKb2.SetActive(false); PopKb3.SetActive(false); PopKb4.SetActive(false); PopKb5.SetActive(false); PopKb6.SetActive(false); PopKb7.SetActive(false); }
static void CreateUIText() { var selectedObj = Selection.activeObject as GameObject; if (selectedObj != null) { GameObject obj = PrefabCache.main.Load("Common/Prefab/UIKit/UIText/UIText"); if (obj != null) { UIText uiPrefab = obj.GetComponent <UIText>(); UIText ui = (UIText)GameObject.Instantiate(uiPrefab); ui.transform.SetParent(selectedObj.transform); Selection.activeGameObject = ui.gameObject; ui.transform.localScale = new Vector3(1f, 1f, 1f); RectTransform rctran = ui.GetComponent <RectTransform>(); rctran.anchoredPosition = Vector2.zero; } } }
public override void LayOut() { base.LayOut(); RectTransform rctran = this.GetComponent <RectTransform>(); RectTransform rctranText = textTitle.GetComponent <RectTransform>(); RectTransform rctranImage = imageBg.GetComponent <RectTransform>(); float x, y, w, h; float scale, scalex, scaley; textTitle.gameObject.SetActive(true); imageBg.gameObject.SetActive(true); switch (_type) { case Type.NONE: { } break; case Type.IMAGE_ONLY: { textTitle.gameObject.SetActive(false); //image { w = rctran.rect.width; h = rctran.rect.height; if ((imageBg.image.sprite.texture != null) && (imageBg.image.sprite.texture.width != 0) && (imageBg.image.sprite.texture.height != 0)) { scalex = w / imageBg.image.sprite.texture.width; scaley = h / imageBg.image.sprite.texture.height; scale = Mathf.Min(scalex, scaley); imageBg.transform.localScale = new Vector3(scale, scale, 1f); } x = 0; y = 0; rctranImage.anchoredPosition = new Vector2(x, y); } } break; case Type.TEXT_ONLY: { imageBg.gameObject.SetActive(false); //text { if (Common.BlankString(textTitle.text)) { w = rctran.rect.width; } else { w = Common.GetStringLength(textTitle.text, AppString.STR_FONT_NAME, textTitle.fontSize); } h = rctran.rect.height; rctranText.sizeDelta = new Vector2(w, h); x = 0; y = 0; rctranText.anchoredPosition = new Vector2(x, y); } } break; case Type.IMAGE_UP_TEXT_DOWN: { //text { if (Common.BlankString(textTitle.text)) { w = rctran.rect.width; } else { w = Common.GetStringLength(textTitle.text, AppString.STR_FONT_NAME, textTitle.fontSize); } h = 100; rctranText.sizeDelta = new Vector2(w, h); x = 0; y = -rctran.rect.height / 2 + h / 2; rctranText.anchoredPosition = new Vector2(x, y); } //image { w = rctran.rect.width; h = rctran.rect.height - rctranText.rect.height; if ((imageBg.image.sprite.texture != null) && (imageBg.image.sprite.texture.width != 0) && (imageBg.image.sprite.texture.height != 0)) { scalex = w / imageBg.image.sprite.texture.width; scaley = h / imageBg.image.sprite.texture.height; scale = Mathf.Min(scalex, scaley); imageBg.transform.localScale = new Vector3(scale, scale, 1f); } x = 0; y = rctran.rect.height / 2 - h / 2; rctranImage.anchoredPosition = new Vector2(x, y); } } break; case Type.IMAGE_TEXT: { //text { if (Common.BlankString(textTitle.text)) { w = rctran.rect.width; } else { w = Common.GetStringLength(textTitle.text, AppString.STR_FONT_NAME, textTitle.fontSize); } h = rctran.rect.height; rctranText.sizeDelta = new Vector2(w, h); x = 0; y = 0; rctranText.anchoredPosition = new Vector2(x, y); } //image { w = rctran.rect.width; h = rctran.rect.height; // if ((imageBg.image.sprite.texture != null) && (imageBg.image.sprite.texture.width != 0) && (imageBg.image.sprite.texture.height != 0)) // { // scalex = w / imageBg.image.sprite.texture.width; // scaley = h / imageBg.image.sprite.texture.height; // scale = Mathf.Min(scalex, scaley); // imageBg.transform.localScale = new Vector3(scale, scale, 1f); // } rctranImage.sizeDelta = new Vector2(w, h); x = 0; y = 0; rctranImage.anchoredPosition = new Vector2(x, y); } } break; } }