Example #1
0
    private void createLocationButton(int j, int k, int mapButtonIndex)
    {
        GameObject buttonObject = GameObject.Instantiate(mapLocationButtonPrefab, myMapPanel.transform);

        float buttonWidth  = buttonObject.GetComponentInChildren <RectTransform>().rect.width;
        float buttonHeight = buttonObject.GetComponentInChildren <RectTransform>().rect.height;

        buttonObject.GetComponentInChildren <RectTransform>().SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, k * buttonWidth, buttonWidth);
        buttonObject.GetComponentInChildren <RectTransform>().SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, j * buttonHeight, buttonHeight);

        buttonObject.GetComponentInChildren <Text>().text = mySceneCatalogue.getLocationNames()[mapButtonIndex];

        UnityAction buttonAction = () => myInputOrganizer.BTN_onLocationClick(mapButtonIndex);

        buttonObject.GetComponent <Button>().onClick.AddListener(buttonAction);
    }