Пример #1
0
    /// <summary>
    /// 参照するUI画像をリソースから読み込んで表示
    /// </summary>
    /// <param name="fishUI">画像を設定するゲームオブジェクトの親オブジェクト</param>
    /// <param name="data">設定するデータ</param>
    private void PictureRef(GameObject fishUI, BioData data)
    {
        string type           = StringUtil.ToTitle(data.GetBioType().ToString());
        Image  image          = fishUI.transform.FindChild("View").GetComponent <Image>();
        string resourceString = "Image/" + type + "/" + data.GetNameEn();
        Sprite View           = Resources.Load(resourceString, typeof(Sprite)) as Sprite;

        image.sprite = View;
    }
Пример #2
0
    /// <summary>
    /// OnClickイベントの作成
    /// </summary>
    /// <param name="fishUI">UI単位をまとめるオブジェクト。</param>
    /// <param name="data">作成する魚のデータ</param>
    private void ClickEvent(GameObject fishUI, BioData data)
    {
        BiologicalManager _manager     = GetComponent <BiologicalManager>();
        FishManager       fish         = _manager.GetFishManager();
        Button            createButton = GetButtonComponent(fishUI, "CreateButton");

        createButton.onClick.AddListener(() =>
        {
            fish.FishCreate(data.GetBioType(), data.GetNameEn());
        });

        Button deleteButton = GetButtonComponent(fishUI, "DeleteButton");

        if (BioType.FISH == data.GetBioType())
        {
            deleteButton.onClick.AddListener(() => fish.ObjectDelete(data.GetNameEn()));
            return;
        }
        // 魚以外はDeleteButtonは使わないので削除
        Destroy(deleteButton.gameObject);
    }