學習
引擎類別
PartOperation

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


概要
方法
繼承成員

API 參考
屬性
RenderFidelity
外掛程式安全性
平行讀取
功能: Basic, CSG
PartOperation.RenderFidelity:Enum.RenderFidelity

SmoothingAngle
外掛程式安全性
平行讀取
功能: Basic, CSG
PartOperation.SmoothingAngle:number

TriangleCount
Roblox 安全性
平行讀取
功能: Basic, CSG
PartOperation.TriangleCount:number

UsePartColor
平行讀取
功能: Basic, CSG
PartOperation.UsePartColor:boolean

方法
SubstituteGeometry
功能: Basic, CSG
PartOperation:SubstituteGeometry(source:Instance):()
參數
source:Instance
返回
()
範例程式碼
替代幾何體和刪除約束
local GeometryService = game:GetService("GeometryService")
local mainPart = workspace.PurpleBlock
local otherParts = { workspace.BlueBlock }
local options = {
CollisionFidelity = Enum.CollisionFidelity.Default,
RenderFidelity = Enum.RenderFidelity.Automatic,
SplitApart = false,
}
local constraintOptions = {
tolerance = 0.1,
weldConstraintPreserve = Enum.WeldConstraintPreserve.All,
}
-- 在 pcall() 中執行聯集操作,因為它是異步的
local success, newParts = pcall(function()
return GeometryService:UnionAsync(mainPart, otherParts, options)
end)
if success and #newParts > 0 and mainPart:IsA("PartOperation") then
-- 將結果操作中的第一個部分設置為用於替代的部分
-- 第一部分僅僅是一個選項;這可以是任何 PartOperation
local substitutePart = newParts[1]
-- 將部分移動到主部件的位置
substitutePart.CFrame = mainPart.CFrame
-- 計算要保留或刪除的約束/附著物
local recommendedTable = GeometryService:CalculateConstraintsToPreserve(mainPart, newParts, constraintOptions)
-- 用替代的幾何體替代主部件的幾何體
mainPart:SubstituteGeometry(substitutePart)
-- 刪除未自動保留的約束/附著物
for _, item in pairs(recommendedTable) do
if item.Attachment then
if item.ConstraintParent == nil then
item.Constraint.Parent = nil
end
if item.AttachmentParent == nil then
item.Attachment.Parent = nil
end
elseif item.WeldConstraint then
if item.Parent == nil then
item.WeldConstraint.Parent = nil
end
end
end
-- 銷毀其他部分
for _, otherPart in pairs(otherParts) do
otherPart.Parent = nil
otherPart:Destroy()
end
end

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