// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
partial class Level
{
///
/// Unloads all active scenes and loads the given scene (in the background).
///
/// The scene asset identifier (scene to load).
/// True if action fails (given asset is not a scene asset, missing data, scene loading error), otherwise false.
public static bool ChangeSceneAsync(Guid sceneAssetId)
{
UnloadAllScenesAsync();
return LoadSceneAsync(sceneAssetId);
}
///
/// Unloads all active scenes and loads the given scene (in the background).
///
/// The asset with the scene to load.
/// True if action fails (given asset is not a scene asset, missing data, scene loading error), otherwise false.
public static bool ChangeSceneAsync(SceneReference sceneAsset)
{
return ChangeSceneAsync(sceneAsset.ID);
}
///
/// Loads scene from the asset.
///
/// The asset with the scene to load.
/// True if action fails (given asset is not a scene asset, missing data, scene loading error), otherwise false.
public static bool LoadScene(SceneReference sceneAsset)
{
return LoadScene(sceneAsset.ID);
}
///
/// Loads scene from the asset. Done in the background.
///
/// The asset with the scene to load.
/// True if failed (given asset is not a scene asset, missing data), otherwise false.
public static bool LoadSceneAsync(SceneReference sceneAsset)
{
return LoadSceneAsync(sceneAsset.ID);
}
///
/// Tries to find script of the given type in all loaded scenes.
///
/// Type of the object.
/// Found script or null.
public static T FindScript() where T : Script
{
return FindScript(typeof(T)) as T;
}
///
/// Tries to find actor of the given type in all loaded scenes.
///
/// Type of the object.
/// Found actor or null.
public static T FindActor() where T : Actor
{
return FindActor(typeof(T)) as T;
}
///
/// Tries to find actor with the given ID in all loaded scenes. It's very fast O(1) lookup.
///
/// Type of the object.
/// The id.
/// Found actor or null.
public static T FindActor(ref Guid id) where T : Actor
{
return FindActor(id) as T;
}
}
}