Merge remote-tracking branch 'origin/master' into 1.8

# Conflicts:
#	Source/Editor/Utilities/EditorUtilities.cpp
#	Source/Editor/Utilities/EditorUtilities.h
This commit is contained in:
Wojtek Figat
2024-02-19 22:26:16 +01:00
219 changed files with 4189 additions and 2372 deletions

View File

@@ -61,6 +61,16 @@ namespace FlaxEngine
/// </summary>
public float Spacing;
/// <summary>
/// The minimum size of the collection.
/// </summary>
public int MinCount;
/// <summary>
/// The maximum size of the collection. Zero if unlimited.
/// </summary>
public int MaxCount;
/// <summary>
/// The collection background color.
/// </summary>

View File

@@ -0,0 +1,25 @@
using System;
namespace FlaxEngine;
/// <summary>
/// This attribute is used to check for if a script requires an Actor type.
/// </summary>
[Serializable]
[AttributeUsage(AttributeTargets.Class)]
public class RequireActorAttribute : Attribute
{
/// <summary>
/// The required type.
/// </summary>
public Type RequiredType;
/// <summary>
/// Initializes a new instance of the <see cref="RequireActorAttribute"/> class.
/// </summary>
/// <param name="type">The required type.</param>
public RequireActorAttribute(Type type)
{
RequiredType = type;
}
}

View File

@@ -0,0 +1,34 @@
using System;
namespace FlaxEngine;
/// <summary>
/// This attribute is used to check for if a script requires other script types.
/// </summary>
[Serializable]
[AttributeUsage(AttributeTargets.Class)]
public class RequireScriptAttribute : Attribute
{
/// <summary>
/// The required types.
/// </summary>
public Type[] RequiredTypes;
/// <summary>
/// Initializes a new instance of the <see cref="RequireScriptAttribute"/> class.
/// </summary>
/// <param name="type">The required type.</param>
public RequireScriptAttribute(Type type)
{
RequiredTypes = new[] { type };
}
/// <summary>
/// Initializes a new instance of the <see cref="RequireScriptAttribute"/> class.
/// </summary>
/// <param name="types">The required types.</param>
public RequireScriptAttribute(Type[] types)
{
RequiredTypes = types;
}
}

View File

@@ -533,7 +533,12 @@ void ScriptingType::HackObjectVTable(void* object, ScriptingTypeHandle baseTypeH
if (!Script.VTable)
{
// Ensure to have valid Script VTable hacked
SetupScriptObjectVTable(object, baseTypeHandle, wrapperIndex);
BinaryModule::Locker.Lock();
if (!Script.VTable)
{
SetupScriptObjectVTable(object, baseTypeHandle, wrapperIndex);
}
BinaryModule::Locker.Unlock();
}
// Override object vtable with hacked one that has calls to overriden scripting functions

View File

@@ -68,4 +68,30 @@ public:
{
return FromString<EnumType>(StringAnsi(name));
}
// Gets the name of the enum value as separated flags
template<class EnumType>
static String ToStringFlags(EnumType value, Char separator = '|')
{
String result;
if (const auto items = GetItems<EnumType>())
{
for (int32 i = 0; items[i].Name; i++)
{
const uint64 itemValue = items[i].Value;
if ((uint64)value == 0 && itemValue == 0)
{
result = items[i].Name;
break;
}
if (itemValue != 0 && EnumHasAllFlags<EnumType>(value, (EnumType)itemValue))
{
if (result.HasChars())
result += separator;
result += items[i].Name;
}
}
}
return result;
}
};

View File

@@ -116,7 +116,7 @@ Action Scripting::ScriptsLoaded;
Action Scripting::ScriptsUnload;
Action Scripting::ScriptsReloading;
Action Scripting::ScriptsReloaded;
ThreadLocal<Scripting::IdsMappingTable*, PLATFORM_THREADS_LIMIT, true> Scripting::ObjectsLookupIdMapping;
ThreadLocal<Scripting::IdsMappingTable*, PLATFORM_THREADS_LIMIT> Scripting::ObjectsLookupIdMapping;
ScriptingService ScriptingServiceInstance;
bool initFlaxEngine();

View File

@@ -6,7 +6,7 @@
#include "Engine/Scripting/ScriptingType.h"
#include "Types.h"
template<typename T, int32 MaxThreads, bool ClearMemory>
template<typename T, int32 MaxThreads>
class ThreadLocal;
/// <summary>
@@ -114,7 +114,7 @@ public:
/// <summary>
/// The objects lookup identifier mapping used to override the object ids on FindObject call (used by the object references deserialization).
/// </summary>
static ThreadLocal<IdsMappingTable*, PLATFORM_THREADS_LIMIT, true> ObjectsLookupIdMapping;
static ThreadLocal<IdsMappingTable*, PLATFORM_THREADS_LIMIT> ObjectsLookupIdMapping;
/// <summary>
/// Finds the object by the given identifier. Searches registered scene objects and optionally assets. Logs warning if fails.