Guest User

instantiateChilds

a guest
May 8th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI.Extensions;
  5.  
  6. public class instantiateChilds : MonoBehaviour {
  7.  
  8.     public GameObject leprefab;
  9.     public GameObject lecontainer;
  10.     public HorizontalScrollSnap snapper;
  11.     public UI_InfiniteScroll infiScroll;
  12.     GameObject[] s;
  13.     bool once = true;
  14.     // Use this for initialization
  15.     public void AddnewImage () {
  16.  
  17.         GameObject go = Instantiate (leprefab);
  18.         snapper.AddChild (go);
  19.         GameObject go2 = Instantiate (leprefab);
  20.         snapper.AddChild (go2);
  21.         GameObject go3 = Instantiate (leprefab);
  22.         snapper.AddChild (go3);
  23.  
  24.     }
  25.  
  26.     public void RemoveChildrens(){
  27.         snapper.RemoveAllChildren(out s);
  28.         for(int i = 0; i<s.Length; i++){
  29.  
  30.             Destroy (s[i].gameObject);
  31.         }
  32.  
  33.         infiScroll.DeleteParameters ();
  34.     }
  35.  
  36.     public void Runinit(){
  37.         infiScroll.Init ();
  38.     }
  39.  
  40.  
  41.    
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment