Merge remote-tracking branch 'upstream/master'

This commit is contained in:
ExMatics HydrogenC
2023-12-19 12:33:13 +08:00
183 changed files with 6019 additions and 3547 deletions

View File

@@ -1235,17 +1235,17 @@ bool ManagedBinaryModule::InvokeMethod(void* method, const Variant& instance, Sp
const bool withInterfaces = !mMethod->IsStatic() && mMethod->GetParentClass()->IsInterface();
if (!mMethod->IsStatic())
{
// Box instance into C# object
// Box instance into C# object (and validate the type)
MObject* instanceObject = MUtils::BoxVariant(instance);
const MClass* instanceObjectClass = MCore::Object::GetClass(instanceObject);
// Validate instance
if (!instanceObject || !instanceObjectClass->IsSubClassOf(mMethod->GetParentClass(), withInterfaces))
if (!instanceObject)
{
if (!instanceObject)
LOG(Error, "Failed to call method '{0}.{1}' (args count: {2}) without object instance", String(mMethod->GetParentClass()->GetFullName()), String(mMethod->GetName()), parametersCount);
else
LOG(Error, "Failed to call method '{0}.{1}' (args count: {2}) with invalid object instance of type '{3}'", String(mMethod->GetParentClass()->GetFullName()), String(mMethod->GetName()), parametersCount, String(MUtils::GetClassFullname(instanceObject)));
LOG(Error, "Failed to call method '{0}.{1}' (args count: {2}) without object instance", String(mMethod->GetParentClass()->GetFullName()), String(mMethod->GetName()), parametersCount);
return true;
}
const MClass* instanceObjectClass = MCore::Object::GetClass(instanceObject);
if (!instanceObjectClass->IsSubClassOf(mMethod->GetParentClass(), withInterfaces))
{
LOG(Error, "Failed to call method '{0}.{1}' (args count: {2}) with invalid object instance of type '{3}'", String(mMethod->GetParentClass()->GetFullName()), String(mMethod->GetName()), parametersCount, String(MUtils::GetClassFullname(instanceObject)));
return true;
}

View File

@@ -108,6 +108,7 @@ namespace
};
ChunkedArray<Location, 256> ManagedSourceLocations;
ThreadLocal<uint32> ManagedEventsCount;
#endif
#endif
}
@@ -145,7 +146,9 @@ DEFINE_INTERNAL_CALL(void) ProfilerInternal_BeginEvent(MString* nameObj)
srcLoc->color = 0;
}
//static constexpr tracy::SourceLocationData tracySrcLoc{ nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 };
tracy::ScopedZone::Begin(srcLoc);
const bool tracyActive = tracy::ScopedZone::Begin(srcLoc);
if (tracyActive)
ManagedEventsCount.Get()++;
#endif
#endif
#endif
@@ -155,7 +158,12 @@ DEFINE_INTERNAL_CALL(void) ProfilerInternal_EndEvent()
{
#if COMPILE_WITH_PROFILER
#if TRACY_ENABLE
tracy::ScopedZone::End();
uint32& tracyActive = ManagedEventsCount.Get();
if (tracyActive > 0)
{
tracyActive--;
tracy::ScopedZone::End();
}
#endif
ProfilerCPU::EndEvent();
#endif

View File

@@ -1657,7 +1657,7 @@ bool InitHostfxr()
// Get path to hostfxr library
get_hostfxr_parameters get_hostfxr_params;
get_hostfxr_params.size = sizeof(hostfxr_initialize_parameters);
get_hostfxr_params.size = sizeof(get_hostfxr_parameters);
get_hostfxr_params.assembly_path = libraryPath.Get();
#if PLATFORM_MAC
::String macOSDotnetRoot = TEXT("/usr/local/share/dotnet");

View File

@@ -27,6 +27,7 @@ Script::Script(const SpawnParams& params)
, _tickUpdate(false)
, _tickLateUpdate(false)
, _tickLateFixedUpdate(false)
, _wasAwakeCalled(false)
, _wasStartCalled(false)
, _wasEnableCalled(false)
{
@@ -86,7 +87,7 @@ void Script::SetParent(Actor* value, bool canBreakPrefabLink)
// Unlink from the old one
if (_parent)
{
if (!value && _parent->IsDuringPlay() && _parent->IsActiveInHierarchy() && GetEnabled())
if (!value && _parent->IsDuringPlay() && _parent->IsActiveInHierarchy() && GetEnabled() && _wasEnableCalled)
{
// Call disable when script is removed from actor (new actor is null)
Disable();
@@ -241,19 +242,31 @@ String Script::ToString() const
void Script::OnDeleteObject()
{
// Ensure to unlink from the parent (it will call Disable event if required)
SetParent(nullptr);
// Check if remove object from game
if (IsDuringPlay())
// Call OnDisable
if (_wasEnableCalled)
{
Disable();
}
// Call OnDestroy
if (_wasAwakeCalled)
{
_wasAwakeCalled = false;
CHECK_EXECUTE_IN_EDITOR
{
OnDestroy();
}
}
// End play
if (IsDuringPlay())
{
EndPlay();
}
// Unlink from parent
SetParent(nullptr);
// Base
SceneObject::OnDeleteObject();
}
@@ -274,6 +287,9 @@ void Script::Initialize()
if (!IsRegistered())
RegisterObject();
// Call OnAwake
ASSERT(!_wasAwakeCalled);
_wasAwakeCalled = true;
CHECK_EXECUTE_IN_EDITOR
{
OnAwake();

View File

@@ -20,6 +20,7 @@ protected:
uint16 _tickUpdate : 1;
uint16 _tickLateUpdate : 1;
uint16 _tickLateFixedUpdate : 1;
uint16 _wasAwakeCalled : 1;
uint16 _wasStartCalled : 1;
uint16 _wasEnableCalled : 1;
#if USE_EDITOR