Caching.AddCache

Unity · Версия 2020.3 LTS · Scripting · Caching

Caching.AddCache

Объявление

public static Cache AddCache(string cachePath);

Параметры

cachePath Путь к папке кэша.

Описание

Добавить кеш с заданным путем.

Это позволяет добавить новый кеш в список кешей. Будет возвращена ссылка на кэш.

using System.IO;
using UnityEngine;

public class Example : MonoBehaviour
{
    void AddCacheAtPath(string path)
    {
        if (!Directory.Exists(path))
            Directory.CreateDirectory(path);

Cache newCache = Caching.AddCache(path);

        //Убедитесь, что ваш новый Cache действителен
        if (newCache.valid)
        {
            //If you wanted to set your newly created cache to the active cache
            Caching.currentCacheForWriting = newCache;
        }
    }
}

Обновлено 17 ноября 2026 г.