Пример #1
0
    public void init()
    {
        _player = null;
        string    dialogsName  = "playerDialogs_" + Position;
        Transform dialogCanvas = GameObject.FindGameObjectWithTag("dialogCanvas").transform;

        if (!dialogCanvas.Find(dialogsName))
        {
            GameObject dialogs = Instantiate(PlayerDialogPrefab);
            dialogs.name = dialogsName;
            dialogs.transform.SetParent(dialogCanvas, false);
            dialogs.transform.SetSiblingIndex(0);
            RectTransform newRect = dialogs.GetComponent <RectTransform>();
            RectTransform oldRect = transform.GetComponent <RectTransform>();
            newRect.anchorMax        = oldRect.anchorMax;
            newRect.anchorMin        = oldRect.anchorMin;
            newRect.offsetMax        = oldRect.offsetMax;
            newRect.offsetMin        = oldRect.offsetMin;
            newRect.pivot            = oldRect.pivot;
            newRect.anchoredPosition = oldRect.anchoredPosition;
            newRect.rotation         = oldRect.rotation;

            DialogGUI           = dialogs.GetComponent <PlayerDialogGUI>();
            DialogGUI.ParentGUI = this;
        }
    }