示例#1
0
    /// <summary>
    /// Inserts an address cell into the address view.
    /// </summary>
    /// <param name="address"> The address to insert into the view </param>
    /// <returns> Whether or not a new cell was inserted. </returns>
    public bool Insert(string address)
    {
        bool addressWasAdded = addresses.Add(address);

        if (addressWasAdded)
        {
            // Create a new address cell
            GameObject addressCell = Instantiate(addressCellPrefab) as GameObject;
            addressCell.SetActive(true);
            // Set its name
            SimpleButton button = addressCell.GetComponent <SimpleButton>();
            button.SetName(address);
            button.addressModifier = this;
            // Add it to the content view
            addressCell.transform.SetParent(contentHolder.transform);
            addressCell.transform.localScale = Vector3.one;
        }

        // Return whether or not the address was added
        return(addressWasAdded);
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        NameList.Add("Alan");
        NameList.Add("Amy");
        NameList.Add("Brian");
        NameList.Add("Carrie");
        NameList.Add("David");
        NameList.Add("Joe");
        NameList.Add("Jason");
        NameList.Add("Michelle");
        NameList.Add("Stephanie");
        NameList.Add("Zoe");

        foreach (string str in NameList)
        {
            GameObject go = Instantiate(Button_Template) as GameObject;
            go.SetActive(true);
            SimpleButton button = go.GetComponent <SimpleButton>();
            button.SetName(str);
            go.transform.SetParent(Button_Template.transform.parent);
        }
    }