Example #1
0
    void Start()
    {
        GameObject _pers = GameObject.FindGameObjectWithTag("Player");

        if (_pers != null)
        {
            Inv        = _pers.GetComponent <Inventario>();
            Persoangem = (Target)_pers.GetComponent(typeof(Target));
        }
        if (Slots == null)
        {
            Slots = new List <ItemContent>();
        }
        if (PrefabValues == null)
        {
            PrefabValues = Prefab.GetComponent <RectTransform>();
        }
    }
Example #2
0
    void CreateSlot()
    {
        #region Criando o espaço
        ItemContent obj = Instantiate(Prefab);
        obj.transform.SetParent(Screen.transform, false);
        RectTransform rect            = obj.GetComponent <RectTransform>();
        RectTransform _tempScreenRect = Screen.GetComponent <RectTransform>();
        rect.anchoredPosition = new Vector2((X * (_tempScreenRect.sizeDelta.x / 2)) - (PrefabSize.x / 2) - 10, ((_tempScreenRect.sizeDelta.y / 2) - 0) - PrefabSize.y * (Y + 1));
        obj.name = "Slot " + X + " - " + Y;
        Slots.Add(obj);
        #endregion
        #region Organizando Posicoes

        if (X % 2 != 0)
        {
            X = 0;
            Y++;
        }
        else
        {
            X++;
        }
        #endregion
    }