Unityエディタでキャッシュサーバーの設定がどうなっているかを確認するコードです。
エディタ拡張を作った際に、キャッシュサーバーがONになっていない場合にアラートを出したりする際に便利です。
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class EditorScript : MonoBehaviour { /// <summary> /// Return cache server status /// </summary> /// <returns>"Local", "Remote", "Disable"</returns> public static string checkCacheServer() { string[] CacheServerModeString = new string[3] { "Local", "Remote", "Disable" }; var CacheServerMode = EditorPrefs.GetInt("CacheServerMode", (int)(EditorPrefs.GetBool("CacheServerEnabled") ? 1 : 2)); return CacheServerModeString[CacheServerMode]; } /// <summary> /// Call Cache server status function from menu /// </summary> [MenuItem("Editor Scripts/Check cache server", false, 10001)] private static void CallCheckCacheServer() { Debug.Log(checkCacheServer()); } }
メニューから実行してテストできます