Class ContentPaths
Filesystem layout of the content platform.
Base content : <StreamingAssets>/Content/base/ (shipped, versioned in git) Mod content : <persistentDataPath>/Mods/<Mod>/Content/ (authored, hot-reloadable)
All paths are physical files; nothing here goes through Addressables, because reading definitions must never load art (see GrindFest.Workspace/CONTENT_PLATFORM_PLAN.md).
public static class ContentPaths
- Inheritance
-
objectContentPaths
Fields
Properties
- BaseContentDirectory
Shipped base content (read-only at runtime).
- ModsDirectory
Root folder of every mod package (base game content lives in StreamingAssets instead).
- StreamingAssetsNeedsWebRequest
True on platforms where StreamingAssets is not a real file system (inside the APK / served over HTTP). These need UnityWebRequest instead of File IO.
- StreamingAssetsRoot
StreamingAssets as this platform actually exposes it.
On desktop and in the editor that is the real folder. In a browser it is not the
http://URL streamingAssetsPath returns: it is the preloaded virtual file system, and the difference is the whole reason the Web player used to stall on a white screen at 100 %.A file that the build listed in its preload manifest (
ContentDirectoryBuildProcessor) is readable with plainFileIO at/vfs_streamingassets/<path>. A URL is not readable that way, and every path here — the definition JSONs especially — is read with plain File IO unless NeedsWebRequest(string) says otherwise. Probing a directory URL answers 404 (no web server lists directories), so the base package used to be dropped entirely,ContentDBmerged zero definitions, and everything that resolves an asset by name (world generation'sWater Plane,Orc Camp,Area, …) missed for the whole session.
Methods
- ExistsAsync(string, CancellationToken)
Existence test that answers the same question on every platform.
A local path is answered from the file system. A StreamingAssets path on a packed platform is probed over HTTP instead, because a URL is not a directory and Exists(string)/Exists(string) silently return false there - which is how "platform fork" bugs hide (content that loads fine in the editor and loads zero files in a browser without a single error).
- IsStreamingAssets(string)
True when
pathis inside streamingAssetsPath.This - not the platform - is the distinction that decides how a path is read: on desktop and in the editor StreamingAssets is a real directory, while on WebGL and Android it is a URL that only UnityWebRequest can open. Everything else (notably persistentDataPath, where mods, saves and compiled scripts live) is a real file system on every platform, WebGL included, so plain File IO is correct and stays.
- ListJsonFiles(string)
Lists
*.jsonfiles directly insidedirectory(non-recursive, sorted).
- ListJsonFilesAsync(string, bool, CancellationToken)
Lists the
*.jsondocuments a content package should read - the asynchronous, platform-neutral counterpart of ListJsonFiles(string) / ListJsonFilesRecursive(string).A local package (a mod under persistentDataPath) is enumerated from disk exactly as before. A base package is not: on a packed platform StreamingAssets is a URL, and a URL cannot be enumerated. That is precisely why the base ships a single
index.json- that file is the listing, so the answer is either it or nothing.
- ListJsonFilesRecursive(string)
Lists every
*.jsonunderdirectory(recursive, sorted). Recursive on purpose: a mod may group its content as one file, one file per kind, or one file per definition — the merge key is the definition id, so the layout is the author's choice (plan §4.3, decision D19).
- ListModFolders()
Sub-directories of the mods root, sorted by name (stable discovery order).
- ModContentDirectory(string)
Content folder of a single mod package.
- NeedsWebRequest(string)
True when this platform needs a web request to read
path.
- ReadText(string)
Synchronous read for platforms where StreamingAssets is a real directory (desktop, editor).
- ReadTextAsync(string, CancellationToken)
Reads a text file, transparently using UnityWebRequest on platforms where StreamingAssets is packed. Returns null when the file does not exist.
- ToUrl(string)
Turns a physical path into a URL UnityWebRequest accepts.