# SetInt(string, int)

> Sets the value of the preference identified by key as an integer.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.6/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public static void SetInt(string key, int value)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of key to write integer to.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Value of the integer to write into the storage.

### Remarks

Sets the value of the preference identified by `key` as an integer.

Additional Resources: [EditorPrefs.GetInt](/engine/6000.6/script-reference/unityeditor/editorprefs/getint.md).

### Examples

```csharp
// A small editor window that allows an integer value to be
// read and written to the EditorPrefs online storage.
//
// SetIntExample is the name of the int to read/write.

using UnityEngine;
using UnityEditor;

public class ExampleClass : EditorWindow
{
    int intValue = 42;

    [MenuItem("Examples/Prefs.SetInt Example")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)EditorWindow.GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        int temp;
        temp = EditorPrefs.GetInt("SetIntExample", -1);
        EditorGUILayout.LabelField("Current stored value: " + temp.ToString());
        intValue = EditorGUILayout.IntField("Value to write to Prefs: ", intValue);
        if (GUILayout.Button("Save value: " + intValue.ToString()))
        {
            EditorPrefs.SetInt("SetIntExample", intValue);
            Debug.Log("SetInt: " + intValue);
        }
    }
}
```
