Ejemplo n.º 1
0
    public void CreateWindow(FormData formData)
    {
        UIConsts.FORM_ID formID = formData.Id;

        // проверка на наличие дублей форм
        if (_uiList.ContainsKey(formID))
        {
            Debug.LogError("FORM TYPE '" + formID.ToString() + "' ALREADY EXISTS");
            return;
        }

        Object loadetPrefab = Resources.Load(formData.Path);

        if (loadetPrefab == null)
        {
            Debug.LogError("PREFAB '" + formData.Path + "' NOT EXIST!");
            return;
        }
        GameObject obj = (GameObject)Instantiate(loadetPrefab);

        obj.name = formID.ToString();
        obj.transform.SetParent(_newCanvas.transform, false);
        obj.GetComponent <BaseUIController>().CreationMethod = formData.CreationMethod;
        _uiList.Add(formID, obj);
        RectTransform rectTransf = obj.GetComponent <RectTransform>();

        // start position
        rectTransf.pivot              = new Vector2(0.5f, 0.5f);
        rectTransf.anchorMin          = new Vector2(0f, 0f);
        rectTransf.anchorMax          = new Vector2(1f, 1f);
        rectTransf.sizeDelta          = new Vector2(0f, 0f);
        rectTransf.anchoredPosition3D = UIConsts.START_POSITION;
        // scale
        //obj.transform.localScale = new Vector3(formData.scale, formData.scale, 1);

        //BoardUIResponder resp = obj.GetComponent<BoardUIResponder>();
        //if (resp != null)
        //{
        //    resp.AfterUIInitialized();
        //}
    }
Ejemplo n.º 2
0
 // Возвращает ссылку на экземпляр формы типа GameObject
 public GameObject GetFormFromID(UIConsts.FORM_ID form)
 {
     if (_uiList.ContainsKey(form))
     {
         GameObject f = _uiList[form];
         return(f);
     }
     else
     {
         Debug.LogError("FORM NAME '" + form.ToString() + "' NOT EXIST!");
         return(null);
     }
 }
Ejemplo n.º 3
0
    public void FindWindowOnSceneOrCreate(FormData formData)
    {
        UIConsts.FORM_ID formID   = formData.Id;
        GameObject       newForm  = null;
        string           formName = formID.ToString();

        foreach (var w in WindowsAvailableAtStart)
        {
            if (w.name == formName)
            {
                newForm = w;
                break;
            }
        }
        if (newForm != null)
        {
            newForm.GetComponent <BaseUIController>().CreationMethod = formData.CreationMethod;
            _uiList.Add(formID, newForm);
        }
        else
        {
            CreateWindow(formData);
        }
    }