コード例 #1
0
    // Show human readable story names and pull title images when possible.
    private void setupStoryLibrary()
    {
        Logger.Log("setting up story library");
        int row = 0;
        int col = 0;

        for (int i = 0; i < this.stories.Count; i++)
        {
            if (col == 0)
            {
                this.libraryShelves.Add(Instantiate((GameObject)Resources.Load("Prefabs/Shelf")));
                this.libraryShelves[row].transform.SetParent(this.bookshelfPanel.transform);
                Util.UpdateShelfPosition(this.libraryShelves[row], row);
            }
            StoryMetadata story      = this.stories[i];
            GameObject    bookObject =
                Instantiate((GameObject)Resources.Load("Prefabs/LibraryBook"));
            LibraryBook libraryBook = bookObject.GetComponent <LibraryBook>();
            libraryBook.AddClickHandler(this.onLibraryBookClick(i, story));
            libraryBook.SetStory(story);
            libraryBook.SetSprite(this.assetManager.GetTitleSprite(story));
            bookObject.transform.SetParent(this.libraryShelves[row].transform);
            this.libraryBooks.Add(bookObject);
            col += 1;
            if (col / Constants.NUM_LIBRARY_COLS > 0)
            {
                col  = col % Constants.NUM_LIBRARY_COLS;
                row += 1;
            }
        }
    }