示例#1
0
    static protected void changeScreenVisibleState(string scName, bool state, string containsFilter = "", bool force = false)
    {
        fetchScreens();

        //Debug.Log("opening " + scName + " (filter ? " + filter + ")");

        ScreenObject selected = getScreen(scName);

        if (selected == null)
        {
            Debug.LogWarning("trying to change visibility of screen " + scName + " but this ScreenObject doesn't exist");
            return;
        }

        bool hideOthers = !selected.dontHideOtherOnShow;

        //Debug.Log(selected.name + " visibilty to " + state+" (filter ? "+containsFilter+" | dont hide other ? "+selected.dontHideOtherOnShow+" => hide others ? "+hideOthers+")");

        //on opening a specific screen we close all other non sticky screens
        if (hideOthers && state)
        {
            for (int i = 0; i < screens.Count; i++)
            {
                if (screens[i] == selected)
                {
                    continue;
                }

                //do nothing with filtered screen
                if (containsFilter.Length > 0 && screens[i].name.Contains(containsFilter))
                {
                    continue;
                }

                screens[i].hide();
                //Debug.Log("  L "+screens[i].name + " hidden");
            }
        }

        if (state)
        {
            selected.show();
        }
        else
        {
            if (force)
            {
                selected.forceHide();
            }
            else
            {
                selected.hide(); // stickies won't hide
            }
        }
    }