概要
方法
GetClass(className: string,filter: Dictionary):ReflectedClass? |
GetClasses(filter: Dictionary):{ReflectedClass} |
GetEventsOfClass(className: string,filter: Dictionary):{ReflectedEvent} |
GetMethodsOfClass(className: string,filter: Dictionary):{ReflectedMethod} |
GetPropertiesOfClass(className: string,filter: Dictionary):{ReflectedProperty} |
範例程式碼
ReflectionService 概述
local ReflectionService = game:GetService("ReflectionService")
-- 創建一個具有所有能力的 SecurityCapabilities 對象
local allCapabilities = SecurityCapabilities.new(table.unpack(Enum.SecurityCapability:GetEnumItems()))
-- 獲取所有可用於所有能力的類
local allClasses = ReflectionService:GetClasses({ Security = allCapabilities })
print("總類數:", #allClasses)
-- 獲取特定類
local partClass = ReflectionService:GetClass("Part")
if partClass then
print("\nPart 類:")
print(" 名稱:", partClass.Name)
print(" 超類:", partClass.Superclass and tostring(partClass.Superclass) or "無")
end
-- 獲取類的前 5 個屬性
local properties = ReflectionService:GetPropertiesOfClass("Part", { Security = allCapabilities })
print("\nPart 屬性:", #properties)
for i = 1, math.min(5, #properties) do
print(" -", properties[i].Name)
endAPI 參考
方法
GetClass
參數
| 預設值:"nil" |
返回
ReflectedClass?
GetClasses
參數
| 預設值:"nil" |
返回
{ReflectedClass}
GetEventsOfClass
參數
| 預設值:"nil" |
返回
{ReflectedEvent}
GetMethodsOfClass
參數
| 預設值:"nil" |
返回
{ReflectedMethod}
GetPropertiesOfClass
參數
| 預設值:"nil" |
返回
{ReflectedProperty}