- Home /
Question by
komodor · Jan 29, 2015 at 11:39 AM ·
editor-scriptingcustomizationpreferencestab
custom tab in preferences (editor-script)
hey, anybody knows how to make this tab?
customprefs.png
(15.3 kB)
Comment
Best Answer
Answer by troien · Jan 29, 2015 at 12:11 PM
You can create one such tab using the PreferenceItem attribute.
Because the docs only have an example in JavaScript, here is one for C#...
using UnityEngine;
using UnityEditor;
public class CustomPreferences
{
// Have we loaded the prefs yet
private static bool prefsLoaded = false;
// The Preferences
private static bool boolPreference = false;
[PreferenceItem("My preferences")]
private static void CustomPreferencesGUI()
{
if (!prefsLoaded)
{
boolPreference = EditorPrefs.GetBool("BoolPreferenceKey", false);
prefsLoaded = true;
}
EditorGUILayout.LabelField("Version: x.xx");
boolPreference = EditorGUILayout.Toggle("Bool preference: ", boolPreference);
if (GUI.changed)
{
EditorPrefs.SetBool("BoolPreferenceKey", boolPreference);
}
}
}
From 2018 up you should use : SettingsProvider class. Not an attribute anymore
Your answer

Follow this Question
Related Questions
Responsive Editor UI Button with custom style | How to remove GUIStyle.hover delay 0 Answers
Creating a template project for non-programmers for research purposes 0 Answers
Custom debug color display for scene view? 2 Answers
How to include custom art/styles in editor scripts 1 Answer
Can you run custom code when changing scene perspective? 1 Answer