Add support for accessing Game Settings and related assets in C# API in game build

This commit is contained in:
Wojtek Figat
2021-03-01 16:17:01 +01:00
parent e218cc417f
commit d6b566a3fe
6 changed files with 43 additions and 14 deletions

View File

@@ -7,6 +7,7 @@ namespace FlaxEditor.Content.Settings
{
partial class BuildSettings
{
#if FLAX_EDITOR
/// <summary>
/// The build presets.
/// </summary>
@@ -60,5 +61,6 @@ namespace FlaxEditor.Content.Settings
}
return null;
}
#endif
}
}

View File

@@ -90,41 +90,53 @@ namespace FlaxEditor.Content.Settings
[EditorOrder(1100), EditorDisplay("Other Settings"), Tooltip("The custom settings to use with a game. Can be specified by the user to define game-specific options and be used by the external plugins (used as key-value pair).")]
public Dictionary<string, JsonAsset> CustomSettings;
#if FLAX_EDITOR || PLATFORM_WINDOWS
/// <summary>
/// Reference to <see cref="WindowsPlatformSettings"/> asset. Used to apply configuration on Windows platform.
/// </summary>
[EditorOrder(2010), EditorDisplay("Platform Settings", "Windows"), AssetReference(typeof(WindowsPlatformSettings), true), Tooltip("Reference to Windows Platform Settings asset")]
public JsonAsset WindowsPlatform;
#endif
#if FLAX_EDITOR || PLATFORM_UWP || PLATFORM_XBOX_ONE
/// <summary>
/// Reference to <see cref="UWPPlatformSettings"/> asset. Used to apply configuration on Universal Windows Platform.
/// </summary>
[EditorOrder(2020), EditorDisplay("Platform Settings", "Universal Windows Platform"), AssetReference(typeof(UWPPlatformSettings), true), Tooltip("Reference to Universal Windows Platform Settings asset")]
public JsonAsset UWPPlatform;
#endif
#if FLAX_EDITOR || PLATFORM_LINUX
/// <summary>
/// Reference to <see cref="LinuxPlatformSettings"/> asset. Used to apply configuration on Linux platform.
/// </summary>
[EditorOrder(2030), EditorDisplay("Platform Settings", "Linux"), AssetReference(typeof(LinuxPlatformSettings), true), Tooltip("Reference to Linux Platform Settings asset")]
public JsonAsset LinuxPlatform;
#endif
#if FLAX_EDITOR || PLATFORM_PS4
/// <summary>
/// Reference to PS4 Platform Settings asset. Used to apply configuration on PS4 platform.
/// </summary>
[EditorOrder(2040), EditorDisplay("Platform Settings", "PlayStation 4"), AssetReference(PS4PlatformSettingsTypename, true), Tooltip("Reference to PS4 Platform Settings asset")]
public JsonAsset PS4Platform;
#endif
#if FLAX_EDITOR || PLATFORM_XBOX_SCARLETT
/// <summary>
/// Reference to Xbox Scarlett Platform Settings asset. Used to apply configuration on Xbox Scarlett platform.
/// </summary>
[EditorOrder(2050), EditorDisplay("Platform Settings", "Xbox Scarlett"), AssetReference(XboxScarlettPlatformSettingsTypename, true), Tooltip("Reference to Xbox Scarlett Platform Settings asset")]
public JsonAsset XboxScarlettPlatform;
#endif
#if FLAX_EDITOR || PLATFORM_ANDROID
/// <summary>
/// Reference to <see cref="AndroidPlatformSettings"/> asset. Used to apply configuration on Android platform.
/// </summary>
[EditorOrder(2060), EditorDisplay("Platform Settings", "Android"), AssetReference(typeof(AndroidPlatformSettings), true), Tooltip("Reference to Android Platform Settings asset")]
public JsonAsset AndroidPlatform;
#endif
/// <summary>
/// Gets the absolute path to the game settings asset file.
@@ -202,20 +214,32 @@ namespace FlaxEditor.Content.Settings
return LoadAsset<BuildSettings>(gameSettings.GameCooking) as T;
if (type == typeof(InputSettings))
return LoadAsset<InputSettings>(gameSettings.Input) as T;
if (type == typeof(WindowsPlatformSettings))
return LoadAsset<WindowsPlatformSettings>(gameSettings.WindowsPlatform) as T;
if (type == typeof(UWPPlatformSettings))
return LoadAsset<UWPPlatformSettings>(gameSettings.UWPPlatform) as T;
if (type == typeof(LinuxPlatformSettings))
return LoadAsset<LinuxPlatformSettings>(gameSettings.LinuxPlatform) as T;
if (type.FullName == PS4PlatformSettingsTypename)
return LoadAsset(gameSettings.PS4Platform, PS4PlatformSettingsTypename) as T;
if (type.FullName == XboxScarlettPlatformSettingsTypename)
return LoadAsset(gameSettings.XboxScarlettPlatform, XboxScarlettPlatformSettingsTypename) as T;
if (type == typeof(AndroidPlatformSettings))
return LoadAsset<AndroidPlatformSettings>(gameSettings.AndroidPlatform) as T;
if (type == typeof(AudioSettings))
return LoadAsset<AudioSettings>(gameSettings.Audio) as T;
#if FLAX_EDITOR || PLATFORM_WINDOWS
if (type == typeof(WindowsPlatformSettings))
return LoadAsset<WindowsPlatformSettings>(gameSettings.WindowsPlatform) as T;
#endif
#if FLAX_EDITOR || PLATFORM_UWP || PLATFORM_XBOX_ONE
if (type == typeof(UWPPlatformSettings))
return LoadAsset<UWPPlatformSettings>(gameSettings.UWPPlatform) as T;
#endif
#if FLAX_EDITOR || PLATFORM_LINUX
if (type == typeof(LinuxPlatformSettings))
return LoadAsset<LinuxPlatformSettings>(gameSettings.LinuxPlatform) as T;
#endif
#if FLAX_EDITOR || PLATFORM_PS4
if (type.FullName == PS4PlatformSettingsTypename)
return LoadAsset(gameSettings.PS4Platform, PS4PlatformSettingsTypename) as T;
#endif
#if FLAX_EDITOR || PLATFORM_XBOX_SCARLETT
if (type.FullName == XboxScarlettPlatformSettingsTypename)
return LoadAsset(gameSettings.XboxScarlettPlatform, XboxScarlettPlatformSettingsTypename) as T;
#endif
#if FLAX_EDITOR || PLATFORM_ANDROID
if (type == typeof(AndroidPlatformSettings))
return LoadAsset<AndroidPlatformSettings>(gameSettings.AndroidPlatform) as T;
#endif
if (gameSettings.CustomSettings != null)
{
@@ -233,6 +257,7 @@ namespace FlaxEditor.Content.Settings
return null;
}
#if FLAX_EDITOR
private static bool SaveAsset<T>(GameSettings gameSettings, ref JsonAsset asset, T obj) where T : SettingsBase
{
if (asset)
@@ -337,5 +362,6 @@ namespace FlaxEditor.Content.Settings
/// </summary>
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void Apply();
#endif
}
}

View File

@@ -58,7 +58,6 @@ public:
/// <summary>
/// Finds random location on nav mesh within the reach of specified location.
/// </summary>
/// <remarks>If the result location doesn't need to be exactly inside the circle but just in local are aof the navigation mesh polys, then use more optimized <see cref="FindRandomPointAround"/>.</remarks>
/// <param name="center">The source point to find random location around it.</param>
/// <param name="radius">The search distance for a random point. Maximum distance for a result point from the center of the circle.</param>
/// <param name="result">The result position on the navmesh (valid only if method returns true).</param>

View File

@@ -9,7 +9,9 @@ namespace FlaxEditor.Content.Settings
/// <summary>
/// The collision layers masks. Used to define layer-based collision detection.
/// </summary>
[EditorOrder(1040), EditorDisplay("Layers Matrix"), CustomEditor(typeof(FlaxEditor.CustomEditors.Dedicated.LayersMatrixEditor))]
#if FLAX_EDITOR
[EditorOrder(1040), EditorDisplay("Layers Matrix"), CustomEditor(typeof(CustomEditors.Dedicated.LayersMatrixEditor))]
#endif
public uint[] LayerMasks = new uint[32];
/// <summary>