學習
引擎類別
ReflectionService
無法建立
服務
未複製

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要

方法
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)
end

API 參考
方法
GetClass
ReflectionService:GetClass(
className:string, filter:Dictionary
):ReflectedClass?
參數
className:string
filter:Dictionary
預設值:"nil"
返回
ReflectedClass?

GetClasses
ReflectionService:GetClasses(filter:Dictionary):{ReflectedClass}
參數
filter:Dictionary
預設值:"nil"
返回
{ReflectedClass}

GetEventsOfClass
ReflectionService:GetEventsOfClass(
className:string, filter:Dictionary
):{ReflectedEvent}
參數
className:string
filter:Dictionary
預設值:"nil"
返回
{ReflectedEvent}

GetMethodsOfClass
ReflectionService:GetMethodsOfClass(
className:string, filter:Dictionary
):{ReflectedMethod}
參數
className:string
filter:Dictionary
預設值:"nil"
返回
{ReflectedMethod}

GetPropertiesOfClass
ReflectionService:GetPropertiesOfClass(
className:string, filter:Dictionary
):{ReflectedProperty}
參數
className:string
filter:Dictionary
預設值:"nil"
返回
{ReflectedProperty}

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。