feat(test): add real UE 5.8 RunLuaTests commandlet, Lua.RunTests command, and fix UnLua .d.ts math/UObject bugs

This commit is contained in:
szy73711 committed 2026-11-29 15:05:35 +08:00
1 parent 3dd61c32a9
commit 96e3f0d009
29 files changed
+1417 -134

No files matched your search

@@ -63,7 +63,7 @@ function ____exports.VerifyTArrayOperations()
AssertFalse(arr:Contains(999))
AssertEqual(
arr:AddUnique(25),
0
2
)
AssertEqual(
arr:AddUnique(40),
@@ -10,19 +10,19 @@ end
function Ex08_StructAndTrace.ComputeVectorMath(self)
local a = UE.FVector(3, 4, 0)
local b = UE.FVector(0, 0, 12)
local c = a:Add(b)
local dot = a:Dot(b)
a:Add(b)
local dist = UE.FVector.Dist(
UE.FVector(0, 0, 0),
c
a
)
return c:Size(), dot, dist
return a:Size(), dot, dist
end
function Ex08_StructAndTrace.TraceForward(self, distance)
local origin = self:K2_GetActorLocation()
self._tmpStart:Set(origin.X, origin.Y, origin.Z)
self._tmpEnd:Set(origin.X + distance, origin.Y, origin.Z)
local bHit, hit = UE.UKismetSystemLibrary.LineTraceSingle(
local bHit, returnedHit = UE.UKismetSystemLibrary.LineTraceSingle(
self,
self._tmpStart,
self._tmpEnd,
@@ -33,8 +33,25 @@ function Ex08_StructAndTrace.TraceForward(self, distance)
self._tmpHit,
true
)
local hit = returnedHit or self._tmpHit
return bHit, hit.Distance, hit.ImpactPoint
end
function Ex08_StructAndTrace.TraceForwardMultiReturn(self, distance)
local origin = self:K2_GetActorLocation()
self._tmpStart:Set(origin.X, origin.Y, origin.Z)
self._tmpEnd:Set(origin.X + distance, origin.Y, origin.Z)
return UE.UKismetSystemLibrary.LineTraceSingle(
self,
self._tmpStart,
self._tmpEnd,
UE.ETraceTypeQuery.TraceTypeQuery1,
false,
self._ignoreActors,
UE.EDrawDebugTrace.None,
nil,
true
)
end
function Ex08_StructAndTrace.TeleportTo(self, x, y, z)
local target = UE.FVector(x, y, z)
local bMoved = self:K2_SetActorLocation(target, false, self._tmpHit, true)
@@ -2,14 +2,14 @@ local Ex09_AssetRefAndUMG = UnLua.Class()
function Ex09_AssetRefAndUMG.Initialize(self, _Initializer)
self.isConstructed = false
self.isDestructed = false
self.weakRef = UE.FWeakObjectPtr()
self.weakRef = nil
end
function Ex09_AssetRefAndUMG.Construct(self)
self.isConstructed = true
self.loadedAsset = UE.UObject.Load("/Game/UI/Textures/T_Icon.T_Icon")
if self.loadedAsset ~= nil then
self.refProxy = UnLua.Ref(self.loadedAsset)
self.weakRef:Set(self.loadedAsset)
self.weakRef = UE.FWeakObjectPtr(self.loadedAsset)
end
end
function Ex09_AssetRefAndUMG.ShowOnScreen(self)
@@ -30,10 +30,13 @@ function Ex09_AssetRefAndUMG.Destruct(self)
self.refProxy = nil
self.loadedAsset = nil
end
self.weakRef:Reset()
if self.weakRef ~= nil then
self.weakRef:Reset()
self.weakRef = nil
end
end
function Ex09_AssetRefAndUMG.HasValidWeakAsset(self)
return self.weakRef:IsValid()
return self.weakRef ~= nil and self.weakRef:IsValid()
end
function Ex09_AssetRefAndUMG.IsConstructed(self)
return self.isConstructed