Ghi chú phát hành
Học
Lớp công cụ
PartOperation

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Phương Pháp
Thành viên kế thừa

Tài Liệu Tham Khảo API
Thuộc Tính
RenderFidelity
Bảo Mật Plugin
Đọc Song Song
Các khả năng: Basic, CSG
PartOperation.RenderFidelity:Enum.RenderFidelity

SmoothingAngle
Bảo Mật Plugin
Đọc Song Song
Các khả năng: Basic, CSG
PartOperation.SmoothingAngle:number

TriangleCount
Bảo Mật Roblox
Đọc Song Song
Các khả năng: Basic, CSG
PartOperation.TriangleCount:number

UsePartColor
Đọc Song Song
Các khả năng: Basic, CSG
PartOperation.UsePartColor:boolean

Phương Pháp
SubstituteGeometry
Các khả năng: Basic, CSG
PartOperation:SubstituteGeometry(source:Instance):()
Tham Số
source:Instance
Lợi Nhuận
()
Mẫu mã
Thay thế Hình học và Ràng buộc Thả
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,
}
-- Thực hiện phép toán hợp nhất trong pcall() vì nó là bất đồng bộ
local success, newParts = pcall(function()
return GeometryService:UnionAsync(mainPart, otherParts, options)
end)
if success and #newParts > 0 and mainPart:IsA("PartOperation") then
-- Đặt phần đầu tiên trong phép toán kết quả làm phần để sử dụng cho thay thế
-- Phần đầu tiên chỉ đơn giản là một tùy chọn; điều này có thể là bất kỳ PartOperation nào
local substitutePart = newParts[1]
-- Định vị lại phần này đến vị trí của phần chính
substitutePart.CFrame = mainPart.CFrame
-- Tính toán các ràng buộc/gắn kết để bảo tồn hoặc thả
local recommendedTable = GeometryService:CalculateConstraintsToPreserve(mainPart, newParts, constraintOptions)
-- Thay thế hình học của phần chính với hình học thay thế
mainPart:SubstituteGeometry(substitutePart)
-- Thả các ràng buộc/gắn kết không được tự động bảo tồn với thay thế
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
-- Hủy bỏ các phần khác
for _, otherPart in pairs(otherParts) do
otherPart.Parent = nil
otherPart:Destroy()
end
end

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.