Merge branch 'TerrainLayerNames' of https://github.com/xxSeys1/FlaxEngine into xxSeys1-TerrainLayerNames

This commit is contained in:
Wojtek Figat
2024-11-26 15:59:01 +01:00
5 changed files with 75 additions and 17 deletions

View File

@@ -30,6 +30,33 @@ namespace FlaxEditor.Content.Settings
return GetCurrentLayers(out int _);
}
/// <summary>
/// The layers names.
/// </summary>
[EditorOrder(10), EditorDisplay("Terrain Layers", EditorDisplayAttribute.InlineStyle), Collection(CanResize = false, Display = CollectionAttribute.DisplayType.Inline)]
public string[] TerrainLayers = new string[8];
/// <summary>
/// Gets the current terrain layer names. Returns "Layer" + index for layers without a name.
/// </summary>
/// <returns>The layer names.</returns>
public static string[] GetCurrentTerrainLayers()
{
#if FLAX_TESTS
return System.Array.Empty<string>();
#else
string[] layerNames = GameSettings.Load<LayersAndTagsSettings>().TerrainLayers;
for (int i = 0; i < layerNames.Length; i++)
{
if (string.IsNullOrEmpty(layerNames[i]))
layerNames[i] = $"Layer {i}";
}
return layerNames;
#endif
}
[LibraryImport("FlaxEngine", EntryPoint = "LayersAndTagsSettingsInternal_GetCurrentLayers", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))]
[return: MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "layerCount")]
internal static partial string[] GetCurrentLayers(out int layerCount);