GUI上での変更方法
書く必要はないかもしれませんが、GUI
上での変更方法についても記載しておきます。
Macの場合はメニューバーよりUnity -> Settings...
を選択しPreferences
を開き、Preferences -> General -> Editor Theme
をLight
かDark
に変更します。

スクリプトでの取得
Preferences
で設定されている値はEditorPrefs
を利用することで取得・設定することができます。
結構見つけるのが大変でしたが、UserSkin
というkey
にて取得することができます。
// Editor Themeを取得する // 0 = Light, 1 = Dark var userSkin = EditorPrefs.GetInt("UserSkin");
またEditorPrefs.SetInt
を実行した後にInternalEditorUtility.SwitchSkinAndRepaintAllViews()
を実行することでEditorに適応することができます。
// Editor Themeを設定する EditorPrefs.SetInt("UserSkin", 1); // Editor Themeを適応する InternalEditorUtility.SwitchSkinAndRepaintAllViews();
Preferencesのkeyの探し方
以下のファイルにEditorPrefs
のデータが格納されています。
- Mac :
~/Library/Preferences/com.unity3d.UnityEditor5.x.plist
- Windows :
HKCU\Software\Unity Technologies\UnityEditor 5.x key
On macOS, EditorPrefs are stored in ~/Library/Preferences/com.unity3d.UnityEditor5.x.plist.
On Windows, EditorPrefs are stored in the registry under the HKCU\Software\Unity Technologies\UnityEditor 5.x key.
EditorPrefs - Unity スクリプトリファレンス
Mac
の場合はXCode
で開き、該当のそれっぽいkey
を探しましょう。

またUnityCsReference
を見ることでkey
の予測の手助けになったりもします。
github.com