Unity cache что это

Global Cache

When the Unity Package Manager downloads package contents and metadata, it stores them in a global cache. This makes re-using and sharing packages more efficient, and allows you to install and update stored packages even when offline.

Location

By default, Unity stores the global cache in a root directory that depends on the operating system (and the user account type on Windows):

Operating systemDefault root directory
Windows (non-system user account)%LOCALAPPDATA%\Unity\cache
Windows (system user account)%ALLUSERSPROFILE%\Unity\cache
macOS$HOME/Library/Unity/cache
Linux$HOME/.config/unity3d/cache

Structure

The Package Manager uses two different shared caches, each serving a different purpose. They are stored in subdirectories under the folder location above:

SubfolderDescription
npmStores data obtained from registries using the npm protocol. This includes package metadata and package tarballs.
packagesThis cache contains the uncompressed contents of package tarballs fetched from a registry.

Inside each of these subfolders, each registry has its own path so that packages hosted on different registries are not mixed up.

Requirements

The user account running the Unity Editor process must have full write permissions on the root directory and its contents. Without these permissions, the Package Manager cannot download and save the package metadata and contents in the cache.

Customizing the shared cache location

You can use two environment variables to override either global cache folder:

UPM_NPM_CACHE_PATH overrides the npm folder path. For example (macOS):

UPM_CACHE_PATH overrides the packages folder path. For example (macOS):

You must restart the Unity Editor and the Hub after changing either of these environment variables for them to take effect.

Источник

Caching

class in UnityEngine

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Submission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Description

The Caching class lets you manage cached AssetBundles, downloaded using UnityWebRequestAssetBundle.GetAssetBundle().

If you wanted to store up to 5 cached versions of the same bundle and use the previous caches in the event your most recent cache becomes invalid or the downloaded Asset Bundle has a problem, you could set that up like this.

The ability to have multiple caches allows you to keep several cached version of a particular Asset Bundle. You can use these for things like backups and fallbacks.

This example shows downloading medium resolution and high resolution textures after startup and caching them in their own appropriate caches.

Static Properties

cacheCountReturns the cache count in the cache list.
compressionEnabledControls compression of cache data. Enabled by default.
currentCacheForWritingGets or sets the current cache in which AssetBundles should be cached.
defaultCacheReturns the default cache which is added by Unity internally.
readyReturns true if Caching system is ready for use.

Static Methods

AddCacheAdd a cache with the given path.
ClearAllCachedVersionsRemoves all the cached versions of the given AssetBundle from the cache.
ClearCacheRemoves all AssetBundle content that has been cached by the current application.
ClearCachedVersionRemoves the given version of the AssetBundle.
ClearOtherCachedVersionsRemoves all the cached versions of the AssetBundle from the cache, except for the specified version.
GetAllCachePathsReturns all paths of the cache in the cache list.
GetCacheAtReturns the Cache at the given position in the cache list.
GetCacheByPathReturns the Cache that has the given cache path.
GetCachedVersionsReturns all cached versions of the given AssetBundle.
IsVersionCachedChecks if an AssetBundle is cached.
MarkAsUsedBumps the timestamp of a cached file to be the current time.
MoveCacheAfterMoves the source Cache after the destination Cache in the cache list.
MoveCacheBeforeMoves the source Cache before the destination Cache in the cache list.
RemoveCacheRemoves the Cache from cache list.

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.

Copyright ©2021 Unity Technologies. Publication Date: 2021-12-03.

Источник

AssetBundle compression

AssetBundle compression formats

Unity’s AssetBundle build pipeline creates AssetBundles with LZMA compression. This compression format is a stream of data representing the entire AssetBundle, which means that if you need to read an Asset from these archives, you must decompress the entire stream. This is the preferred format for AssetBundles downloaded from a Content Delivery Network (CDN), because the file sizes are smaller than those with LZ4 compression.

LZ4 compression, on the other hand, is a chunk-based compression algorithm. If Unity needs to access an Asset from an LZ4 archive, it only needs to decompress and read the chunks that contain bytes of the requested Asset. This is the compression method that Unity uses in both of its AssetBundle caches. Use the BuildAssetBundleOptions.ChunkBasedCompression value when building AssetBundles to force LZ4(HC) compression.

Uncompressed AssetBundles that Unity builds when you use BuildAssetBundleOptions.UncompressedAssetBundle require no decompression, but occupy more disk space. Uncompressed AssetBundles are 16-byte aligned.

AssetBundle cache

To optimize the fetching, recompressing, and versioning of LZMA AssetBundles using WWW or UnityWebRequest (UWR), Unity maintains two caches:

The Memory Cache stores AssetBundles in UncompressedRuntime format in RAM.

The Disk Cache stores fetched AssetBundles on writable media in the compression format described later.

AssetBundles loaded into the Memory Cache consume a large amount of memory. Unless you specifically want to frequently and rapidly access the contents of an AssetBundle, the Memory Cache is likely not worth the Memory cost. Instead, you should use the Disk Cache.

If you provide a version parameter to the UWR API, Unity stores your AssetBundle data in the Disk Cache. If you do not provide a version parameter, Unity uses the Memory Cache. The version parameter can be either a version number or a hash. If Caching.compressionEnabled is set to true, Unity applies LZ4 compression when it writes AssetBundles to disk for all subsequent downloads. It does not compress existing uncompressed data in the cache. If Caching.compressionEnabled is false, Unity applies no compression when it writes AssetBundles to disk.

It takes longer to initially load cached LZMA AssetBundles, because Unity must recompress the archive to the destination format. Subsequent loads use the cached version.

AssetBundle.LoadFromFile or AssetBundle.LoadFromFileAsync always use the Memory Cache for LZMA AssetBundles, so you should use the UWR API. If it is not possible to use the UWR API, you can use AssetBundle.RecompressAssetBundleAsync to rewrite an LZMA AssetBundle on disk.

Note: WebGL A JavaScript API that renders 2D and 3D graphics in a web browser. The Unity WebGL build option allows Unity to publish content as JavaScript programs which use HTML5 technologies and the WebGL rendering API to run Unity content in a web browser. More info
See in Glossary doesn’t support LZMA compression for AssetBundles. Use LZ4 compression with AssetBundles on WebGL platforms. For more information, see Building and running a WebGL project.

Internal testing shows that there is at least an order of magnitude difference in RAM usage between using the Disk Cache instead of the Memory Cache. You must weigh the trade-off between memory impact versus added disk space requirements and Asset instantiation time for your application.

Источник

Освобождаем место на диске от жестко привязанных файлов программ

Unity или любая другая программа хавает место на жестком диске с Windows в папках Local/Roaming и т.д. (обычно эти папки скрытые и находятся по пути «C:\Users\Ваш комп\AppData». Или вы хотите ускорить работу системы если вдруг у вас есть SSD, а Win стоит на HDD почему-то.

Windows, о боже мой, может создавать виртуальные папки на рабочем диске при этом сами файлы будут лежать на другом. И вот эта чудо функция скрыта за командной консолью, но не отчаивайтесь, решить проблему просто.

1. Берем необходимую нам папку и копируем ее целиком в новое место жительства.

2. Открываем консоль от имени администратора.

Если вы еще не поплыли от сложности продолжаем, осталось немного.

3. Вводим магическую команду в консоль:

4. Проверяем что в оригинальном каталоге ваша папка теперь выглядит и открывается как ярлык.

5. Радуемся свободному месту.

6. Подписываемся на мой паблик, где скоро будет анонс новой игры.

Комментарий удален по просьбе пользователя

Ну да, она ведь не умела 13 лет назад. Хотя подождите-ка.

Со времен vista софтлинки. Это разве 13 лет? До этого были хардлинки (nt4) и junctions (хардлинк? на папку) (2000). Что примечатель для кейса выше лучше именно последнее т.к. не нужны админские права.

Кто вас укусил? Ну лень гуглить с телефона. Издеваться то зачем?

Тебя кто укусил, линус торвальдс?

Кто вас укусил?
Зубная фея, которая очень хочет мой зуб.

Нет, это автор поста научился в консоль )
Я таким лет десять назад баловался )

Оооо, доступ к папке по ссылке.
Ооооо.

Это между прочим громадная разница. Все таки ссылка в виде ярлыка (если вы это подразумевали) это файл с информацией, который ещё надо обработать умудрится чем-то (проводник тот же например) и так они не работают. А симлинки/хардлинки это на уровне файловой системы, либо это отдельный файл с разными метаданными, но со ссыйлкой на один источник, либо это вообще один и тот же файл с разными путями, но имеющими идентичный файловый дискриптор.

Источник

Unity cache что это

The Unity Cache Server, optimized for locally networked team environments.

Note: This version of the cache server does not support the new Asset Database Version 2 introduced in Unity 2019.3. For projects using the new Asset import pipeline, use the Accelerator

This repository contains an open-source implementation of the Cache Server. This stand-alone version of Cache Server is specifically optimized for LAN connected teams. The Cache Server speeds up initial import of project data, as well as platform switching within a project.

This open-source repository is maintained separately from the Cache Server available on the Unity website and the implementation of the Cache Server that is packaged with the Unity installer.

Download and install LTS version 12.13.x of Node.js from the Node.JS website.

Install from npm registry

For the latest beta release:

Install from GitHub source

Note: GitHub source install from master branch might be ahead of latest release version.

The config/default.yml file contains configuration values for the cache modules (see below) and other features. The config system is based on the node-config module. For additional information on how to manage environment specific config files, see the Configuration Files documentation on the node-config GitHub repository.

You can have multiple configuration files based on environment:

To use a custom configuration directory:

To dump the current config to the console, run the following command:

The Cache Server section of the Unity Manual contains detailed information on connecting clients to remote Cache Servers.

Cache Server supports two caching mechanisms:

The file system module is the default and suitable for most applications. The RAM cache module provides optimal performance but requires a sufficient amount of physical RAM in the server system. Typically, this is two to three times size of your Project’s Library folder on disk.

Configuration options for all modules are set in the config/default.yml file.

A simple, efficient file system backed cache.

OptionDefaultDescription
cachePath.cache_fsThe path to the cache directory.
cleanupOptions.expireTimeSpanP30DASP.NET or ISO 8601 style timespan. Cache files that have not been accessed within this timespan are eligible for cleanup. For more information on duration syntax, see the moment library documentation.
cleanupOptions.maxCacheSize0The maximum size, in bytes, of the cache on disk. To bring the total disk utilization under this threshold, the cleanup script considers files for removal in least recently used order. Set the value to zero (0) to disable the cleanup feature.

A high performance, fully in-memory LRU cache.

Due to performance considerations, the cache_fs module shipped with Cache Server v6.0 does NOT operate as an LRU cache and does not enforce overall cache size restrictions. This is a change from previous versions of Cache Server. To manage disk usage, a separate cleanup script is provided that can either be run periodically or in «daemon» mode to automatically run at a given time interval.

unity-cache-server-cleanup [option] or node cleanup.js [options]

OptionDefaultDescription
queueProcessDelay2000The period, in milliseconds, to delay the start of processing the queue, from when the first transaction is added to an empty queue. Each transaction from a client is queued after completion. It’s a good idea to keep this value at or above the default value to avoid possible I/O race conditions with recently completed transactions.
connectionIdleTimeout10000The period, in milliseconds, to keep connections to remote mirror hosts alive, after processing a queue of transactions. Queue processing is bursty. To minimize the overhead of connection setup and teardown, calibrate this value for your environment.

High Reliability Mode

High Reliability Mode imposes stricter requirements on upload transactions to increase the integrity of cached data.

Asset versions are cached based on the Asset GUID and Asset hash reported by the client (Unity Editor). The Asset hash is calculated from the inputs to the Asset import process. The import process should produce the same binary result for a given set of inputs, but there is no guarantee that it will. Instability in the import process is typically an indication of a bug or design problem in the Asset importer.These errors can be propagated to other clients because Unity is not able to detect these instabilities before committing them to the Cache Server.

In the default operating mode ( highReliability is false), the Cache Server accepts all transactions for all versions of an Asset from any Unity client. In this scenario, the version of an Asset can change after it is already committed and the commit can cause an incorrect or unstable import.

High Reliability Mode allows the Cache Server to compare multiple transactions for the same version for binary stability before committing a version to the cache, and disallows further modifications to already committed versions. When an instability is detected, warning messages are logged and caching of the Asset is suspended until a team member uploads a new version of the Asset.

Requiring multiple imports of the same Asset to ensure the stability of each Asset version is resource intensive. High Reliability Mode is primarily beneficial to developers in networked team environments, where the increased overhead of importing Assets multiple times is distributed across the entire team. The larger the team, the smaller the impact on any individual.

OptionDefaultDescription
highReliabilityfalseEnable high reliability mode.
highReliabilityOptions.reliabilityThreshold2Number of binary-stable imports of the same version required before a version is cached and served.
highReliabilityOptions.saveUnreliableVersionArtifactstrueAfter a version is declared unreliable, save all subsequent transactions for the version for later inspection and debugging.
highReliabilityOptions.multiClientfalseRequire multiple clients to upload the same binary-stable version to increment the stability factor. For example, if the same client uploads the same version twice in a row, it does not increase stability of the version.

Unity project Library Importer

Tools are provided to quickly seed a Cache Server from a fully imported Unity project (a project with a Library folder).

Steps to Import a Project

Client Recorder (—diag-client-recorder)

OptionDefaultDescription
Diagnostics.clientRecorderfalseEnable client network stream recording.
Diagnostics.clientRecorderOptions.bufferSize10000000Size of in-memory buffer for client network stream recording.
Diagnostics.clientRecorderOptions.saveDir«diagnostics/client-recordings»Directory where client network stream recordings will be saved. A relative directory will be relative to the server application startup directory.

Contributions are welcome! Before submitting pull requests please note the Submission of Contributions section of the Apache 2.0 license.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *