示例#1
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
     }
 }
    public void Populate()
    {
        GameObject newObj; // Create GameObject instance

        for (int i = 0; i < GalleryHandler.TotalImageInGallery; i++)
        {
            // Create new instances of our prefab until we've created as many as we specified
            newObj = (GameObject)Instantiate(prefab, transform);
            newObj.GetComponent <GalleryItem>().LoadItem(i);
        }

        float width = scroll.GetComponent <RectTransform>().rect.width;


        Vector2 newSize = new Vector2((width / 3) - 10, (width / 3) - 10);

        GetComponent <GridLayoutGroup>().cellSize = newSize;

        GalleryHandler.ImagesInGallery = GalleryHandler.GetTotalImageSaved();
    }