Exemplo n.º 1
0
    public void Add(CGameUI ui)
    {
        if (!index_pool.CanAlloc())
        {
            LOG.TraceRed("ERROR: ui数量超出上限。ui name:{0}", ui.Name);
            return;
        }
        int index = index_pool.Alloc();

        if (uis[index] != null)
        {
            throw new Exception(string.Format("[CUIManager] ui index:{0} is already in use", index));
        }
        if (names.ContainsKey(ui.Name))
        {
            throw new Exception(string.Format("[CUIManager] ui name:{0} is already exist", ui.Name));
        }
        uis[index]     = ui;
        names[ui.Name] = ui;
        ui.index       = index;
        ui.SetPosition(new Vector3((ui.index + 1) * 100, 0, 0));
        // 最后显示该ui
        ui.Show();
    }