Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        YDText = GameObject.Find("RateYD").GetComponent <Text>();
        ydc    = YDText.GetComponent <rateYDController>();


        ScoreT      = GameObject.Find("Score").GetComponent <Text>();
        SController = ScoreT.GetComponent <ScoreController>();


        //ボタン並べる場所取得
        RectTransform content = GameObject.Find("Canvas/Scroll View/Viewport/Content").GetComponent <RectTransform>();
        //Contentの高さ決定
        //float btnSpace = content.GetComponent<VerticalLayoutGroup>().spacing;
        float btnHeight = btnPref.GetComponent <LayoutElement>().preferredHeight;

        //content.sizeDelta = new Vector2(0, (btnHeight + btnSpace) * BUTTON_COUNT);
        content.sizeDelta = content.GetComponent <GridLayoutGroup>().spacing;
        for (int i = 0; i < BUTTON_COUNT; i++)
        {
            int no = i;
            //ボタン生成
            GameObject btn = (GameObject)Instantiate(btnPref);
            //ボタンをContentの子に設定
            btn.transform.SetParent(content, false);
            //ボタンのテキスト変更
            switch (no)
            {
            case 0:
                btn.transform.GetComponentInChildren <Text>().text = "ドル買→1兆円";
                break;

            case 2:
                btn.transform.GetComponentInChildren <Text>().text = "ドル買→10兆円";
                break;

            case 4:
                btn.transform.GetComponentInChildren <Text>().text = "ドル買→100兆円";
                break;


            case 1:
                btn.transform.GetComponentInChildren <Text>().text = "ドル売→100億ドル";
                break;

            case 3:
                btn.transform.GetComponentInChildren <Text>().text = "ドル売→1000億ドル";
                break;

            case 5:
                btn.transform.GetComponentInChildren <Text>().text = "ドル売→1兆ドル";
                break;

            default: break;
            }

            //ボタンのクリックイベント登録
            btn.transform.GetComponent <Button>().onClick.AddListener(() => OnClick(no));
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        Vector2 thisCollider = GameObject.Find("buy_button").transform.position;

        //円ドル系読み込み
        YDText = GameObject.Find("RateYD").GetComponent <Text>();
        ydc    = YDText.GetComponent <rateYDController>();
    }
Exemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        Mes = new int[50];
        rYD = GameObject.Find("RateYD").GetComponent<Text>();
        rYDC = rYD.GetComponent<rateYDController>();

        MesText = GameObject.Find("Message").GetComponent<Text>();
        MesText.text = "test";


        ScoreText = GameObject.Find("Score").GetComponent<Text>();
        SController = ScoreText.GetComponent<ScoreController>();
    }