> For the complete documentation index, see [llms.txt](https://kdoore.gitbook.io/cs2335/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kdoore.gitbook.io/cs2335/overview-branchlogic/dictionary-user-choice-data/choicepanel/example-user-choices/dictionary-value-to-disable-options.md).

# Dictionary Value to Disable Options

### Scene Button Disabled based on Dictionary Value

In the code below, located in a State file associated with a Scene, there's logic that checks the GameData Dictionary to see if the key-value pair:  "choice1": "heart" exists in the dictionary.  If it exists, then ButtonOption1 is disabled.  This logic is executed as soon as the Corresponding scene is loaded, so the button is disabled before the Scene is displayed.  This is a toy example, but this is a reasonable place for this logic to be located. It illustrates the general idea of checking dictionary values to determine options available as a scene is loaded.  A Dictionary< string, string > provides flexibility to include any user choices that can be used to constrain the user's options. &#x20;

#### Scene2State.cs Logic to Disable Button depending on Dictionary values

```
 public void InitializeObjectRefs()
    {
        optionBtn1 = GameObject.Find("ButtonOption1").GetComponent<Button>();
        optionBtn1.onClick.AddListener(LoadScene3);

        string choiceValue = GameData.instanceRef.GetChoice("choice1");
        if(choiceValue == "heart")
        {
            GameObject btn1 = optionBtn1.gameObject;
            btn1.SetActive(false);
        }
        optionBtn2 = GameObject.Find("ButtonOption2").GetComponent<Button>();
        optionBtn2.onClick.AddListener(LoadMiniGame);

        Debug.Log("Initialize Refs - Scene2State");
    }
```

Selecting the heart option eliminates the option to return to the BeginScene from Scene 2.  Logic could be added to disable the Choice panel once the heart button has been selected, otherwise, the dictionary updates the "choice1" value each time the player selects a button.

![](http://g.recordit.co/cZ4jnsnhsH.gif)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kdoore.gitbook.io/cs2335/overview-branchlogic/dictionary-user-choice-data/choicepanel/example-user-choices/dictionary-value-to-disable-options.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
