Exemplo n.º 1
0
    private void DrawFileCacheSize()
    {
        if (Application.isPlaying || !fileCacheSize.HasValue)
        {
            fileCacheSize = cache.GetFileCacheSizeFast();
        }

        float  fileCacheSizeMb  = fileCacheSize.Value / 1000000f;
        string fileCacheSizeStr = fileCacheSizeMb.ToString("F2");

        EditorGUILayout.LabelField("Current Size (mb)", fileCacheSizeStr);
        if (GUILayout.Button("Clear"))
        {
            cache.ClearFileCache();
            fileCacheSize = null;
        }
    }
Exemplo n.º 2
0
    private void OnFileCacheGUI()
    {
        bool fileCache = pUseFileCache.boolValue;

        if (fileCache)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
        }
        EditorGUILayout.PropertyField(pUseFileCache, new GUIContent("File Cache"));

        if (pUseFileCache.boolValue)
        {
#if UNITY_WEBPLAYER || UNITY_WEBGL
            EditorGUILayout.HelpBox("File Cache is not supported for Webplayer and WebGL.", MessageType.Warning);
#endif
            CheckFileCacheSize();


            EditorGUILayout.PropertyField(pMaxFileCacheSize, new GUIContent("Size (mb)"));
            pFileCacheUnloadRate.floatValue = EditorGUILayout.Slider("Unload (%)", Mathf.RoundToInt(pFileCacheUnloadRate.floatValue * 100), 1, 50) / 100;
            EditorGUILayout.PropertyField(pFileCacheLocation, new GUIContent("Cache Location"));
            if (pFileCacheLocation.enumValueIndex == (int)OnlineMapsCache.CacheLocation.custom)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(pFileCacheCustomPath, new GUIContent("Cache Folder"));
                if (GUILayout.Button("...", GUILayout.ExpandWidth(false)))
                {
                    string folder = EditorUtility.OpenFolderPanel("Cache folder", pFileCacheCustomPath.stringValue, "");
                    if (!string.IsNullOrEmpty(folder))
                    {
                        pFileCacheCustomPath.stringValue = folder;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(pFileCacheTilePath, new GUIContent("Tile Path"));
            if (GUILayout.Button("Open", GUILayout.ExpandWidth(false)))
            {
                Process.Start(cache.GetFileCacheFolder().ToString());
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            showPathTokens = OnlineMapsEditor.Foldout(showPathTokens, "Available Tokens");
            if (showPathTokens)
            {
                GUILayout.Label("{pid} - Provider ID");
                GUILayout.Label("{mid} - MapType ID");
                GUILayout.Label("{zoom}, {z} - Tile Zoom");
                GUILayout.Label("{x} - Tile X");
                GUILayout.Label("{y} - Tile Y");
                GUILayout.Label("{quad} - Tile Quad Key");
                GUILayout.Label("{lng} - Language code");
                GUILayout.Label("{lbs} - Labels");
                GUILayout.Space(10);
            }
            EditorGUILayout.EndVertical();

            if (Application.isPlaying || !fileCacheSize.HasValue)
            {
                fileCacheSize = cache.GetFileCacheSizeFast();
            }

            float  fileCacheSizeMb  = fileCacheSize.Value / 1000000f;
            string fileCacheSizeStr = fileCacheSizeMb.ToString("F2");
            EditorGUILayout.LabelField("Current Size (mb)", fileCacheSizeStr);
            if (GUILayout.Button("Clear"))
            {
                cache.ClearFileCache();
                fileCacheSize = null;
            }
        }

        if (fileCache)
        {
            EditorGUILayout.EndVertical();
        }
    }