學習
引擎類別
Decal

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


範例程式碼
更改貼圖纹理
-- 創建部件
local part = Instance.new("Part")
part.Size = Vector3.new(5, 1, 5)
part.Position = Vector3.new(0, 0.5, 0)
part.Anchored = true
part.TopSurface = Enum.SurfaceType.Smooth
part.BrickColor = BrickColor.new("Toothpaste")
-- 創建貼圖
local decal = Instance.new("Decal")
decal.Face = Enum.NormalId.Top
decal.Parent = part
-- 定義面
local happyFace = Content.fromUri("http://www.roblox.com/asset/?id=26424652")
local sadFace = Content.fromUri("http://www.roblox.com/asset/?id=147144198")
decal.ColorMapContent = happyFace
-- 被碰觸事件
local cooldown = false
part.Touched:Connect(function(hit)
if not cooldown then
if hit and hit.Parent then
cooldown = true
sound:Play()
decal.ColorMapContent = sadFace
task.wait(1)
decal.ColorMapContent = happyFace
task.wait(0.2)
cooldown = false
end
end
end)
-- 添加到工作空間
part.Parent = workspace
漸變貼圖
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Size = Vector3.new(10, 10, 1)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Transparency = 1
local decal = Instance.new("Decal")
decal.Face = Enum.NormalId.Front
decal.ColorMapContent = Content.fromUri("http://www.roblox.com/asset/?id=699259085") -- roblox 標誌
decal.Parent = part
part.Parent = workspace
local tween = TweenService:Create(
decal,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true),
{ Transparency = 1 }
)
tween:Play()

API 參考
屬性
Color3
平行讀取
功能: Basic
Decal.Color3:Color3
範例程式碼
貼圖顏色
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Size = Vector3.new(10, 10, 1)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Transparency = 1
local decal = Instance.new("Decal")
decal.Face = Enum.NormalId.Front
decal.ColorMapContent = Content.fromUri("http://www.roblox.com/asset/?id=1145367640")
decal.Parent = part
part.Parent = workspace
local redTween = TweenService:Create(
decal,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
{ Color3 = Color3.new(1, 0, 0) }
)
local greenTween = TweenService:Create(
decal,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
{ Color3 = Color3.new(0, 1, 0) }
)
local blueTween = TweenService:Create(
decal,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
{ Color3 = Color3.new(0, 0, 1) }
)
while true do
redTween:Play()
redTween.Completed:Wait()
greenTween:Play()
greenTween.Completed:Wait()
blueTween:Play()
blueTween.Completed:Wait()
end

ColorMap
未複製
平行讀取
功能: Basic
Decal.ColorMap:ContentId

ColorMapContent
未複製
平行讀取
功能: Basic
Decal.ColorMapContent:Content

LocalTransparencyModifier
隱藏
未複製
平行讀取
功能: Basic
Decal.LocalTransparencyModifier:number

MetalnessMap
隱藏
外掛程式安全性
平行讀取
功能: Basic
Decal.MetalnessMap:ContentId

MetalnessMapContent
外掛程式安全性
平行讀取
功能: Basic
Decal.MetalnessMapContent:Content

NormalMap
隱藏
外掛程式安全性
平行讀取
功能: Basic
Decal.NormalMap:ContentId

NormalMapContent
外掛程式安全性
平行讀取
功能: Basic
Decal.NormalMapContent:Content

Rotation
平行讀取
功能: Basic
Decal.Rotation:number

RoughnessMap
隱藏
外掛程式安全性
平行讀取
功能: Basic
Decal.RoughnessMap:ContentId

RoughnessMapContent
外掛程式安全性
平行讀取
功能: Basic
Decal.RoughnessMapContent:Content

Shiny
已棄用

Specular
已棄用

Texture
已棄用

TextureContent
已棄用

TexturePack
Roblox 安全性
平行讀取
功能: Basic
Decal.TexturePack:ContentId

Transparency
平行讀取
功能: Basic
Decal.Transparency:number

UVOffset
平行讀取
功能: Basic
Decal.UVOffset:Vector2

UVScale
平行讀取
功能: Basic
Decal.UVScale:Vector2

ZIndex
平行讀取
功能: Basic
Decal.ZIndex:number

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