public override void OnInit() { base.OnInit(); m_ObjOptionalRoot = FindChild("OptionalRoot"); m_ObjOptionalTemplate = FindChild("OptionalTextureTemplate"); m_OptionalMap = new Dictionary<string, RegularityOptionalElement>(); m_UICamera = WindowManager.Instance.GetUICamera(); m_ObjWinRoot = FindChild("Win"); m_ObjLoseRoot = FindChild("Lose"); m_PopList = FindChildComponent<UIPopupList>("PopupList"); m_ButtonRoot = FindChild("ButtonRoot"); m_Grid = m_ObjOptionalRoot.GetComponent<UIGrid>(); m_LabelLeftTime = FindChildComponent<UILabel>("Label_LeftTime"); m_LabelLeftCount = FindChildComponent<UILabel>("Label_LeftCount"); m_FlowerList = new List<GameObject>(); for (int i = 0; i < 3; ++i) { var obj = FindChild("Flower"+i); m_FlowerList.Add(obj); } AddChildElementClickEvent(OnClickReset, "UIButton_ResetElem"); AddChildElementClickEvent(OnClickResetById, "UIButton_Reset"); AddChildElementClickEvent(OnClickBack, "UIButton_BackElem"); AddChildElementClickEvent(OnClickBack, "UIButton_Back"); AddChildElementClickEvent(OnClickBack, "Button_Exit"); m_ObjLoseRoot.SetActive(false); m_ObjWinRoot.SetActive(false); m_ButtonRoot.SetActive(false); }
void Start () { mList = GetComponent<UIPopupList>(); UpdateList(); mList.eventReceiver = gameObject; mList.functionName = "OnLanguageSelection"; }
private void Start() { this.mList = base.GetComponent<UIPopupList>(); this.UpdateList(); this.mList.eventReceiver = base.gameObject; this.mList.functionName = "OnLanguageSelection"; }
/// <summary> /// Cache the components and register a listener callback. /// </summary> void Awake () { mList = GetComponent<UIPopupList>(); mCheck = GetComponent<UICheckbox>(); if (mList != null) mList.onSelectionChange += SaveSelection; if (mCheck != null) mCheck.onStateChange += SaveState; }
private void InitializeValuesAndReferences() { var uSizePopup = gameObject.GetSafeFirstMonoBehaviourInChildren<GuiUniverseSizePopupList>(); _universeSizePopupList = uSizePopup.gameObject.GetSafeMonoBehaviour<UIPopupList>(); PopulateAIPlayerFolderLookup(); EventDelegate.Add(_universeSizePopupList.onChange, OnUniverseSizeSelectionChanged); }
void Start() { if (popupList == null) popupList = GetComponent<UIPopupList>(); popupList.onChange.Add(new EventDelegate(this, "OnChange")); Invoke("Refresh", 0.02f); }
void Awake () { Object.DontDestroyOnLoad (GameObject.Find ("PC Packet")); PC = GameObject.Find ("PC Packet").GetComponent<Character> (); UI = GetComponent<UIController> (); ClassSelectList = GameObject.Find ("Class Select: List") .GetComponent<UIPopupList> (); NameInput = GameObject.Find ("Name: Input") .GetComponent<UIInput> (); }
protected override void Awake() { base.Awake(); popupList = gameObject.GetSafeMonoBehaviourComponent<UIPopupList>(); ConfigurePopupList(); InitializeListValues(); InitializeSelection(); // don't receive events until initializing is complete EventDelegate.Add(popupList.onChange, OnPopupListSelectionChange); //popupList.onSelectionChange += OnPopupListSelectionChange; }
void showItemsInCategory(string aCategory,UIPopupList aList) { aList.Clear(); BetterList<MoveAnimationLibItem> items = MovesAnimationLib.REF.items; for(int i = 0 ;i<items.size;i++) { if(items[i].category==aCategory) { aList.AddItem(items[i].name,items[i]); } } }
// Use this for initialization void Start () { popList = GetComponent<UIPopupList>(); if(popList == null) return; popList.Clear(); List<DataTable> tableList = ConstDataManager.Instance.ListTables(); foreach(DataTable table in tableList) { popList.AddItem(table.Name); } }
private UISlider changVolume; //调解音量 void Start() { selectMusic = transform.FindChild("SelectMusic").GetComponent<UIPopupList>(); selectMusic.Clear(); AudioClip[] bgMusics = Resources.LoadAll<AudioClip>("BgMusic"); for (int i = 0; i < bgMusics.Length; i++) { selectMusic.AddItem(bgMusics[i].name); } EventDelegate.Add(selectMusic.onChange, OnMusicChange); changVolume = transform.FindChild("VolumeSolider").GetComponent<UISlider>(); EventDelegate.Add(changVolume.onChange, OnChangeVolume); }
public override void Awake() { base.Awake(); _uiPopupList = GetComponent<UIPopupList>(); if (_uiPopupList != null) { _nativeEventReceiver = _uiPopupList.eventReceiver; _nativeFunctionName = _uiPopupList.functionName; _uiPopupList.eventReceiver = gameObject; _uiPopupList.functionName = "OnSelectionChange"; } }
/// <summary> /// Raises the map selection change event. /// </summary> /// <param name='sender'> /// Poplist that called this message. /// </param> /// void OnMapSelectionChange(UIPopupList sender) { // Finds map from list, with name, that equals to poplist selection MapData selectedMap = MidSceneObject.Instance.mapSaveCollection.maps.Find (delegate(MapData map) { return map.name == sender.selection; }); // Remove all player labels and poplists for (int i = 0; i < playerLabels.Count; i++) { Destroy (playerLabels [i].gameObject); Destroy (playerRacePopLists [i].gameObject); } playerLabels.Clear (); playerRacePopLists.Clear (); if (selectedMap != null) { // Create label and poplist for each player in map for (int i = 0; i < selectedMap.players + 1; i++) { // Label UILabel newLabel = (Instantiate (lbl_player) as GameObject).GetComponent<UILabel> (); newLabel.name = "lbl_CPUPlayer " + i; newLabel.transform.parent = pnl_NewGameMenu.transform; newLabel.transform.localPosition = lbl_player.transform.position - new Vector3 (0, 30 * i, 0); newLabel.transform.localRotation = Quaternion.identity; newLabel.transform.localScale = lbl_player.transform.lossyScale; newLabel.text = (i == 0) ? "Human Player" : "Opponent" + i; playerLabels.Add (newLabel); // PopList UIPopupList newPopList = (Instantiate (poplst_PlayerRace) as GameObject).GetComponent<UIPopupList> (); newPopList.name = "poplst_CPUPlayer " + i; newPopList.transform.parent = pnl_NewGameMenu.transform; newPopList.transform.localPosition = poplst_PlayerRace.transform.position - new Vector3 (0, 30 * i, 0); newPopList.transform.localRotation = Quaternion.identity; newPopList.transform.localScale = poplst_PlayerRace.transform.lossyScale; newPopList.items = MidSceneObject.Instance.raceSaveCollection.GetRacesNames (); newPopList.selection = newPopList.items [0]; newPopList.eventReceiver = gameObject; playerRacePopLists.Add (newPopList); } // Human Player name/text correction playerLabels [0].name = "lbl_HumanPlayer"; playerLabels [0].text = "Human Player"; playerRacePopLists [0].name = "poplst_HumanPlayer"; // Neutral Player name/text correction playerLabels [1].name = "lbl_NeutralPlayer"; playerLabels [1].text = "Neutral Player"; playerRacePopLists [1].name = "poplst_NeutralPlayer"; } }
void Start () { mList = GetComponent<UIPopupList>(); if (Localization.knownLanguages != null) { mList.items.Clear(); for (int i = 0, imax = Localization.knownLanguages.Length; i < imax; ++i) mList.items.Add(Localization.knownLanguages[i]); mList.value = Localization.language; } EventDelegate.Add(mList.onChange, OnChange); }
void Start() { if ( modeParent == null || modePrfs == null) { Debug.LogError("Missing component!"); return; } if (popupList == null) popupList = GetComponent<UIPopupList>(); popupList.onChange.Add(new EventDelegate(this, "OnChange")); Refresh(); }
private void Start() { this.mList = base.GetComponent<UIPopupList>(); if (Localization.knownLanguages != null) { this.mList.items.Clear(); int i = 0; int num = Localization.knownLanguages.Length; while (i < num) { this.mList.items.Add(Localization.knownLanguages[i]); i++; } this.mList.value = Localization.language; } EventDelegate.Add(this.mList.onChange, new EventDelegate.Callback(this.OnChange)); }
void Start () { mList = GetComponent<UIPopupList>(); if (Localization.instance != null && Localization.instance.languages != null && Localization.instance.languages.Length > 0) { mList.items.Clear(); for (int i = 0, imax = Localization.instance.languages.Length; i < imax; ++i) { TextAsset asset = Localization.instance.languages[i]; if (asset != null) mList.items.Add(asset.name); } mList.value = Localization.instance.currentLanguage; } EventDelegate.Add(mList.onChange, OnChange); }
private UIToggle isContinue; //是否继续上次游戏 void Start() { nameInput = transform.FindChild("NameInput/Label").GetComponent<UILabel>(); //下拉菜单 selectPattern = transform.FindChild("SelcetStyle").GetComponent<UIPopupList>(); selectPattern.Clear(); string[] patterns = System.Enum.GetNames(typeof(GamePattern)); for (int i = 0; i < patterns.Length; i++) { selectPattern.AddItem(patterns[i]); } //当下拉菜单值发生变化时,通知OnPatternChange方法 EventDelegate.Add(selectPattern.onChange, OnPatternChange); //单选框 isContinue = transform.FindChild("Continue").GetComponent<UIToggle>(); //当单选框值发生变化时,通知OnIsContinue方法 EventDelegate.Add(isContinue.onChange, OnIsContinue); }
private void Start() { this.mList = base.GetComponent<UIPopupList>(); if (((Localization.instance != null) && (Localization.instance.languages != null)) && (Localization.instance.languages.Length > 0)) { this.mList.items.Clear(); int index = 0; int length = Localization.instance.languages.Length; while (index < length) { TextAsset asset = Localization.instance.languages[index]; if (asset != null) { this.mList.items.Add(asset.name); } index++; } this.mList.value = Localization.instance.currentLanguage; } EventDelegate.Add(this.mList.onChange, new EventDelegate.Callback(this.OnChange)); }
void OnEnable () { SerializedProperty bit = serializedObject.FindProperty("bitmapFont"); mType = (bit.objectReferenceValue != null) ? FontType.Bitmap : FontType.Dynamic; mList = target as UIPopupList; if (mList.ambigiousFont == null) { mList.ambigiousFont = NGUISettings.ambigiousFont; mList.fontSize = NGUISettings.fontSize; mList.fontStyle = NGUISettings.fontStyle; EditorUtility.SetDirty(mList); } if (mList.atlas == null) { mList.atlas = NGUISettings.atlas; mList.backgroundSprite = NGUISettings.selectedSprite; mList.highlightSprite = NGUISettings.selectedSprite; EditorUtility.SetDirty(mList); } }
/// <summary> /// Manually close the popup list. /// </summary> public void CloseSelf () { if (mChild != null && current == this) { StopCoroutine("CloseIfUnselected"); mSelection = null; mLabelList.Clear(); if (isAnimated) { UIWidget[] widgets = mChild.GetComponentsInChildren<UIWidget>(); for (int i = 0, imax = widgets.Length; i < imax; ++i) { UIWidget w = widgets[i]; Color c = w.color; c.a = 0f; TweenColor.Begin(w.gameObject, animSpeed, c).method = UITweener.Method.EaseOut; } Collider[] cols = mChild.GetComponentsInChildren<Collider>(); for (int i = 0, imax = cols.Length; i < imax; ++i) cols[i].enabled = false; Destroy(mChild, animSpeed); mFadeOutComplete = Time.unscaledTime + Mathf.Max(0.1f, animSpeed); } else { Destroy(mChild); mFadeOutComplete = Time.unscaledTime + 0.1f; } mBackground = null; mHighlight = null; mChild = null; current = null; } }
public void GetFluidPurity1(UIPopupList pp) { Mc.Purity1 = int.Parse(pp.value); }
public override void OnInspectorGUI() { NGUIEditorTools.SetLabelWidth(80f); mList = target as UIPopupList; ComponentSelector.Draw<UIAtlas>(mList.atlas, OnSelectAtlas); ComponentSelector.Draw<UIFont>(mList.font, OnSelectFont); GUILayout.BeginHorizontal(); UILabel lbl = EditorGUILayout.ObjectField("Text Label", mList.textLabel, typeof(UILabel), true) as UILabel; if (mList.textLabel != lbl) { RegisterUndo(); mList.textLabel = lbl; if (lbl != null) lbl.text = mList.value; } GUILayout.Space(44f); GUILayout.EndHorizontal(); if (mList.textLabel == null) { EditorGUILayout.HelpBox("This popup list has no label to update, so it will behave like a menu.", MessageType.Info); } if (mList.atlas != null) { GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUILayout.Label("Options"); GUILayout.EndHorizontal(); string text = ""; foreach (string s in mList.items) text += s + "\n"; GUILayout.Space(-14f); GUILayout.BeginHorizontal(); GUILayout.Space(84f); string modified = EditorGUILayout.TextArea(text, GUILayout.Height(100f)); GUILayout.EndHorizontal(); if (modified != text) { RegisterUndo(); string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries); mList.items.Clear(); foreach (string s in split) mList.items.Add(s); if (string.IsNullOrEmpty(mList.value) || !mList.items.Contains(mList.value)) { mList.value = mList.items.Count > 0 ? mList.items[0] : ""; } } string sel = NGUIEditorTools.DrawList("Default", mList.items.ToArray(), mList.value); if (mList.value != sel) { RegisterUndo(); mList.value = sel; } UIPopupList.Position pos = (UIPopupList.Position)EditorGUILayout.EnumPopup("Position", mList.position); if (mList.position != pos) { RegisterUndo(); mList.position = pos; } bool isLocalized = EditorGUILayout.Toggle("Localized", mList.isLocalized); if (mList.isLocalized != isLocalized) { RegisterUndo(); mList.isLocalized = isLocalized; } if (NGUIEditorTools.DrawHeader("Appearance")) { NGUIEditorTools.BeginContents(); NGUIEditorTools.SpriteField("Background", mList.atlas, mList.backgroundSprite, OnBackground); NGUIEditorTools.SpriteField("Highlight", mList.atlas, mList.highlightSprite, OnHighlight); EditorGUILayout.Space(); Color tc = EditorGUILayout.ColorField("Text Color", mList.textColor); Color bc = EditorGUILayout.ColorField("Background", mList.backgroundColor); Color hc = EditorGUILayout.ColorField("Highlight", mList.highlightColor); if (mList.textColor != tc || mList.highlightColor != hc || mList.backgroundColor != bc) { RegisterUndo(); mList.textColor = tc; mList.backgroundColor = bc; mList.highlightColor = hc;; } EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.Label("Padding", GUILayout.Width(76f)); Vector2 padding = mList.padding; padding.x = EditorGUILayout.FloatField(padding.x); padding.y = EditorGUILayout.FloatField(padding.y); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (mList.padding != padding) { RegisterUndo(); mList.padding = padding; } float ts = EditorGUILayout.FloatField("Text Scale", mList.textScale, GUILayout.Width(120f)); if (mList.textScale != ts) { RegisterUndo(); mList.textScale = ts; } bool isAnimated = EditorGUILayout.Toggle("Animated", mList.isAnimated); if (mList.isAnimated != isAnimated) { RegisterUndo(); mList.isAnimated = isAnimated; } NGUIEditorTools.EndContents(); } NGUIEditorTools.DrawEvents("On Value Change", mList, mList.onChange); } }
void Awake() { mList = GetComponent <UIPopupList>(); }
private void Awake() { this.mList = base.GetComponent <UIPopupList>(); this.mCheck = base.GetComponent <UIToggle>(); this.mSlider = base.GetComponent <UIProgressBar>(); }
/// <summary> /// Trigger all event notification callbacks. /// </summary> protected void TriggerCallbacks () { if (current != this) { UIPopupList old = current; current = this; // Legacy functionality if (mLegacyEvent != null) mLegacyEvent(mSelectedItem); if (EventDelegate.IsValid(onChange)) { EventDelegate.Execute(onChange); } else if (eventReceiver != null && !string.IsNullOrEmpty(functionName)) { // Legacy functionality support (for backwards compatibility) eventReceiver.SendMessage(functionName, mSelectedItem, SendMessageOptions.DontRequireReceiver); } current = old; } }
public void addDropdownItem(GameObject obj, string item) { UIPopupList dropdown = obj.GetComponent <UIPopupList>(); dropdown.items.Add(item); }
/// <summary> /// Cache the components and register a listener callback. /// </summary> void Awake() { mList = GetComponent <UIPopupList>(); mCheck = GetComponent <UIToggle>(); }
/// <summary> /// Sets the selection index. /// </summary> public static void SetSelectionIndex(this UIPopupList context, int index) { context.value = context.items[Mathf.Clamp(index, 0, context.items.Count)]; }
public void upload(GameObject container) { UIPopupList wjs_list = container.transform.FindChild("wjs").GetComponent <UIPopupList>(); UIPopupList yhk_list = container.transform.FindChild("yhk").GetComponent <UIPopupList>(); UIInput tel_input = container.transform.FindChild("tel").GetComponent <UIInput>(); UIInput email_input = container.transform.FindChild("email").GetComponent <UIInput>(); //UIInput token_input = container.transform.FindChild("token").GetComponent<UIInput>(); if (MyUtilTools.stringIsNull(tel_input.value)) { DialogUtil.tip("请输入开户手机号码"); return; } if (tel_input.value.Length != 11) { DialogUtil.tip("手机号码尾数不对"); return; } if (!MyUtilTools.checkEmail(email_input.value)) { DialogUtil.tip("请输入合法的email"); return; } /* * if (MyUtilTools.checkEmail(token_input.value)) * { * DialogUtil.tip("请输入验证码"); * return; * }*/ Transform indent_trans = container.transform.FindChild("indents"); UITexture indent_front_texture = indent_trans.FindChild("front").FindChild("context").GetComponent <UITexture>(); if (indent_front_texture.mainTexture == null) { DialogUtil.tip("请上传身份证正面"); return; } UITexture indent_back_texture = indent_trans.FindChild("back").FindChild("context").GetComponent <UITexture>(); if (indent_back_texture.mainTexture == null) { DialogUtil.tip("请上传身份证反面"); return; } UITexture bank_texture = container.transform.FindChild("bank").FindChild("front").FindChild("context").GetComponent <UITexture>(); if (bank_texture.mainTexture == null) { DialogUtil.tip("请上传银行卡正面"); return; } SendMessageEntity entity = new SendMessageEntity(); System.DateTime tody = System.DateTime.Now; string dateStr = tody.Year + "-" + tody.Month + "-" + tody.Day + "-" + tody.Hour + "-" + tody.Minute + "-" + tody.Second + ".jpg"; entity.names.Add(tel_input.value + "-indent-front-" + dateStr); entity.names.Add(tel_input.value + "-indent-back-" + dateStr); entity.names.Add(tel_input.value + "-bank-front-" + dateStr); entity.buffer.skip(4); entity.buffer.WriteString("OpenAccountApply"); entity.buffer.WriteString(wjs_list.value); entity.buffer.WriteString(yhk_list.value); entity.buffer.WriteString(tel_input.value); entity.buffer.WriteString(email_input.value); //entity.buffer.WriteString(token_input.value); entity.buffer.WriteString(entity.names[0]); entity.buffer.WriteString(entity.names[1]); entity.buffer.WriteString(entity.names[2]); if (!isUploaded) { EventDelegate ok = new EventDelegate(this, "uploadPicOk"); ok.parameters[0] = new EventDelegate.Parameter(); ok.parameters[0].obj = entity; ok.parameters[1] = new EventDelegate.Parameter(); ok.parameters[1].obj = indent_back_texture; ok.parameters[2] = new EventDelegate.Parameter(); ok.parameters[2].obj = bank_texture; LoadUtil.show(true, "上传图片中请稍后"); JustRun.Instance.upLoadPic(entity.names[0], ((Texture2D)indent_front_texture.mainTexture).EncodeToJPG(), ok, new EventDelegate(uploadPicFail)); } else { sendMessage(entity); } }
IEnumerator OnClick() { post_value = Panel.transform.GetComponent <ToggleScene> (); post_type = post_value.post_type; Debug.Log("文章類型:" + post_type); Debug.Log("submit"); UIPopupList cityselect = GameObject.Find("CitySelect").GetComponent <UIPopupList> (); string city = cityselect.value; if (city == "台北") { city = "Taipei"; } else if (city == "台中") { city = "Taichung"; } else if (city == "台南") { city = "Tainan"; } else if (city == "新北") { city = "NewTaipei"; } else if (city == "桃園") { city = "Taoyuan"; } else if (city == "高雄") { city = "Kaohsiung"; } //進經濟地理資料庫部分 UIPopupList lbs = GameObject.Find("place_pop").GetComponent <UIPopupList>(); string lbs_name = lbs.value; if (lbs_name != null) { //StartCoroutine(xml(lbs_name)); string url = "http://egis.moea.gov.tw/innoserve/toolLoc/GetFastLocData.aspx?cmd=searchLayer2&group=0&db=ALL¶m=" + lbs_name + "&coor=84"; WWW www = new WWW(url); yield return(www); if (www.error == null) { Debug.Log("Loaded following XML " + www.data); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(www.data); XmlNode provinces = xmlDoc.SelectSingleNode("result"); Debug.Log("readxml"); foreach (XmlNode province in provinces) { XmlElement _province = (XmlElement)province; geo_x = _province.GetAttribute("Cx"); geo_y = _province.GetAttribute("Cy"); Debug.Log(geo_x); Debug.Log(geo_y); //yield return geo_x; //yield return geo_y; } } } UserTag_1 = UserTagInput[0].value; UserTag_2 = UserTagInput[1].value; UserTag_3 = UserTagInput[2].value; string userpost = userpostLabel.value; ParseObject POST = new ParseObject("POST"); if (img != null) { byte[] data = img.EncodeToJPG(); //byte[] files = System.Text.Encoding.UTF8.GetBytes(data); ParseFile file = new ParseFile("resume.jpg", data); file.SaveAsync().ContinueWith(t => { Debug.Log(file.Name); }); POST ["file"] = file; } if (lbs_name != null) { double result = Convert.ToDouble(geo_x); double result2 = Convert.ToDouble(geo_y); var point = new ParseGeoPoint(result2, result); POST ["Post_Geo"] = point; POST ["geo_place"] = lbs_name; } POST ["postfield"] = userpost; POST ["Location"] = city; POST ["foo"] = post_type; POST ["User"] = ParseUser.CurrentUser.Username; string str = POST.ObjectId; POST.SaveAsync().ContinueWith(t => { Debug.Log("文章內容:" + userpost); }); cityselect.value = "城市"; lbs.value = "確認→"; userpostLabel.value = ""; FindorSave(UserTag_1, 0); FindorSave(UserTag_2, 1); FindorSave(UserTag_3, 2); ParseObject JUDGE = new ParseObject("JUDGE"); JUDGE ["Post_Id"] = str; JUDGE ["Like"] = InitialAmount; JUDGE ["DisLike"] = InitialAmount; JUDGE.SaveAsync(); Debug.Log("save"); }
public string getDropdownSelection(GameObject obj) { UIPopupList dropdown = obj.GetComponent <UIPopupList>(); return(dropdown.value); }
public void setDropdownIndex(GameObject obj, int index) { UIPopupList dropdown = obj.GetComponent <UIPopupList>(); dropdown.value = dropdown.items[index]; }
public void deleteDropdownItem(GameObject obj) { UIPopupList dropdown = obj.GetComponent <UIPopupList>(); dropdown.items.RemoveAt(dropdown.items.Count - 1); }
public static void Close() { if (UIPopupList.current != null) { UIPopupList.current.CloseSelf(); UIPopupList.current = null; } }
public override void OnInspectorGUI() { serializedObject.Update(); NGUIEditorTools.SetLabelWidth(80f); mList = target as UIPopupList; UILabel lbl = EditorGUILayout.ObjectField("Text Label", mList.textLabel, typeof(UILabel), true) as UILabel; if (mList.textLabel != lbl) { RegisterUndo(); mList.textLabel = lbl; if (lbl != null) { lbl.text = mList.value; } } if (mList.textLabel == null) { EditorGUILayout.HelpBox("This popup list has no label to update, so it will behave like a menu.", MessageType.Info); } if (mList.atlas != null) { GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUILayout.Label("Options"); GUILayout.EndHorizontal(); string text = ""; foreach (string s in mList.items) { text += s + "\n"; } GUILayout.Space(-14f); GUILayout.BeginHorizontal(); GUILayout.Space(84f); string modified = EditorGUILayout.TextArea(text, GUILayout.Height(100f)); GUILayout.EndHorizontal(); if (modified != text) { RegisterUndo(); string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries); mList.items.Clear(); foreach (string s in split) { mList.items.Add(s); } if (string.IsNullOrEmpty(mList.value) || !mList.items.Contains(mList.value)) { mList.value = mList.items.Count > 0 ? mList.items[0] : ""; } } GUI.changed = false; string sel = NGUIEditorTools.DrawList("Default", mList.items.ToArray(), mList.value); if (GUI.changed) { serializedObject.FindProperty("mSelectedItem").stringValue = sel; } NGUIEditorTools.DrawProperty("Position", serializedObject, "position"); NGUIEditorTools.DrawProperty("Localized", serializedObject, "isLocalized"); DrawAtlas(); DrawFont(); NGUIEditorTools.DrawEvents("On Value Change", mList, mList.onChange); } serializedObject.ApplyModifiedProperties(); }
public void Show() { if (base.enabled && NGUITools.GetActive(base.gameObject) && UIPopupList.mChild == null && this.atlas != null && this.isValid && this.items.Count > 0) { this.mLabelList.Clear(); base.StopCoroutine("CloseIfUnselected"); UICamera.selectedObject = (UICamera.hoveredObject ?? base.gameObject); this.mSelection = UICamera.selectedObject; this.source = UICamera.selectedObject; if (this.source == null) { UnityEngine.Debug.LogError("Popup list needs a source object..."); return; } this.mOpenFrame = Time.frameCount; if (this.mPanel == null) { this.mPanel = UIPanel.Find(base.transform); if (this.mPanel == null) { return; } } UIPopupList.mChild = new GameObject("Drop-down List"); UIPopupList.mChild.layer = base.gameObject.layer; UIPopupList.current = this; Transform transform = UIPopupList.mChild.transform; transform.parent = this.mPanel.cachedTransform; Vector3 localPosition; Vector3 vector; Vector3 v; if (this.openOn == UIPopupList.OpenOn.Manual && this.mSelection != base.gameObject) { localPosition = UICamera.lastEventPosition; vector = this.mPanel.cachedTransform.InverseTransformPoint(this.mPanel.anchorCamera.ScreenToWorldPoint(localPosition)); v = vector; transform.localPosition = vector; localPosition = transform.position; } else { Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(this.mPanel.cachedTransform, base.transform, false, false); vector = bounds.min; v = bounds.max; transform.localPosition = vector; localPosition = transform.position; } base.StartCoroutine("CloseIfUnselected"); transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; this.mBackground = NGUITools.AddSprite(UIPopupList.mChild, this.atlas, this.backgroundSprite); this.mBackground.pivot = UIWidget.Pivot.TopLeft; this.mBackground.depth = NGUITools.CalculateNextDepth(this.mPanel.gameObject); this.mBackground.color = this.backgroundColor; Vector4 border = this.mBackground.border; this.mBgBorder = border.y; this.mBackground.cachedTransform.localPosition = new Vector3(0f, border.y, 0f); this.mHighlight = NGUITools.AddSprite(UIPopupList.mChild, this.atlas, this.highlightSprite); this.mHighlight.pivot = UIWidget.Pivot.TopLeft; this.mHighlight.color = this.highlightColor; UISpriteData atlasSprite = this.mHighlight.GetAtlasSprite(); if (atlasSprite == null) { return; } float num = (float)atlasSprite.borderTop; float num2 = (float)this.activeFontSize; float activeFontScale = this.activeFontScale; float num3 = num2 * activeFontScale; float num4 = 0f; float num5 = -this.padding.y; List<UILabel> list = new List<UILabel>(); if (!this.items.Contains(this.mSelectedItem)) { this.mSelectedItem = null; } int i = 0; int count = this.items.Count; while (i < count) { string text = this.items[i]; UILabel uILabel = NGUITools.AddWidget<UILabel>(UIPopupList.mChild); uILabel.name = i.ToString(); uILabel.pivot = UIWidget.Pivot.TopLeft; uILabel.bitmapFont = this.bitmapFont; uILabel.trueTypeFont = this.trueTypeFont; uILabel.fontSize = this.fontSize; uILabel.fontStyle = this.fontStyle; uILabel.text = ((!this.isLocalized) ? text : Localization.Get(text)); uILabel.color = this.textColor; uILabel.cachedTransform.localPosition = new Vector3(border.x + this.padding.x - uILabel.pivotOffset.x, num5, -1f); uILabel.overflowMethod = UILabel.Overflow.ResizeFreely; uILabel.alignment = this.alignment; list.Add(uILabel); num5 -= num3; num5 -= this.padding.y; num4 = Mathf.Max(num4, uILabel.printedSize.x); UIEventListener uIEventListener = UIEventListener.Get(uILabel.gameObject); uIEventListener.onHover = new UIEventListener.BoolDelegate(this.OnItemHover); uIEventListener.onPress = new UIEventListener.BoolDelegate(this.OnItemPress); uIEventListener.parameter = text; if (this.mSelectedItem == text || (i == 0 && string.IsNullOrEmpty(this.mSelectedItem))) { this.Highlight(uILabel, true); } this.mLabelList.Add(uILabel); i++; } num4 = Mathf.Max(num4, v.x - vector.x - (border.x + this.padding.x) * 2f); float num6 = num4; Vector3 vector2 = new Vector3(num6 * 0.5f, -num3 * 0.5f, 0f); Vector3 vector3 = new Vector3(num6, num3 + this.padding.y, 1f); int j = 0; int count2 = list.Count; while (j < count2) { UILabel uILabel2 = list[j]; NGUITools.AddWidgetCollider(uILabel2.gameObject); uILabel2.autoResizeBoxCollider = false; BoxCollider component = uILabel2.GetComponent<BoxCollider>(); if (component != null) { vector2.z = component.center.z; component.center = vector2; component.size = vector3; } else { BoxCollider2D component2 = uILabel2.GetComponent<BoxCollider2D>(); component2.offset = vector2; component2.size = vector3; } j++; } int width = Mathf.RoundToInt(num4); num4 += (border.x + this.padding.x) * 2f; num5 -= border.y; this.mBackground.width = Mathf.RoundToInt(num4); this.mBackground.height = Mathf.RoundToInt(-num5 + border.y); int k = 0; int count3 = list.Count; while (k < count3) { UILabel uILabel3 = list[k]; uILabel3.overflowMethod = UILabel.Overflow.ShrinkContent; uILabel3.width = width; k++; } float num7 = 2f * this.atlas.pixelSize; float f = num4 - (border.x + this.padding.x) * 2f + (float)atlasSprite.borderLeft * num7; float f2 = num3 + num * num7; this.mHighlight.width = Mathf.RoundToInt(f); this.mHighlight.height = Mathf.RoundToInt(f2); bool flag = this.position == UIPopupList.Position.Above; if (this.position == UIPopupList.Position.Auto) { UICamera uICamera = UICamera.FindCameraForLayer(this.mSelection.layer); if (uICamera != null) { flag = (uICamera.cachedCamera.WorldToViewportPoint(localPosition).y < 0.5f); } } if (this.isAnimated) { this.AnimateColor(this.mBackground); if (Time.timeScale == 0f || Time.timeScale >= 0.1f) { float bottom = num5 + num3; this.Animate(this.mHighlight, flag, bottom); int l = 0; int count4 = list.Count; while (l < count4) { this.Animate(list[l], flag, bottom); l++; } this.AnimateScale(this.mBackground, flag, bottom); } } if (flag) { vector.y = v.y - border.y; v.y = vector.y + (float)this.mBackground.height; v.x = vector.x + (float)this.mBackground.width; transform.localPosition = new Vector3(vector.x, v.y - border.y, vector.z); } else { v.y = vector.y + border.y; vector.y = v.y - (float)this.mBackground.height; v.x = vector.x + (float)this.mBackground.width; } Transform parent = this.mPanel.cachedTransform.parent; if (parent != null) { vector = this.mPanel.cachedTransform.TransformPoint(vector); v = this.mPanel.cachedTransform.TransformPoint(v); vector = parent.InverseTransformPoint(vector); v = parent.InverseTransformPoint(v); } Vector3 b = (!this.mPanel.hasClipping) ? this.mPanel.CalculateConstrainOffset(vector, v) : Vector3.zero; localPosition = transform.localPosition + b; localPosition.x = Mathf.Round(localPosition.x); localPosition.y = Mathf.Round(localPosition.y); transform.localPosition = localPosition; } else { this.OnSelect(false); } }
public override void OnInspectorGUI() { NGUIEditorTools.SetLabelWidth(80f); mList = target as UIPopupList; ComponentSelector.Draw <UIAtlas>(mList.atlas, OnSelectAtlas); ComponentSelector.Draw <UIFont>(mList.font, OnSelectFont); GUILayout.BeginHorizontal(); UILabel lbl = EditorGUILayout.ObjectField("Text Label", mList.textLabel, typeof(UILabel), true) as UILabel; if (mList.textLabel != lbl) { RegisterUndo(); mList.textLabel = lbl; if (lbl != null) { lbl.text = mList.value; } } GUILayout.Space(44f); GUILayout.EndHorizontal(); if (mList.textLabel == null) { EditorGUILayout.HelpBox("This popup list has no label to update, so it will behave like a menu.", MessageType.Info); } GUILayout.BeginHorizontal(); bool useTableDic = EditorGUILayout.Toggle("UseTableDic", mList.useDicTable, GUILayout.Width(100f)); GUILayout.EndHorizontal(); mList.useDicTable = useTableDic; if (mList.atlas != null) { GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUILayout.Label("Options"); GUILayout.EndHorizontal(); string text = ""; foreach (string s in mList.items) { text += s + "\n"; } GUILayout.Space(-14f); GUILayout.BeginHorizontal(); GUILayout.Space(84f); string modified = EditorGUILayout.TextArea(text, GUILayout.Height(100f)); GUILayout.EndHorizontal(); if (modified != text) { RegisterUndo(); string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries); mList.items.Clear(); foreach (string s in split) { mList.items.Add(s); } if (string.IsNullOrEmpty(mList.value) || !mList.items.Contains(mList.value)) { mList.value = mList.items.Count > 0 ? mList.items[0] : ""; } } string sel = NGUIEditorTools.DrawList("Default", mList.items.ToArray(), mList.value); if (mList.value != sel) { RegisterUndo(); mList.value = sel; } UIPopupList.Position pos = (UIPopupList.Position)EditorGUILayout.EnumPopup("Position", mList.position); if (mList.position != pos) { RegisterUndo(); mList.position = pos; } bool isLocalized = EditorGUILayout.Toggle("Localized", mList.isLocalized); if (mList.isLocalized != isLocalized) { RegisterUndo(); mList.isLocalized = isLocalized; } if (NGUIEditorTools.DrawHeader("Appearance")) { NGUIEditorTools.BeginContents(); NGUIEditorTools.SpriteField("Background", mList.atlas, mList.backgroundSprite, OnBackground); NGUIEditorTools.SpriteField("Highlight", mList.atlas, mList.highlightSprite, OnHighlight); EditorGUILayout.Space(); Color tc = EditorGUILayout.ColorField("Text Color", mList.textColor); Color bc = EditorGUILayout.ColorField("Background", mList.backgroundColor); Color hc = EditorGUILayout.ColorField("Highlight", mList.highlightColor); if (mList.textColor != tc || mList.highlightColor != hc || mList.backgroundColor != bc) { RegisterUndo(); mList.textColor = tc; mList.backgroundColor = bc; mList.highlightColor = hc;; } EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.Label("Padding", GUILayout.Width(76f)); Vector2 padding = mList.padding; padding.x = EditorGUILayout.FloatField(padding.x); padding.y = EditorGUILayout.FloatField(padding.y); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (mList.padding != padding) { RegisterUndo(); mList.padding = padding; } float ts = EditorGUILayout.FloatField("Text Scale", mList.textScale, GUILayout.Width(120f)); if (mList.textScale != ts) { RegisterUndo(); mList.textScale = ts; } bool isAnimated = EditorGUILayout.Toggle("Animated", mList.isAnimated); if (mList.isAnimated != isAnimated) { RegisterUndo(); mList.isAnimated = isAnimated; } NGUIEditorTools.EndContents(); } NGUIEditorTools.DrawEvents("On Value Change", mList, mList.onChange); } }
private void _issue(GameObject container, bool push) { if (!MainData.instance.user.login()) { LoginEvent.tryToLogin(); return; } if (push && !MainData.instance.user.recharge.haveMoney(10)) { DialogUtil.tip("邮游币不足"); return; } Transform trans = container.transform; UIPopupList typeList = trans.FindChild("type").GetComponent <UIPopupList>(); string addressStr = ""; if (typeList.value.Equals("现货")) { Transform address_tran = trans.FindChild("address"); UIPopupList addressList = address_tran.GetComponent <UIPopupList>(); if (addressList.value.Equals("其他")) { UIInput input = address_tran.FindChild("inputer").GetComponent <UIInput>(); if (MyUtilTools.stringIsNull(input.value)) { UILabel label = input.transform.FindChild("tips").GetComponent <UILabel>(); DialogUtil.tip(label.text); return; } addressStr = "1," + input.value; } else { addressStr = "0," + addressList.value; } } else { Transform wjs_tran = trans.FindChild("wjs-select"); UIPopupList wjsList = wjs_tran.GetComponent <UIPopupList>(); if (wjsList.value.Equals("其他文交所")) { UIInput input = wjs_tran.FindChild("inputer").GetComponent <UIInput>(); if (MyUtilTools.stringIsNull(input.value)) { UILabel label = input.transform.FindChild("tips").GetComponent <UILabel>(); DialogUtil.tip(label.text); return; } addressStr = "1," + input.value; } else { addressStr = "0," + wjsList.value; } } UIInput input_name = trans.FindChild("name").GetComponent <UIInput>(); string name = input_name.value; if (MyUtilTools.stringIsNull(name)) { UILabel label = input_name.transform.FindChild("tips").GetComponent <UILabel>(); DialogUtil.tip(label.text); return; } UIInput input_num = trans.FindChild("num").GetComponent <UIInput>(); string num = input_num.value; if (MyUtilTools.stringIsNull(num)) { UILabel label = input_num.transform.FindChild("tips").GetComponent <UILabel>(); DialogUtil.tip(label.text); return; } UIInput input_price = trans.FindChild("price").GetComponent <UIInput>(); string price = input_price.value; if (MyUtilTools.stringIsNull(price)) { UILabel label = input_price.transform.FindChild("tips").GetComponent <UILabel>(); DialogUtil.tip(label.text); return; } UIPopupList danweiList = trans.FindChild("danwei").GetComponent <UIPopupList>(); int n_num = int.Parse(num); Transform time_trans = trans.FindChild("time"); UIInput year = time_trans.FindChild("year").GetComponent <UIInput>(); UIInput month = time_trans.FindChild("month").GetComponent <UIInput>(); UIInput day = time_trans.FindChild("day").GetComponent <UIInput>(); UIInput hour = time_trans.FindChild("hour").GetComponent <UIInput>(); UIInput minute = time_trans.FindChild("minute").GetComponent <UIInput>(); string time = year.value + "-" + month.value + "-" + day.value + " " + hour.value + ":" + minute.value + ":00"; UIInput input_other = trans.FindChild("other").GetComponent <UIInput>(); string other = input_other.value; UIToggle toggle = trans.FindChild("flag").GetComponent <UIToggle>(); ByteBuffer buffer = ByteBuffer.Allocate(1024); buffer.skip(4); buffer.WriteString("Issue"); buffer.WriteLong(MainData.instance.user.id); buffer.WriteByte((byte)(push?1:0)); buffer.WriteByte((byte)1); buffer.WriteByte((byte)(typeList.value.Equals("入库") ?0:1)); buffer.WriteString(addressStr); buffer.WriteString(name); buffer.WriteString(price); buffer.WriteInt(n_num); buffer.WriteString(danweiList.value); buffer.WriteString(time); buffer.WriteString(other); buffer.WriteByte((byte)(toggle.value ? 1 : 0)); NetUtil.getInstance.SendMessage(buffer); }
public void show(UIPopupList list, string title_str) { if (pre_select == null) { pre_select = Resources.Load <GameObject>("prefabs/popup-obj"); } temp = list; panel.alpha = 0.1f; gameObject.SetActive(true); CameraUtil.push(5, 3); if (title_str != null) { UILabel label_title = transform.FindChild("up").FindChild("title").GetComponentInChildren <UILabel>(); label_title.text = title_str; } UITexture back = transform.FindChild("back").GetComponent <UITexture>(); if (list.items.Count > 8) //需要滚屏 { back.height = 820; if (pre_container == null) { pre_container = Resources.Load <GameObject>("prefabs/popup-container"); } GameObject ob_temp = NGUITools.AddChild(transform.FindChild("container").gameObject, pre_container); ob_temp.name = "body"; ob_temp.transform.localPosition = new Vector3(0, -40, 0); GameObject container = ob_temp.transform.FindChild("container").gameObject; float start = 270; for (int i = 0; i < list.items.Count; i++) { string key = list.items[i]; GameObject select = NGUITools.AddChild(container, pre_select); select.name = "option" + i; select.transform.localPosition = new Vector3(0, start, 0); Transform trans = select.transform.FindChild("Label"); UILabel label = trans.GetComponent <UILabel>(); label.text = key; label.color = list.value.Equals(key) ? Color.red : Color.black; UIButton button = trans.FindChild("event").GetComponent <UIButton>(); EventDelegate event_delegate = new EventDelegate(this, "select"); event_delegate.parameters[0] = new EventDelegate.Parameter(); event_delegate.parameters[0].obj = label; button.onClick.Add(event_delegate); start -= 100; } scroll_drag.scrollView = ob_temp.GetComponent <UIScrollView>(); } else { GameObject container = transform.FindChild("container").gameObject; int len = 100; len += list.items.Count * 100; back.height = len + 20; float start = list.items.Count / 2 * 100 - (list.items.Count % 2 == 0 ? 100 : 50); for (int i = 0; i < list.items.Count; i++) { string key = list.items[i]; GameObject select = NGUITools.AddChild(container, pre_select); select.name = "option" + i; select.transform.localPosition = new Vector3(0, start, 0); Transform trans = select.transform.FindChild("Label"); UILabel label = trans.GetComponent <UILabel>(); label.text = key; label.color = list.value.Equals(key) ? Color.red : Color.black; UIButton button = trans.FindChild("event").GetComponent <UIButton>(); EventDelegate event_delegate = new EventDelegate(this, "select"); event_delegate.parameters[0] = new EventDelegate.Parameter(); event_delegate.parameters[0].obj = label; button.onClick.Add(event_delegate); start -= 100; } } }
void refreshRight() { Transform container = transform.FindChild("right"); if (users.Count == 0) { container.gameObject.SetActive(false); return; } else { container.gameObject.SetActive(true); } MainData.UserData user = users[selectIndex]; container.FindChild("account").FindChild("value").GetComponent <UILabel>().text = user.account; container.FindChild("nickName").FindChild("inputer").GetComponent <UIInput>().value = user.nikeName; container.FindChild("name").FindChild("inputer").GetComponent <UIInput>().value = user.realyName; container.FindChild("ident").FindChild("inputer").GetComponent <UIInput>().value = user.indentity; UIPopupList type = container.FindChild("type").FindChild("value").GetComponent <UIPopupList>(); UIPopupList title = container.FindChild("title").FindChild("value").GetComponent <UIPopupList>(); if (user.permission == 1) { type.value = "买家"; title.items.Clear(); title.items.Add("普通买家"); title.items.Add("高级买家"); } else if (user.permission == 2) { type.value = "卖家"; title.items.Clear(); title.items.Add("普通营销员"); title.items.Add("高级营销员"); title.items.Add("金牌营销员"); } title.value = user.title; container.FindChild("deposit").FindChild("inputer").GetComponent <UIInput>().value = user.deposit + ""; container.FindChild("deal").FindChild("inputer").GetComponent <UIInput>().value = user.credit.totalDealValue + ""; container.FindChild("credit-c").FindChild("inputer").GetComponent <UIInput>().value = user.credit.maxValue + ""; container.FindChild("credit-t").FindChild("inputer").GetComponent <UIInput>().value = user.credit.tempMaxValue + ""; container.FindChild("hp").FindChild("inputer").GetComponent <UIInput>().value = user.credit.hp + ""; container.FindChild("zp").FindChild("inputer").GetComponent <UIInput>().value = user.credit.zp + ""; container.FindChild("cp").FindChild("inputer").GetComponent <UIInput>().value = user.credit.cp + ""; container.FindChild("regist").FindChild("value").GetComponent <UILabel>().text = user.registTime; container.FindChild("time").FindChild("value").GetComponent <UILabel>().text = user.endTime; container.FindChild("wg").FindChild("inputer").GetComponent <UIInput>().value = user.breach + ""; Transform fh_body = container.FindChild("fh").FindChild("body"); UIInput reason_input = fh_body.FindChild("inputer").GetComponent <UIInput>(); reason_input.value = user.forbid.reason + ""; string nowDateStr = System.DateTime.Now.Year + "-" + System.DateTime.Now.Month + "-" + System.DateTime.Now.Day + " 23:59:59"; if (user.forbid.endTime.Equals("forever")) { reason_input.value = "永久封号"; fh_body.FindChild("time").FindChild("value").GetComponent <UILabel>().text = nowDateStr; } else if (user.forbid.endTime.Equals("null")) { reason_input.value = "未被封号"; fh_body.FindChild("time").FindChild("value").GetComponent <UILabel>().text = nowDateStr; } else { reason_input.value = user.forbid.reason + ""; fh_body.FindChild("time").FindChild("value").GetComponent <UILabel>().text = user.forbid.endTime; } if (user.addresses.Count > 0) { container.FindChild("address").FindChild("value").GetComponent <UILabel>().text = user.addresses[0]; } else { container.FindChild("address").FindChild("value").GetComponent <UILabel>().text = "未绑定地址"; } if (user.bacnkAccount.names.Count > 0) { container.FindChild("bank").FindChild("value").GetComponent <UILabel>().text = user.bacnkAccount.names[0] + " " + user.bacnkAccount.accounts[0]; } else { container.FindChild("bank").FindChild("value").GetComponent <UILabel>().text = "未绑定银行卡"; } container.FindChild("other").FindChild("inputer").GetComponent <UIInput>().value = user.other; }
public virtual void Show() { if (base.enabled && NGUITools.GetActive(base.gameObject) && UIPopupList.mChild == null && this.atlas != null && this.isValid && this.items.Count > 0) { this.mLabelList.Clear(); base.StopCoroutine("CloseIfUnselected"); UICamera.selectedObject = (UICamera.hoveredObject ?? base.gameObject); this.mSelection = UICamera.selectedObject; this.source = UICamera.selectedObject; if (this.source == null) { global::Debug.LogError("Popup list needs a source object..."); return; } this.mOpenFrame = Time.frameCount; if (this.mPanel == null) { this.mPanel = UIPanel.Find(base.transform); if (this.mPanel == null) { return; } } UIPopupList.mChild = new GameObject("Drop-down List"); UIPopupList.mChild.layer = base.gameObject.layer; if (this.separatePanel) { if (base.GetComponent <Collider>() != null) { Rigidbody rigidbody = UIPopupList.mChild.AddComponent <Rigidbody>(); rigidbody.isKinematic = true; } else if (base.GetComponent <Collider2D>() != null) { Rigidbody2D rigidbody2D = UIPopupList.mChild.AddComponent <Rigidbody2D>(); rigidbody2D.isKinematic = true; } UIPopupList.mChild.AddComponent <UIPanel>().depth = 1000000; } UIPopupList.current = this; Transform transform = UIPopupList.mChild.transform; transform.parent = this.mPanel.cachedTransform; Vector3 localPosition; Vector3 vector; Vector3 v; if (this.openOn == UIPopupList.OpenOn.Manual && this.mSelection != base.gameObject) { localPosition = UICamera.lastEventPosition; vector = this.mPanel.cachedTransform.InverseTransformPoint(this.mPanel.anchorCamera.ScreenToWorldPoint(localPosition)); v = vector; transform.localPosition = vector; localPosition = transform.position; } else { Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(this.mPanel.cachedTransform, base.transform, false, false); vector = bounds.min; v = bounds.max; transform.localPosition = vector; localPosition = transform.position; } base.StartCoroutine("CloseIfUnselected"); transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; this.mBackground = NGUITools.AddSprite(UIPopupList.mChild, this.atlas, this.backgroundSprite, (!this.separatePanel) ? NGUITools.CalculateNextDepth(this.mPanel.gameObject) : 0); this.mBackground.pivot = UIWidget.Pivot.TopLeft; this.mBackground.color = this.backgroundColor; Vector4 border = this.mBackground.border; this.mBgBorder = border.y; this.mBackground.cachedTransform.localPosition = new Vector3(0f, border.y, 0f); this.mHighlight = NGUITools.AddSprite(UIPopupList.mChild, this.atlas, this.highlightSprite, this.mBackground.depth + 1); this.mHighlight.pivot = UIWidget.Pivot.TopLeft; this.mHighlight.color = this.highlightColor; UISpriteData atlasSprite = this.mHighlight.GetAtlasSprite(); if (atlasSprite == null) { return; } float num = (float)atlasSprite.borderTop; float num2 = (float)this.activeFontSize; float activeFontScale = this.activeFontScale; float num3 = num2 * activeFontScale; float num4 = 0f; float num5 = -this.padding.y; List <UILabel> list = new List <UILabel>(); if (!this.items.Contains(this.mSelectedItem)) { this.mSelectedItem = null; } int i = 0; int count = this.items.Count; while (i < count) { string text = this.items[i]; UILabel uilabel = NGUITools.AddWidget <UILabel>(UIPopupList.mChild, this.mBackground.depth + 2); uilabel.name = i.ToString(); uilabel.pivot = UIWidget.Pivot.TopLeft; uilabel.bitmapFont = this.bitmapFont; uilabel.trueTypeFont = this.trueTypeFont; uilabel.fontSize = this.fontSize; uilabel.fontStyle = this.fontStyle; uilabel.text = ((!this.isLocalized) ? text : Localization.Get(text)); uilabel.color = this.textColor; uilabel.cachedTransform.localPosition = new Vector3(border.x + this.padding.x - uilabel.pivotOffset.x, num5, -1f); uilabel.overflowMethod = UILabel.Overflow.ResizeFreely; uilabel.alignment = this.alignment; list.Add(uilabel); num5 -= num3; num5 -= this.padding.y; num4 = Mathf.Max(num4, uilabel.printedSize.x); UIEventListener uieventListener = UIEventListener.Get(uilabel.gameObject); uieventListener.onHover = new UIEventListener.BoolDelegate(this.OnItemHover); uieventListener.onPress = new UIEventListener.BoolDelegate(this.OnItemPress); uieventListener.parameter = text; if (this.mSelectedItem == text || (i == 0 && string.IsNullOrEmpty(this.mSelectedItem))) { this.Highlight(uilabel, true); } this.mLabelList.Add(uilabel); i++; } num4 = Mathf.Max(num4, v.x - vector.x - (border.x + this.padding.x) * 2f); float num6 = num4; Vector3 vector2 = new Vector3(num6 * 0.5f, -num3 * 0.5f, 0f); Vector3 vector3 = new Vector3(num6, num3 + this.padding.y, 1f); int j = 0; int count2 = list.Count; while (j < count2) { UILabel uilabel2 = list[j]; NGUITools.AddWidgetCollider(uilabel2.gameObject); uilabel2.autoResizeBoxCollider = false; BoxCollider component = uilabel2.GetComponent <BoxCollider>(); if (component != null) { vector2.z = component.center.z; component.center = vector2; component.size = vector3; } else { BoxCollider2D component2 = uilabel2.GetComponent <BoxCollider2D>(); component2.offset = vector2; component2.size = vector3; } j++; } int width = Mathf.RoundToInt(num4); num4 += (border.x + this.padding.x) * 2f; num5 -= border.y; this.mBackground.width = Mathf.RoundToInt(num4); this.mBackground.height = Mathf.RoundToInt(-num5 + border.y); int k = 0; int count3 = list.Count; while (k < count3) { UILabel uilabel3 = list[k]; uilabel3.overflowMethod = UILabel.Overflow.ShrinkContent; uilabel3.width = width; k++; } float num7 = 2f * this.atlas.pixelSize; float f = num4 - (border.x + this.padding.x) * 2f + (float)atlasSprite.borderLeft * num7; float f2 = num3 + num * num7; this.mHighlight.width = Mathf.RoundToInt(f); this.mHighlight.height = Mathf.RoundToInt(f2); bool flag = this.position == UIPopupList.Position.Above; if (this.position == UIPopupList.Position.Auto) { UICamera uicamera = UICamera.FindCameraForLayer(this.mSelection.layer); if (uicamera != null) { flag = (uicamera.cachedCamera.WorldToViewportPoint(localPosition).y < 0.5f); } } if (this.isAnimated) { this.AnimateColor(this.mBackground); if (Time.timeScale == 0f || Time.timeScale >= 0.1f) { float bottom = num5 + num3; this.Animate(this.mHighlight, flag, bottom); int l = 0; int count4 = list.Count; while (l < count4) { this.Animate(list[l], flag, bottom); l++; } this.AnimateScale(this.mBackground, flag, bottom); } } if (flag) { vector.y = v.y - border.y; v.y = vector.y + (float)this.mBackground.height; v.x = vector.x + (float)this.mBackground.width; transform.localPosition = new Vector3(vector.x, v.y - border.y, vector.z); } else { v.y = vector.y + border.y; vector.y = v.y - (float)this.mBackground.height; v.x = vector.x + (float)this.mBackground.width; } Transform parent = this.mPanel.cachedTransform.parent; if (parent != null) { vector = this.mPanel.cachedTransform.TransformPoint(vector); v = this.mPanel.cachedTransform.TransformPoint(v); vector = parent.InverseTransformPoint(vector); v = parent.InverseTransformPoint(v); } Vector3 b = (!this.mPanel.hasClipping) ? this.mPanel.CalculateConstrainOffset(vector, v) : Vector3.zero; localPosition = transform.localPosition + b; localPosition.x = Mathf.Round(localPosition.x); localPosition.y = Mathf.Round(localPosition.y); transform.localPosition = localPosition; } else { this.OnSelect(false); } }
void Start() { popupList = GetComponent <UIPopupList>(); popupList.items.Clear(); string[] settings = new string[0]; if (fullscreenResolution) { resolutions = Screen.resolutions; resolutionMenuText = new string[resolutions.Length]; for (int i = 0; i < resolutions.Length; i++) { resolutionMenuText[i] = resolutions[i].width.ToString() + "x" + resolutions[i].height.ToString(); popupList.items.Add(resolutionMenuText[i]); } } else if (fullscreenMod) { popupList.items.Add("Windowed"); popupList.items.Add("Fullscreen"); } else if (vsyncCount) { settings = new string[2] { "Disabled", "Enabled" }; } else if (textureQuality) { settings = new string[4] { "Low", "Medium", "High", "Maximum" }; } else if (anisoQuality) { settings = new string[2] { "Disabled", "Enabled" }; } else if (waterQuality) { settings = new string[4] { "Low", "Medium", "High", "Very High" }; } else if (terrainQuality) { settings = new string[5] { "Low", "Medium", "High", "Very High", "Ultra" }; } else if (lightingMethod) { settings = new string[2] { "Forward", "Deferred" }; } else if (shadowQuality) { settings = new string[5] { "Low", "Medium", "High", "Very High", "Ultra" }; } else if (crosshairStyle) { settings = new string[3] { "Disabled", "Static", "Dynamic" }; } else if (fpsCounter) { settings = new string[2] { "False", "True" }; } else if (aimingMethod) { settings = new string[2] { "Hold (Press)", "Toggle (Click)" }; } else if (speakerMode) { settings = new string[5] { "Stereo", "Quad", "Surround", "5.1 Surround", "7.1 Surround" }; } if (!fullscreenResolution) { for (int i = 0; i < settings.Length; i++) { popupList.items.Add(settings[i]); } } InitializeValues(); }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeControls(80f); mList = target as UIPopupList; ComponentSelector.Draw <UIAtlas>(mList.atlas, OnSelectAtlas); ComponentSelector.Draw <UIFont>(mList.font, OnSelectFont); UILabel lbl = EditorGUILayout.ObjectField("Text Label", mList.textLabel, typeof(UILabel), true) as UILabel; if (mList.textLabel != lbl) { RegisterUndo(); mList.textLabel = lbl; if (lbl != null) { lbl.text = mList.selection; } } if (mList.atlas != null) { string bg = UISpriteInspector.SpriteField(mList.atlas, "Background", mList.backgroundSprite); string hl = UISpriteInspector.SpriteField(mList.atlas, "Highlight", mList.highlightSprite); if (mList.backgroundSprite != bg || mList.highlightSprite != hl) { RegisterUndo(); mList.backgroundSprite = bg; mList.highlightSprite = hl; } GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUILayout.Label("Options"); GUILayout.EndHorizontal(); string text = ""; foreach (string s in mList.items) { text += s + "\n"; } GUILayout.Space(-22f); GUILayout.BeginHorizontal(); GUILayout.Space(84f); string modified = EditorGUILayout.TextArea(text, GUILayout.Height(100f)); GUILayout.EndHorizontal(); if (modified != text) { RegisterUndo(); string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries); mList.items.Clear(); foreach (string s in split) { mList.items.Add(s); } if (string.IsNullOrEmpty(mList.selection) || !mList.items.Contains(mList.selection)) { mList.selection = mList.items.Count > 0 ? mList.items[0] : ""; } } string sel = NGUIEditorTools.DrawList("Selection", mList.items.ToArray(), mList.selection); if (mList.selection != sel) { RegisterUndo(); mList.selection = sel; } float ts = EditorGUILayout.FloatField("Text Scale", mList.textScale); Color tc = EditorGUILayout.ColorField("Text Color", mList.textColor); Color bc = EditorGUILayout.ColorField("Background", mList.backgroundColor); Color hc = EditorGUILayout.ColorField("Highlight", mList.highlightColor); GUILayout.BeginHorizontal(); bool isLocalized = EditorGUILayout.Toggle("Localized", mList.isLocalized, GUILayout.Width(100f)); bool isAnimated = EditorGUILayout.Toggle("Animated", mList.isAnimated); GUILayout.EndHorizontal(); if (mList.textScale != ts || mList.textColor != tc || mList.highlightColor != hc || mList.backgroundColor != bc || mList.isLocalized != isLocalized || mList.isAnimated != isAnimated) { RegisterUndo(); mList.textScale = ts; mList.textColor = tc; mList.backgroundColor = bc; mList.highlightColor = hc; mList.isLocalized = isLocalized; mList.isAnimated = isAnimated; } NGUIEditorTools.DrawSeparator(); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUILayout.Label("Padding", GUILayout.Width(76f)); GUILayout.BeginVertical(); GUILayout.Space(-12f); Vector2 padding = EditorGUILayout.Vector2Field("", mList.padding); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (mList.padding != padding) { RegisterUndo(); mList.padding = padding; } EditorGUIUtility.LookLikeControls(100f); GameObject go = EditorGUILayout.ObjectField("Event Receiver", mList.eventReceiver, typeof(GameObject), true) as GameObject; string fn = EditorGUILayout.TextField("Function Name", mList.functionName); if (mList.eventReceiver != go || mList.functionName != fn) { RegisterUndo(); mList.eventReceiver = go; mList.functionName = fn; } } }
// Use this for initialization void Awake() { list = GetComponent <UIPopupList>(); label = GetComponentInChildren <UILabel>(); }
/// <summary> /// Create a popup list or a menu. /// </summary> void CreatePopup(GameObject go, bool isDropDown) { if (NGUISettings.atlas != null) { NGUIEditorTools.DrawSpriteField("Foreground", "Foreground sprite (shown on the button)", NGUISettings.atlas, mListFG, OnListFG, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Background", "Background sprite (envelops the options)", NGUISettings.atlas, mListBG, OnListBG, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Highlight", "Sprite used to highlight the selected option", NGUISettings.atlas, mListHL, OnListHL, GUILayout.Width(120f)); } if (ShouldCreate(go, NGUISettings.atlas != null && NGUISettings.ambigiousFont != null)) { int depth = NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = isDropDown ? "Popup List" : "Popup Menu"; UISpriteData sphl = NGUISettings.atlas.GetSprite(mListHL); UISpriteData spfg = NGUISettings.atlas.GetSprite(mListFG); Vector2 hlPadding = new Vector2(Mathf.Max(4f, sphl.paddingLeft), Mathf.Max(4f, sphl.paddingTop)); Vector2 fgPadding = new Vector2(Mathf.Max(4f, spfg.paddingLeft), Mathf.Max(4f, spfg.paddingTop)); // Background sprite UISprite sprite = NGUITools.AddSprite(go, NGUISettings.atlas, mListFG); sprite.depth = depth; sprite.atlas = NGUISettings.atlas; sprite.pivot = UIWidget.Pivot.Left; sprite.width = Mathf.RoundToInt(150f + fgPadding.x * 2f); sprite.height = Mathf.RoundToInt(NGUISettings.fontSize + fgPadding.y * 2f); sprite.transform.localPosition = Vector3.zero; sprite.MakePixelPerfect(); // Text label UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.ambigiousFont = NGUISettings.ambigiousFont; lbl.fontSize = NGUISettings.fontSize; lbl.fontStyle = NGUISettings.fontStyle; lbl.text = go.name; lbl.pivot = UIWidget.Pivot.Left; lbl.cachedTransform.localPosition = new Vector3(fgPadding.x, 0f, 0f); lbl.AssumeNaturalSize(); // Add a collider NGUITools.AddWidgetCollider(go); // Add the popup list UIPopupList list = go.AddComponent <UIPopupList>(); list.atlas = NGUISettings.atlas; list.ambigiousFont = NGUISettings.ambigiousFont; list.fontSize = NGUISettings.fontSize; list.fontStyle = NGUISettings.fontStyle; list.backgroundSprite = mListBG; list.highlightSprite = mListHL; list.padding = hlPadding; if (isDropDown) { EventDelegate.Add(list.onChange, lbl.SetCurrentSelection); } for (int i = 0; i < 5; ++i) { list.items.Add(isDropDown ? ("List Option " + i) : ("Menu Option " + i)); } // Add the scripts go.AddComponent <UIButton>().tweenTarget = sprite.gameObject; go.AddComponent <UIPlaySound>(); Selection.activeGameObject = go; } }
/// <summary> /// Cache the components and register a listener callback. /// </summary> void Awake() { mList = GetComponent<UIPopupList>(); mCheck = GetComponent<UIToggle>(); }
public static void _resetAtlasAndFont(Transform tr, bool isClean) { UILabel lb = tr.GetComponent <UILabel> (); if (lb != null) { if (isClean) { lb.bitmapFont = null; } else { if (string.IsNullOrEmpty(lb.fontName)) { lb.bitmapFont = CLUIInit.self.emptFont; } else { lb.bitmapFont = CLUIInit.self.getFontByName(lb.fontName); //font; } } } HUDText hud = tr.GetComponent <HUDText> (); if (hud != null) { // hud.font = font; if (isClean) { hud.font = null; } else { if (string.IsNullOrEmpty(hud.fontName)) { hud.font = CLUIInit.self.emptFont; } else { hud.font = CLUIInit.self.getFontByName(hud.fontName); //font; } } } UISprite sp = tr.GetComponent <UISprite> (); if (sp != null) { // sp.atlas = atlas; if (isClean) { sp.atlas = null; } else { if (string.IsNullOrEmpty(sp.atlasName)) { sp.atlas = CLUIInit.self.emptAtlas; } else { sp.atlas = CLUIInit.self.getAtlasByName(sp.atlasName); } } } UIRichText4Chat rtc = tr.GetComponent <UIRichText4Chat> (); if (rtc != null) { if (isClean) { rtc.faceAtlas = null; } else { if (string.IsNullOrEmpty(rtc.atlasName)) { rtc.faceAtlas = CLUIInit.self.emptAtlas; } else { rtc.faceAtlas = CLUIInit.self.getAtlasByName(rtc.atlasName); } } } UIPopupList pop = tr.GetComponent <UIPopupList> (); if (pop != null) { // pop.atlas = atlas; if (isClean) { pop.atlas = null; } else { if (string.IsNullOrEmpty(pop.atlasName)) { pop.atlas = CLUIInit.self.emptAtlas; } else { pop.atlas = CLUIInit.self.getAtlasByName(pop.atlasName); } } // pop.bitmapFont = font; if (isClean) { pop.bitmapFont = null; } else { if (string.IsNullOrEmpty(pop.fontName)) { pop.bitmapFont = CLUIInit.self.emptFont; } else { pop.bitmapFont = CLUIInit.self.getFontByName(pop.fontName); //font; } } if (pop.bitmapFont == null) { pop.trueTypeFont = null; } } for (int i = 0; i < tr.childCount; i++) { _resetAtlasAndFont(tr.GetChild(i), isClean); } }
/// <summary> /// Manually close the popup list. /// </summary> static public void Close () { if (current != null) { current.CloseSelf(); current = null; } }
/// <summary> /// Create a popup list or a menu. /// </summary> void CreatePopup(GameObject go, bool isDropDown) { if (NGUISettings.atlas != null) { NGUIEditorTools.SpriteField("Foreground", "Foreground sprite (shown on the button)", NGUISettings.atlas, mListFG, OnListFG); NGUIEditorTools.SpriteField("Background", "Background sprite (envelops the options)", NGUISettings.atlas, mListBG, OnListBG); NGUIEditorTools.SpriteField("Highlight", "Sprite used to highlight the selected option", NGUISettings.atlas, mListHL, OnListHL); } if (ShouldCreate(go, NGUISettings.atlas != null && NGUISettings.font != null)) { int depth = NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = isDropDown ? "Popup List" : "Popup Menu"; UIAtlas.Sprite sphl = NGUISettings.atlas.GetSprite(mListHL); UIAtlas.Sprite spfg = NGUISettings.atlas.GetSprite(mListFG); Vector2 hlPadding = new Vector2( Mathf.Max(4f, sphl.inner.xMin - sphl.outer.xMin), Mathf.Max(4f, sphl.inner.yMin - sphl.outer.yMin)); Vector2 fgPadding = new Vector2( Mathf.Max(4f, spfg.inner.xMin - spfg.outer.xMin), Mathf.Max(4f, spfg.inner.yMin - spfg.outer.yMin)); // Background sprite UISprite sprite = NGUITools.AddSprite(go, NGUISettings.atlas, mListFG); sprite.depth = depth; sprite.atlas = NGUISettings.atlas; sprite.pivot = UIWidget.Pivot.Left; sprite.transform.localScale = new Vector3(150f + fgPadding.x * 2f, NGUISettings.font.size + fgPadding.y * 2f, 1f); sprite.transform.localPosition = Vector3.zero; sprite.MakePixelPerfect(); // Text label UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.font = NGUISettings.font; lbl.text = go.name; lbl.pivot = UIWidget.Pivot.Left; lbl.cachedTransform.localPosition = new Vector3(fgPadding.x, 0f, 0f); lbl.MakePixelPerfect(); // Add a collider NGUITools.AddWidgetCollider(go); // Add the popup list UIPopupList list = go.AddComponent <UIPopupList>(); list.atlas = NGUISettings.atlas; list.font = NGUISettings.font; list.backgroundSprite = mListBG; list.highlightSprite = mListHL; list.padding = hlPadding; if (isDropDown) { list.textLabel = lbl; } for (int i = 0; i < 5; ++i) { list.items.Add(isDropDown ? ("List Option " + i) : ("Menu Option " + i)); } // Add the scripts go.AddComponent <UIButton>().tweenTarget = sprite.gameObject; go.AddComponent <UIButtonSound>(); Selection.activeGameObject = go; } }
/// <summary> /// Show the popup list dialog. /// </summary> public void Show () { if (enabled && NGUITools.GetActive(gameObject) && mChild == null && atlas != null && isValid && items.Count > 0) { mLabelList.Clear(); StopCoroutine("CloseIfUnselected"); // Ensure the popup's source has the selection UICamera.selectedObject = (UICamera.hoveredObject ?? gameObject); mSelection = UICamera.selectedObject; source = UICamera.selectedObject; if (source == null) { Debug.LogError("Popup list needs a source object..."); return; } mOpenFrame = Time.frameCount; // Automatically locate the panel responsible for this object if (mPanel == null) { mPanel = UIPanel.Find(transform); if (mPanel == null) return; } // Calculate the dimensions of the object triggering the popup list so we can position it below it Vector3 min; Vector3 max; // Create the root object for the list mChild = new GameObject("Drop-down List"); mChild.layer = gameObject.layer; current = this; Transform t = mChild.transform; t.parent = mPanel.cachedTransform; Vector3 pos; // Manually triggered popup list on some other game object if (openOn == OpenOn.Manual && mSelection != gameObject) { pos = UICamera.lastEventPosition; min = mPanel.cachedTransform.InverseTransformPoint(mPanel.anchorCamera.ScreenToWorldPoint(pos)); max = min; t.localPosition = min; pos = t.position; } else { Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(mPanel.cachedTransform, transform, false, false); min = bounds.min; max = bounds.max; t.localPosition = min; pos = t.position; } StartCoroutine("CloseIfUnselected"); t.localRotation = Quaternion.identity; t.localScale = Vector3.one; // Add a sprite for the background mBackground = NGUITools.AddSprite(mChild, atlas, backgroundSprite); mBackground.pivot = UIWidget.Pivot.TopLeft; mBackground.depth = NGUITools.CalculateNextDepth(mPanel.gameObject); mBackground.color = backgroundColor; // We need to know the size of the background sprite for padding purposes Vector4 bgPadding = mBackground.border; mBgBorder = bgPadding.y; mBackground.cachedTransform.localPosition = new Vector3(0f, bgPadding.y, 0f); // Add a sprite used for the selection mHighlight = NGUITools.AddSprite(mChild, atlas, highlightSprite); mHighlight.pivot = UIWidget.Pivot.TopLeft; mHighlight.color = highlightColor; UISpriteData hlsp = mHighlight.GetAtlasSprite(); if (hlsp == null) return; float hlspHeight = hlsp.borderTop; float fontHeight = activeFontSize; float dynScale = activeFontScale; float labelHeight = fontHeight * dynScale; float x = 0f, y = -padding.y; List<UILabel> labels = new List<UILabel>(); // Clear the selection if it's no longer present if (!items.Contains(mSelectedItem)) mSelectedItem = null; // Run through all items and create labels for each one for (int i = 0, imax = items.Count; i < imax; ++i) { string s = items[i]; UILabel lbl = NGUITools.AddWidget<UILabel>(mChild); lbl.name = i.ToString(); lbl.pivot = UIWidget.Pivot.TopLeft; lbl.bitmapFont = bitmapFont; lbl.trueTypeFont = trueTypeFont; lbl.fontSize = fontSize; lbl.fontStyle = fontStyle; lbl.text = isLocalized ? Localization.Get(s) : s; lbl.color = textColor; lbl.cachedTransform.localPosition = new Vector3(bgPadding.x + padding.x - lbl.pivotOffset.x, y, -1f); lbl.overflowMethod = UILabel.Overflow.ResizeFreely; lbl.alignment = alignment; labels.Add(lbl); y -= labelHeight; y -= padding.y; x = Mathf.Max(x, lbl.printedSize.x); // Add an event listener UIEventListener listener = UIEventListener.Get(lbl.gameObject); listener.onHover = OnItemHover; listener.onPress = OnItemPress; listener.parameter = s; // Move the selection here if this is the right label if (mSelectedItem == s || (i == 0 && string.IsNullOrEmpty(mSelectedItem))) Highlight(lbl, true); // Add this label to the list mLabelList.Add(lbl); } // The triggering widget's width should be the minimum allowed width x = Mathf.Max(x, (max.x - min.x) - (bgPadding.x + padding.x) * 2f); float cx = x; Vector3 bcCenter = new Vector3(cx * 0.5f, -labelHeight * 0.5f, 0f); Vector3 bcSize = new Vector3(cx, (labelHeight + padding.y), 1f); // Run through all labels and add colliders for (int i = 0, imax = labels.Count; i < imax; ++i) { UILabel lbl = labels[i]; NGUITools.AddWidgetCollider(lbl.gameObject); lbl.autoResizeBoxCollider = false; BoxCollider bc = lbl.GetComponent<BoxCollider>(); if (bc != null) { bcCenter.z = bc.center.z; bc.center = bcCenter; bc.size = bcSize; } else { BoxCollider2D b2d = lbl.GetComponent<BoxCollider2D>(); #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 b2d.center = bcCenter; #else b2d.offset = bcCenter; #endif b2d.size = bcSize; } } int lblWidth = Mathf.RoundToInt(x); x += (bgPadding.x + padding.x) * 2f; y -= bgPadding.y; // Scale the background sprite to envelop the entire set of items mBackground.width = Mathf.RoundToInt(x); mBackground.height = Mathf.RoundToInt(-y + bgPadding.y); // Set the label width to make alignment work for (int i = 0, imax = labels.Count; i < imax; ++i) { UILabel lbl = labels[i]; lbl.overflowMethod = UILabel.Overflow.ShrinkContent; lbl.width = lblWidth; } // Scale the highlight sprite to envelop a single item float scaleFactor = 2f * atlas.pixelSize; float w = x - (bgPadding.x + padding.x) * 2f + hlsp.borderLeft * scaleFactor; float h = labelHeight + hlspHeight * scaleFactor; mHighlight.width = Mathf.RoundToInt(w); mHighlight.height = Mathf.RoundToInt(h); bool placeAbove = (position == Position.Above); if (position == Position.Auto) { UICamera cam = UICamera.FindCameraForLayer(mSelection.layer); if (cam != null) { Vector3 viewPos = cam.cachedCamera.WorldToViewportPoint(pos); placeAbove = (viewPos.y < 0.5f); } } // If the list should be animated, let's animate it by expanding it if (isAnimated) { AnimateColor(mBackground); if (Time.timeScale == 0f || Time.timeScale >= 0.1f) { float bottom = y + labelHeight; Animate(mHighlight, placeAbove, bottom); for (int i = 0, imax = labels.Count; i < imax; ++i) Animate(labels[i], placeAbove, bottom); AnimateScale(mBackground, placeAbove, bottom); } } // If we need to place the popup list above the item, we need to reposition everything by the size of the list if (placeAbove) { min.y = max.y - bgPadding.y; max.y = min.y + mBackground.height; max.x = min.x + mBackground.width; t.localPosition = new Vector3(min.x, max.y - bgPadding.y, min.z); } else { max.y = min.y + bgPadding.y; min.y = max.y - mBackground.height; max.x = min.x + mBackground.width; } Transform pt = mPanel.cachedTransform.parent; if (pt != null) { min = mPanel.cachedTransform.TransformPoint(min); max = mPanel.cachedTransform.TransformPoint(max); min = pt.InverseTransformPoint(min); max = pt.InverseTransformPoint(max); } // Ensure that everything fits into the panel's visible range Vector3 offset = mPanel.CalculateConstrainOffset(min, max); pos = t.localPosition + offset; pos.x = Mathf.Round(pos.x); pos.y = Mathf.Round(pos.y); t.localPosition = pos; } else OnSelect(false); }
/// <summary> /// Show the popup list dialog. /// </summary> public void Show() { if (enabled && NGUITools.GetActive(gameObject) && mChild == null && atlas != null && isValid && items.Count > 0) { mLabelList.Clear(); StopCoroutine("CloseIfUnselected"); // Ensure the popup's source has the selection UICamera.selectedObject = (UICamera.hoveredObject ?? gameObject); mSelection = UICamera.selectedObject; source = UICamera.selectedObject; if (source == null) { Debug.LogError("Popup list needs a source object..."); return; } mOpenFrame = Time.frameCount; // Automatically locate the panel responsible for this object if (mPanel == null) { mPanel = UIPanel.Find(transform); if (mPanel == null) { return; } } // Calculate the dimensions of the object triggering the popup list so we can position it below it Vector3 min; Vector3 max; // Create the root object for the list mChild = new GameObject("Drop-down List") { layer = gameObject.layer }; current = this; Transform t = mChild.transform; t.parent = mPanel.cachedTransform; Vector3 pos; // Manually triggered popup list on some other game object if (openOn == OpenOn.Manual && mSelection != gameObject) { pos = UICamera.lastEventPosition; min = mPanel.cachedTransform.InverseTransformPoint(mPanel.anchorCamera.ScreenToWorldPoint(pos)); max = min; t.localPosition = min; pos = t.position; } else { Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(mPanel.cachedTransform, transform, false, false); min = bounds.min; max = bounds.max; t.localPosition = min; pos = t.position; } StartCoroutine("CloseIfUnselected"); t.localRotation = Quaternion.identity; t.localScale = Vector3.one; // Add a sprite for the background mBackground = NGUITools.AddSprite(mChild, atlas, backgroundSprite); mBackground.pivot = UIWidget.Pivot.TopLeft; mBackground.depth = NGUITools.CalculateNextDepth(mPanel.gameObject); mBackground.color = backgroundColor; // We need to know the size of the background sprite for padding purposes Vector4 bgPadding = mBackground.border; mBgBorder = bgPadding.y; mBackground.cachedTransform.localPosition = new Vector3(0f, bgPadding.y, 0f); // Add a sprite used for the selection mHighlight = NGUITools.AddSprite(mChild, atlas, highlightSprite); mHighlight.pivot = UIWidget.Pivot.TopLeft; mHighlight.color = highlightColor; UISpriteData hlsp = mHighlight.GetAtlasSprite(); if (hlsp == null) { return; } float hlspHeight = hlsp.borderTop; float fontHeight = activeFontSize; float dynScale = activeFontScale; float labelHeight = fontHeight * dynScale; float x = 0f, y = -padding.y; List <UILabel> labels = new List <UILabel>(); // Clear the selection if it's no longer present if (!items.Contains(mSelectedItem)) { mSelectedItem = null; } // Run through all items and create labels for each one for (int i = 0, imax = items.Count; i < imax; ++i) { string s = items[i]; UILabel lbl = NGUITools.AddWidget <UILabel>(mChild); lbl.name = i.ToString(); lbl.pivot = UIWidget.Pivot.TopLeft; lbl.bitmapFont = bitmapFont; lbl.trueTypeFont = trueTypeFont; lbl.fontSize = fontSize; lbl.fontStyle = fontStyle; lbl.text = isLocalized ? Localization.Get(s) : s; lbl.color = textColor; lbl.cachedTransform.localPosition = new Vector3(bgPadding.x + padding.x - lbl.pivotOffset.x, y, -1f); lbl.overflowMethod = UILabel.Overflow.ResizeFreely; lbl.alignment = alignment; labels.Add(lbl); y -= labelHeight; y -= padding.y; x = Mathf.Max(x, lbl.printedSize.x); // Add an event listener UIEventListener listener = UIEventListener.Get(lbl.gameObject); listener.onHover = OnItemHover; listener.onPress = OnItemPress; listener.parameter = s; // Move the selection here if this is the right label if (mSelectedItem == s || (i == 0 && string.IsNullOrEmpty(mSelectedItem))) { Highlight(lbl, true); } // Add this label to the list mLabelList.Add(lbl); } // The triggering widget's width should be the minimum allowed width x = Mathf.Max(x, (max.x - min.x) - (bgPadding.x + padding.x) * 2f); float cx = x; Vector3 bcCenter = new Vector3(cx * 0.5f, -labelHeight * 0.5f, 0f); Vector3 bcSize = new Vector3(cx, (labelHeight + padding.y), 1f); // Run through all labels and add colliders for (int i = 0, imax = labels.Count; i < imax; ++i) { UILabel lbl = labels[i]; NGUITools.AddWidgetCollider(lbl.gameObject); lbl.autoResizeBoxCollider = false; BoxCollider bc = lbl.GetComponent <BoxCollider>(); if (bc != null) { bcCenter.z = bc.center.z; bc.center = bcCenter; bc.size = bcSize; } else { BoxCollider2D b2d = lbl.GetComponent <BoxCollider2D>(); #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 b2d.center = bcCenter; #else b2d.offset = bcCenter; #endif b2d.size = bcSize; } } int lblWidth = Mathf.RoundToInt(x); x += (bgPadding.x + padding.x) * 2f; y -= bgPadding.y; // Scale the background sprite to envelop the entire set of items mBackground.width = Mathf.RoundToInt(x); mBackground.height = Mathf.RoundToInt(-y + bgPadding.y); // Set the label width to make alignment work for (int i = 0, imax = labels.Count; i < imax; ++i) { UILabel lbl = labels[i]; lbl.overflowMethod = UILabel.Overflow.ShrinkContent; lbl.width = lblWidth; } // Scale the highlight sprite to envelop a single item float scaleFactor = 2f * atlas.pixelSize; float w = x - (bgPadding.x + padding.x) * 2f + hlsp.borderLeft * scaleFactor; float h = labelHeight + hlspHeight * scaleFactor; mHighlight.width = Mathf.RoundToInt(w); mHighlight.height = Mathf.RoundToInt(h); bool placeAbove = (position == Position.Above); if (position == Position.Auto) { UICamera cam = UICamera.FindCameraForLayer(mSelection.layer); if (cam != null) { Vector3 viewPos = cam.cachedCamera.WorldToViewportPoint(pos); placeAbove = (viewPos.y < 0.5f); } } // If the list should be animated, let's animate it by expanding it if (isAnimated) { AnimateColor(mBackground); if (Time.timeScale == 0f || Time.timeScale >= 0.1f) { float bottom = y + labelHeight; Animate(mHighlight, placeAbove, bottom); for (int i = 0, imax = labels.Count; i < imax; ++i) { Animate(labels[i], placeAbove, bottom); } AnimateScale(mBackground, placeAbove, bottom); } } // If we need to place the popup list above the item, we need to reposition everything by the size of the list if (placeAbove) { min.y = max.y - bgPadding.y; max.y = min.y + mBackground.height; max.x = min.x + mBackground.width; t.localPosition = new Vector3(min.x, max.y - bgPadding.y, min.z); } else { max.y = min.y + bgPadding.y; min.y = max.y - mBackground.height; max.x = min.x + mBackground.width; } Transform pt = mPanel.cachedTransform.parent; if (pt != null) { min = mPanel.cachedTransform.TransformPoint(min); max = mPanel.cachedTransform.TransformPoint(max); min = pt.InverseTransformPoint(min); max = pt.InverseTransformPoint(max); } // Ensure that everything fits into the panel's visible range Vector3 offset = mPanel.CalculateConstrainOffset(min, max); pos = t.localPosition + offset; pos.x = Mathf.Round(pos.x); pos.y = Mathf.Round(pos.y); t.localPosition = pos; } else { OnSelect(false); } }
public void CloseSelf() { if (UIPopupList.mChild != null && UIPopupList.current == this) { base.StopCoroutine("CloseIfUnselected"); this.mSelection = null; this.mLabelList.Clear(); if (this.isAnimated) { UIWidget[] componentsInChildren = UIPopupList.mChild.GetComponentsInChildren<UIWidget>(); int i = 0; int num = componentsInChildren.Length; while (i < num) { UIWidget uIWidget = componentsInChildren[i]; Color color = uIWidget.color; color.a = 0f; TweenColor.Begin(uIWidget.gameObject, 0.15f, color).method = UITweener.Method.EaseOut; i++; } Collider[] componentsInChildren2 = UIPopupList.mChild.GetComponentsInChildren<Collider>(); int j = 0; int num2 = componentsInChildren2.Length; while (j < num2) { componentsInChildren2[j].enabled = false; j++; } UnityEngine.Object.Destroy(UIPopupList.mChild, 0.15f); UIPopupList.mFadeOutComplete = Time.unscaledTime + Mathf.Max(0.1f, 0.15f); } else { UnityEngine.Object.Destroy(UIPopupList.mChild); UIPopupList.mFadeOutComplete = Time.unscaledTime + 0.1f; } this.mBackground = null; this.mHighlight = null; UIPopupList.mChild = null; UIPopupList.current = null; } }
/// <summary> /// Show the popup list dialog. /// </summary> public virtual void Show() { if (enabled && NGUITools.GetActive(gameObject) && mChild == null && isValid && items.Count > 0) { mLabelList.Clear(); StopCoroutine("CloseIfUnselected"); // Ensure the popup's source has the selection UICamera.selectedObject = (UICamera.hoveredObject ?? gameObject); mSelection = UICamera.selectedObject; source = mSelection; if (source == null) { Debug.LogError("Popup list needs a source object..."); return; } mOpenFrame = Time.frameCount; // Automatically locate the panel responsible for this object if (mPanel == null) { mPanel = UIPanel.Find(transform); if (mPanel == null) { return; } } // Calculate the dimensions of the object triggering the popup list so we can position it below it Vector3 min; Vector3 max; // Create the root object for the list mChild = new GameObject("Drop-down List"); mChild.layer = gameObject.layer; if (separatePanel) { if (GetComponent <Collider>() != null) { Rigidbody rb = mChild.AddComponent <Rigidbody>(); rb.isKinematic = true; } else if (GetComponent <Collider2D>() != null) { Rigidbody2D rb = mChild.AddComponent <Rigidbody2D>(); rb.isKinematic = true; } var panel = mChild.AddComponent <UIPanel>(); panel.depth = 1000000; panel.sortingOrder = mPanel.sortingOrder; } current = this; var pTrans = mPanel.cachedTransform; Transform t = mChild.transform; t.parent = pTrans; Transform rootTrans = pTrans; if (separatePanel) { var root = mPanel.GetComponentInParent <UIRoot>(); if (root == null && UIRoot.list.Count != 0) { root = UIRoot.list[0]; } if (root != null) { rootTrans = root.transform; } } // Manually triggered popup list on some other game object if (openOn == OpenOn.Manual && mSelection != gameObject) { startingPosition = UICamera.lastEventPosition; min = pTrans.InverseTransformPoint(mPanel.anchorCamera.ScreenToWorldPoint(startingPosition)); max = min; t.localPosition = min; startingPosition = t.position; } else { Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(pTrans, transform, false, false); min = bounds.min; max = bounds.max; t.localPosition = min; startingPosition = t.position; } StartCoroutine("CloseIfUnselected"); var f = fitScale; t.localRotation = Quaternion.identity; t.localScale = new Vector3(f, f, f); int depth = separatePanel ? 0 : NGUITools.CalculateNextDepth(mPanel.gameObject); // Add a sprite for the background if (background2DSprite != null) { UI2DSprite sp2 = mChild.AddWidget <UI2DSprite>(depth); sp2.sprite2D = background2DSprite; mBackground = sp2; } else if (atlas != null) { mBackground = NGUITools.AddSprite(mChild, atlas, backgroundSprite, depth); } else { return; } bool placeAbove = (position == Position.Above); if (position == Position.Auto) { UICamera cam = UICamera.FindCameraForLayer(mSelection.layer); if (cam != null) { Vector3 viewPos = cam.cachedCamera.WorldToViewportPoint(startingPosition); placeAbove = (viewPos.y < 0.5f); } } mBackground.pivot = UIWidget.Pivot.TopLeft; mBackground.color = backgroundColor; // We need to know the size of the background sprite for padding purposes Vector4 bgPadding = mBackground.border; mBgBorder = bgPadding.y; mBackground.cachedTransform.localPosition = new Vector3(0f, placeAbove ? bgPadding.y * 2f - overlap : overlap, 0f); // Add a sprite used for the selection if (highlight2DSprite != null) { UI2DSprite sp2 = mChild.AddWidget <UI2DSprite>(++depth); sp2.sprite2D = highlight2DSprite; mHighlight = sp2; } else if (atlas != null) { mHighlight = NGUITools.AddSprite(mChild, atlas, highlightSprite, ++depth); } else { return; } float hlspHeight = 0f, hlspLeft = 0f; if (mHighlight.hasBorder) { hlspHeight = mHighlight.border.w; hlspLeft = mHighlight.border.x; } mHighlight.pivot = UIWidget.Pivot.TopLeft; mHighlight.color = highlightColor; float labelHeight = activeFontSize * activeFontScale; float lineHeight = labelHeight + padding.y; float x = 0f, y = placeAbove ? bgPadding.y - padding.y - overlap : -padding.y - bgPadding.y + overlap; float contentHeight = bgPadding.y * 2f + padding.y; List <UILabel> labels = new List <UILabel>(); // Clear the selection if it's no longer present if (!items.Contains(mSelectedItem)) { mSelectedItem = null; } // Run through all items and create labels for each one for (int i = 0, imax = items.Count; i < imax; ++i) { string s = items[i]; UILabel lbl = NGUITools.AddWidget <UILabel>(mChild, mBackground.depth + 2); lbl.name = i.ToString(); lbl.pivot = UIWidget.Pivot.TopLeft; lbl.bitmapFont = bitmapFont; lbl.trueTypeFont = trueTypeFont; lbl.fontSize = fontSize; lbl.fontStyle = fontStyle; lbl.text = isLocalized ? Localization.Get(s) : s; lbl.modifier = textModifier; lbl.color = textColor; if (textColors.Count > i) { lbl.color = textColors[i]; } lbl.cachedTransform.localPosition = new Vector3(bgPadding.x + padding.x - lbl.pivotOffset.x, y, -1f); lbl.overflowMethod = UILabel.Overflow.ResizeFreely; lbl.alignment = alignment; lbl.symbolStyle = NGUIText.SymbolStyle.Colored; labels.Add(lbl); contentHeight += lineHeight; y -= lineHeight; x = Mathf.Max(x, lbl.printedSize.x); // Add an event listener UIEventListener listener = UIEventListener.Get(lbl.gameObject); listener.onHover = OnItemHover; listener.onPress = OnItemPress; listener.onClick = OnItemClick; listener.parameter = s; // Move the selection here if this is the right label if (mSelectedItem == s || (i == 0 && string.IsNullOrEmpty(mSelectedItem))) { Highlight(lbl, true); } // Add this label to the list mLabelList.Add(lbl); } // The triggering widget's width should be the minimum allowed width x = Mathf.Max(x, (max.x - min.x) - (bgPadding.x + padding.x) * 2f); float cx = x; Vector3 bcCenter = new Vector3(cx * 0.5f, -labelHeight * 0.5f, 0f); Vector3 bcSize = new Vector3(cx, (labelHeight + padding.y), 1f); // Run through all labels and add colliders for (int i = 0, imax = labels.Count; i < imax; ++i) { UILabel lbl = labels[i]; NGUITools.AddWidgetCollider(lbl.gameObject); lbl.autoResizeBoxCollider = false; BoxCollider bc = lbl.GetComponent <BoxCollider>(); if (bc != null) { bcCenter.z = bc.center.z; bc.center = bcCenter; bc.size = bcSize; } else { BoxCollider2D b2d = lbl.GetComponent <BoxCollider2D>(); #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 b2d.center = bcCenter; #else b2d.offset = bcCenter; #endif b2d.size = bcSize; } } int lblWidth = Mathf.RoundToInt(x); x += (bgPadding.x + padding.x) * 2f; y -= bgPadding.y; // Scale the background sprite to envelop the entire set of items mBackground.width = Mathf.RoundToInt(x); mBackground.height = Mathf.RoundToInt(contentHeight); // Set the label width to make alignment work for (int i = 0, imax = labels.Count; i < imax; ++i) { UILabel lbl = labels[i]; lbl.overflowMethod = UILabel.Overflow.ShrinkContent; lbl.width = lblWidth; } // Scale the highlight sprite to envelop a single item float scaleFactor = (atlas != null) ? 2f * atlas.pixelSize : 2f; float w = x - (bgPadding.x + padding.x) * 2f + hlspLeft * scaleFactor; float h = labelHeight + hlspHeight * scaleFactor; mHighlight.width = Mathf.RoundToInt(w); mHighlight.height = Mathf.RoundToInt(h); // If the list should be animated, let's animate it by expanding it if (isAnimated) { AnimateColor(mBackground); if (Time.timeScale == 0f || Time.timeScale >= 0.1f) { float bottom = y + labelHeight; Animate(mHighlight, placeAbove, bottom); for (int i = 0, imax = labels.Count; i < imax; ++i) { Animate(labels[i], placeAbove, bottom); } AnimateScale(mBackground, placeAbove, bottom); } } // If we need to place the popup list above the item, we need to reposition everything by the size of the list if (placeAbove) { var bgY = bgPadding.y * f; min.y = max.y - bgPadding.y * f; max.y = min.y + (mBackground.height - bgPadding.y * 2f) * f; max.x = min.x + mBackground.width * f; t.localPosition = new Vector3(min.x, max.y - bgY, min.z); } else { max.y = min.y + bgPadding.y * f; min.y = max.y - mBackground.height * f; max.x = min.x + mBackground.width * f; } var absoluteParent = mPanel; // UIRoot.list[0].GetComponent<UIPanel>(); for (;;) { var p = absoluteParent.parent; if (p == null) { break; } var pp = p.GetComponentInParent <UIPanel>(); if (pp == null) { break; } absoluteParent = pp; } if (pTrans != null) { min = pTrans.TransformPoint(min); max = pTrans.TransformPoint(max); min = absoluteParent.cachedTransform.InverseTransformPoint(min); max = absoluteParent.cachedTransform.InverseTransformPoint(max); var adj = UIRoot.GetPixelSizeAdjustment(gameObject); min /= adj; max /= adj; } // Ensure that everything fits into the panel's visible range var offset = absoluteParent.CalculateConstrainOffset(min, max); var pos = t.localPosition + offset; pos.x = Mathf.Round(pos.x); pos.y = Mathf.Round(pos.y); t.localPosition = pos; t.parent = rootTrans; } else { OnSelect(false); } }
protected void TriggerCallbacks() { if (!this.mExecuting) { this.mExecuting = true; UIPopupList uIPopupList = UIPopupList.current; UIPopupList.current = this; if (this.mLegacyEvent != null) { this.mLegacyEvent(this.mSelectedItem); } if (EventDelegate.IsValid(this.onChange)) { EventDelegate.Execute(this.onChange); } else if (this.eventReceiver != null && !string.IsNullOrEmpty(this.functionName)) { this.eventReceiver.SendMessage(this.functionName, this.mSelectedItem, SendMessageOptions.DontRequireReceiver); } UIPopupList.current = uIPopupList; this.mExecuting = false; } }
/// <summary> /// Cache the components and register a listener callback. /// </summary> void Awake() { mList = GetComponent <UIPopupList>(); mCheck = GetComponent <UIToggle>(); mSlider = GetComponent <UIProgressBar>(); }
// Use this for initialization IEnumerator OnClick() { test = GameObject.Find("place_pop").GetComponent <UIPopupList>(); mysearch = GetComponentInChildren <UILabel>(); mInput = GameObject.Find("place_input").GetComponent <UIInput>(); string place = mInput.text; Debug.Log(place); test.items.Clear(); string geo_source; string geo_x = null; string geo_y = null; string CMD; //string post = "台北101購物中心"; string url = "http://egis.moea.gov.tw/innoserve/toolLoc/GetFastLocData.aspx?cmd=searchLayer2&group=0&db=ALL¶m=" + place + "&coor=84"; WWW www = new WWW(url); //Load the data and yield (wait) till it's ready before we continue executing the rest of this method. yield return(www); if (www.error == null) { //Sucessfully loaded the XML Debug.Log("Loaded following XML " + www.data); //geo_name=xl2.GetAttribute("Addr") + ": " + xl2.InnerText; //Create a new XML document out of the loaded data XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(www.data); XmlNode provinces = xmlDoc.SelectSingleNode("result"); Debug.Log("readxml"); /* * XmlNodeList nodeList = xmlDoc.SelectNodes("result"); * int numGoods = nodeList.Count; * Debug.Log(numGoods);*/ foreach (XmlNode province in provinces) { XmlElement _province = (XmlElement)province; geo_name = _province.GetAttribute("Addr"); geo_source = _province.GetAttribute("Source"); if (geo_source == "地標") { mysearch.text = geo_name; test.items.Add(geo_name); //GetComponent<UILabel>().text = test.value; geo_x = _province.GetAttribute("Cx"); geo_y = _province.GetAttribute("Cy"); Debug.Log(geo_name); Debug.Log(geo_x); Debug.Log(geo_y); } else { mysearch.text = "無資料呦!"; //geo_name="無資料呦!"; //test.items.Add(geo_name); } } } mInput.text = ""; /* * double result = Convert.ToDouble(geo_x); * double result2 = Convert.ToDouble(geo_y); * * ParseObject POST = new ParseObject("POST"); * var point = new ParseGeoPoint(result2, result); * POST ["Post_Geo"] = point; * * POST ["geo_place"] = geo_name; * POST.SaveAsync ().ContinueWith (t => * { * Debug.Log ("文章內容:" + point); * Debug.Log ("文章內容:" + geo_name); * * });*/ }
public override void init(GameLayout layout, GameObject go, txUIObject parent) { base.init(layout, go, parent); mPopupList = mObject.GetComponent <UIPopupList>(); }
public static void registEvent(GameObject father, string name, Action function) { UISlider slider = getByName <UISlider>(father, name); if (slider != null) { MonoDelegate d = slider.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = slider.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; slider.onChange.Add(new EventDelegate(d, "function")); return; } UIPopupList list = getByName <UIPopupList>(father, name); if (list != null) { MonoDelegate d = list.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = list.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; list.onChange.Add(new EventDelegate(d, "function")); return; } UIToggle tog = getByName <UIToggle>(father, name); if (tog != null) { MonoDelegate d = tog.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = tog.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; tog.onChange.Clear(); tog.onChange.Add(new EventDelegate(d, "function")); return; } UIInput input = getByName <UIInput>(father, name); if (input != null) { MonoDelegate d = input.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = input.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; input.onSubmit.Clear(); input.onSubmit.Add(new EventDelegate(d, "function")); return; } UIScrollBar bar = getByName <UIScrollBar>(father, name); if (bar != null) { MonoDelegate d = bar.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = bar.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; bar.onChange.Clear(); bar.onChange.Add(new EventDelegate(d, "function")); return; } UIButton btn = getByName <UIButton>(father, name); if (btn != null) { MonoDelegate d = btn.gameObject.GetComponent <MonoDelegate>(); if (d == null) { d = btn.gameObject.AddComponent <MonoDelegate>(); } d.actionInMono = function; btn.onClick.Clear(); btn.onClick.Add(new EventDelegate(d, "function")); return; } }
public void setDropdownSelection(GameObject obj, string newval) { UIPopupList dropdown = obj.GetComponent <UIPopupList>(); dropdown.value = newval; }