Warning: count(): Parameter must be an array or an object that implements Countable in /home/psychic-vr-lab/www/psychic-vr-lab.com/blog/wp-includes/post-template.php on line 284

Warning: count(): Parameter must be an array or an object that implements Countable in /home/psychic-vr-lab/www/psychic-vr-lab.com/blog/wp-includes/post-template.php on line 284

Warning: count(): Parameter must be an array or an object that implements Countable in /home/psychic-vr-lab/www/psychic-vr-lab.com/blog/wp-includes/post-template.php on line 284

Warning: count(): Parameter must be an array or an object that implements Countable in /home/psychic-vr-lab/www/psychic-vr-lab.com/blog/wp-includes/post-template.php on line 284
開発入門 > Unity > Cacheサーバーの設定を確認する

Cacheサーバーの設定を確認する

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());
    }

}

 

メニューから実行してテストできます

cacheserver

カテゴリー: Unity

HOME / Coporate Site/ Careers

© Copyright 2018 STYLY..