Class ContentDirectoryBuildProcessor
Puts the built content directories into the player, and makes them readable there.
Two destinations, because the platforms differ in one respect only — whether StreamingAssets is a folder:
- **Desktop/editor**: StreamingAssets is a real directory, so injecting the built folder is enough. AddAdditionalPathToStreamingAssets(string, string) takes the source *and* the path inside StreamingAssets, so the player lands exactly where BaseDirectory looks.
- **Web**: there is no file system to read from, and this is the whole reason the project could not ship
content to a browser. A file is only synchronously readable if our own build put its bytes into the VFS first,
so every file in the directory has to be named in a preload manifest under
Library/PlayerDataCache/WebGLPreloadedStreamingAssets— an internal Unity cache, which is why stale manifests have to be deleted rather than trusted.
The active build target is switched before building, because a content directory is built for the active target and a directory built for another one registers and then fails per file in the player ("File's Build target is: 19"). Getting this wrong produces content that loads in the editor and not in the build, which is the most expensive way to find out.
public class ContentDirectoryBuildProcessor : BuildPlayerProcessor, IOrderedCallback
- Inheritance
-
objectContentDirectoryBuildProcessor
- Implements
Fields
- BasePathInStreamingAssets
Where the content directories are placed inside StreamingAssets, i.e. inside the player.
Properties
- callbackOrder
Returns the relative callback order for callbacks. Callbacks with lower values are called before ones with higher values.
Methods
- PrepareForBuild(BuildPlayerContext)
Implement this function to receive a callback before a Player build starts.