Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: DJVDJV on November 29, 2016, 04:46:10 PM

Title: UIPopupList Set-method
Post by: DJVDJV on November 29, 2016, 04:46:10 PM
Hellos,

I try set UIPopupList selected item with method:
public void Set (string value, bool notify = true)
(in UIPopupList)

But there seems be row 321:
mSelectedItem = null;

That resets value.. if I comment this row away all works great.
How I should set current value right way (and without changing NGUI code)
Title: Re: UIPopupList Set-method
Post by: ArenMook on November 30, 2016, 03:26:18 PM
I've answered this question a couple of times now. The popup list's selection is only known while the popup is open. If you want to cache it, then do just that.
  1. using UnityEngine;
  2.  
  3. [RequireComponent(typeof(UIPopupList))]
  4. public class SavedSelection : MonoBehaviour
  5. {
  6.     public string selection;
  7.  
  8.     UIPopupList mList;
  9.  
  10.     void Start ()
  11.     {
  12.         mList = GetComponent<UIPopupList>();
  13.         EventDelegate.Add(mList.onChange, delegate () { selection = mList.value; });
  14.     }
  15. }