Exemple #1
0
    public TipsCompontent GetTips(TipsConfig tipsConfig = null)
    {
        if (tipsConfig == null)
        {
            tipsConfig = new TipsConfig();
        }
        string         path           = "Common/TipsCompontent/Tips_" + tipsConfig.TipsSize + "_" + tipsConfig.TipsDirection;
        TipsCompontent tipsCompontent = UIFactory.Instance.GetUI <TipsCompontent>(path);

        tipsCompontent.SetStyle(tipsConfig);
        return(tipsCompontent);
    }
Exemple #2
0
    /// <summary>
    /// 设置数量
    /// </summary>
    /// <param name="count"></param>
    private void SetCount(int count)
    {
        if (count <= 1)
        {
            Debug.LogErrorFormat("节点数量必须大于1");
            return;
        }
        _count = count;
        //初始化
        if (!_hasInit)
        {
            Init();
        }
        //克隆
        for (int i = 0; i < _count - 1; i++)
        {
            Instantiate(_original, _parent);
        }
        //添加toggle的监听事件
        _toggles = _parent.GetComponentsInChildren <Toggle>();
        ToggleGroup toggleGroup = _parent.GetComponent <ToggleGroup>();

        for (int i = 0; i < _count; i++)
        {
            int tempIndex = i;
            _toggles[tempIndex].group = toggleGroup;
            TipsCompontent tipsCompontent = _toggles[tempIndex].transform.GetComponentInChildren <TipsCompontent>();
            _toggles[tempIndex].onValueChanged.AddListener((isOn) =>
            {
                if (_tipsList != null && _hasTips)
                {
                    //如果不存在
                    if (tipsCompontent == null)
                    {
                        tipsCompontent = TipsFactory.Instance.GetTips(_tipsConfig);
                        //弹窗位置
                        tipsCompontent.SetParent(_toggles[tempIndex].transform);
                        //弹窗内容
                        tipsCompontent.SetContent(_tipsList[tempIndex]);
                    }
                    tipsCompontent.gameObject.SetActive(isOn);
                }
            });
        }
    }