Exemplo n.º 1
0
    private void addSectorToContainer(SectorState sectorState, int sectorIndex)
    {
        GameObject currLocationObj = Instantiate(sectorPointPrefab, new Vector3(), new Quaternion()) as GameObject;

        // Реакция на нажатие
        GameObject SecButton = currLocationObj.transform.FindChild("Button").gameObject;

        SecButton.GetComponent <Button> ().onClick.AddListener(() => onSectorClickListener(sectorState));

        // Текст
        GameObject SecText       = SecButton.transform.FindChild("Text").gameObject;
        string     secHiddenMark = sectorState.isVisible ? "" : "[*] ";

        SecText.GetComponent <Text> ().text = secHiddenMark + sectorState.getName();

        // Позиционирование
        RectTransform AnswRT = currLocationObj.GetComponent <RectTransform> ();

        AnswRT.SetParent(sectorsContainer);
        AnswRT.localScale = new Vector3(1, 1, 1);
        AnswRT.anchorMin  = sectorState.getNormalCoords();
        AnswRT.anchorMax  = AnswRT.anchorMin;
        AnswRT.offsetMax  = new Vector2(0, 0);
        AnswRT.offsetMin  = new Vector2(0, 0);
    }