Exemplo n.º 1
0
    /// <summary>
    /// 动态创建可滑动的预设
    /// </summary>
    /// <param name="count"></param>
    /// <param name="head"></param>
    /// <param name="path"></param>
    protected void AutoCreateItems(int count, Transform head, string path)
    {
        for (int i = ButtonUis.Count - 1; i >= 0; i--)
        {
            GameObject.DestroyImmediate(ButtonUis.ElementAt(i).gameObject);
        }

        ButtonUis.Clear();
        int index = count / 6;

        if (count % 6 != 0)
        {
            index += 1;
        }
        for (int i = 0; i < index * 6; i++)
        {
            ResourceItem objUnit = ResourcesManager.Instance.loadImmediate(path, ResourceType.PREFAB);
            GameObject   obj     = GameObject.Instantiate(objUnit.Asset) as GameObject;
            obj.name                 = obj.name + (i + 1).ToString();
            obj.transform.parent     = head;
            obj.transform.localScale = Vector3.one;
            //obj.transform.localPosition = Vector3.zero;
            DbClickBotton click = obj.GetComponent <DbClickBotton>();
            click.AddListener(i, OnButtonClickFunc);
            click.AddListenerDb(i, OnButtolDbClickFunc);
            ButtonUis.Add(click);
            //click.transform.GetComponent<UIGrid>().Reposition() ;
        }
        UIGrid grid = head.GetComponentInChildren <UIGrid>();

        grid.enabled       = true;
        grid.repositionNow = true;
        grid.Reposition();
    }
Exemplo n.º 2
0
 protected override void AddButtonListener(Transform head)
 {
     for (int ct = 0; ct < ComposeBtnCount; ct++)
     {
         int           ctt   = ct + 1;
         DbClickBotton click = head.Find("Button" + ctt.ToString()).GetComponent <DbClickBotton>();
         click.AddListener(ct, OnButtonClickFunc);
         click.AddListenerDb(ct, OnButtolDbClickFunc);
         ButtonUis.Add(click);
     }
 }
Exemplo n.º 3
0
    protected override void AddButtonListener(Transform head)
    {
        for (int ct = 0; ct < UserItemBtnCount; ct++)
        {
            int           ctt   = ct + 1;
            DbClickBotton click = head.Find("Item" + ctt.ToString()).GetComponent <DbClickBotton>();
            click.AddListener(ct, OnButtonClickFunc);
            click.AddListenerDb(ct, OnButtolDbClickFunc);
            ButtonUis.Add(click);

            UIObjDragEvent drag = click.GetComponent <UIObjDragEvent>();
            drag.ObjDragEvent += OnItemDragEvent;
        }
    }