- Home /
 
 
               Question by 
               LongNH2410 · Dec 29, 2014 at 01:23 PM · 
                ngui  
              
 
              How to call funtion method in UIButton by Script
Hi all, I want to load list of items dynamic from UIScrollView by NGUI. I have defined a prefab.
In a prefab contains:
UIButton
UILable display name
I have use this tutorial create list of items dynamic by UIScrollView:
https://www.youtube.com/watch?v=AjzJrbiTJgE
And my code here:
     public GameObject scrollView;
     public GameObject itemPref;
     void Start() {
         for (int i = 0; i < 5; i++) {
             GameObject item = NGUITools.AddChild(scrollView, itemPref);    
             item.name = "Item" + i;
         }
         scrollView.transform.parent.GetComponent<UIScrollView> ().ResetPosition ();
         scrollView.GetComponent<UIGrid> ().Reposition ();
 
         GameObject gm = GameObject.Find ("Item0");
         UIButton btn = gm.GetComponentInChildren<UIButton> ();
         Debug.Log ("btn Name: " + btn.name);
     }
 
               I have get a UIButton from prefab. How to call function click when i touched on UIButton "btn" by Script?
 GameObject gm = GameObject.Find ("Item0");
 UIButton btn = gm.GetComponentInChildren<UIButton> ();
 Debug.Log ("btn Name: " + btn.name);
 
               Please help me resolve this issue. Thanks all!
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
After using NGUI, game is not scaling for different devices ??? 0 Answers
NGUI Texture atlas help ! 1 Answer
How to make Scrollable Label in NGUI. 0 Answers
NGUI panel wont hide 2 Answers
NGUI slider effect for Android 0 Answers