Skip to main content

WorldLandmark

A class in Root.Township, Alta.Chunks.

An asset for a large landmark prefab that's loaded through Addressables while certain chunks are loaded, and unloaded when none of them are.

Constructors​

MemberWhat it is
WorldLandmark()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

8 private and internal fields
MemberWhat it is
private bool isLoadedWhether the landmark is meant to be loaded; set as soon as Load starts. Backing field for IsLoaded.
private AsyncOperationHandle<GameObject> loadThe addressables load operation for the prefab.
private ChunkReference[] loadedChunksReferences to chunks that keep the landmark loaded while any of them is loaded.
private static Logger loggerClass logger.
private AssetReference prefabAddressable prefab spawned when the landmark loads. Backing field for Prefab.
private Chunk[] sceneLoadedChunksResolved chunks from loadedChunks. Backing field for LoadedChunks.
private Chunk[] sceneStaticChunksResolved chunks from staticChunks. Backing field for StaticChunks.
private ChunkReference[] staticChunksReferences to static chunks linked to the landmark.

Properties​

MemberWhat it is
bool IsLoaded { get; }True from Load until Unload, even while still loading.
bool IsLoading { get; }True while the prefab load is still running.
Chunk[] LoadedChunks { get; }The scene chunks that keep this landmark loaded. Filled by ResolveChunkReferences.
TaskCompletionSource<bool> LoadingTask { get; private set; }Completes when the current load finishes. Null when not loading.
AssetReference Prefab { get; }The Addressables reference to the landmark prefab.
GameObject SpawnedPrefab { get; private set; }The spawned landmark object while loaded.
Chunk[] StaticChunks { get; }The scene chunks listed as static for this landmark. Filled by ResolveChunkReferences.

Methods​

MemberWhat it is
void CheckUnload()Unloads the landmark if none of its loaded chunks are loaded.
bool Load()Starts loading and spawning the prefab. False if it was already loaded.
void ResetReferences()Destroys the spawned prefab, releases the asset and drops the load handle.
void ResolveChunkReferences()Turns the chunk references into scene chunks, skipping missing ones.
void Unload()Destroys the spawned prefab and releases the asset.
protected virtual void OnLoadCompleted(GameObject spawnedPrefab)Override hook, called with the spawned prefab after loading.
protected virtual void OnUnloadCompleted()Override hook, called after unloading.
1 private and internal method
MemberWhat it is
private void LoadComplete(AsyncOperationHandle<GameObject> spawned)Addressables callback: finishes LoadingTask and spawns the prefab, or releases it if the landmark was unloaded meanwhile.

Used in​

Members of other types that take, return or hold a WorldLandmark: