Decal

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

デカルオブジェクトは、BasePart の顔に画像を適用するオブジェクトです。

デカルはどのように機能しますか?

デカルは、親になった BasePart に画像を適用します。この画像が適用される表面は、FaceInstance.Face プロパティに依存します。デカールのサイズは、顔のサイズに依存しており、デカールのサイズとアスペクト比は、親の BasePart.Size を変更することで変更できます。

デカルが適用する画像は、Decal.Texture プロパティによって決まります。画像は、コミュニティガイドラインに従う限り、Robloxにアップロードできます。For information on how to upload images, see テクスチャとデカル

デカールの代替品

デカールには多種多様なアプリケーションがありますが、いくつかの場合、開発者は代わりに次のクラスの 1つを選択したいかもしれません。

  • 繰り返しタイル化されたテクスチャの場合、Texture オブジェクトを使用する必要があります
  • GUI 要素を適用するには、SurfaceGui オブジェクトを使用する必要があります
  • 画像の照明効果を変更する必要がある場合は、SurfaceGui オブジェクトを使用する必要があります

コードサンプル

次のコードは、そのトップフェイスに Part を適用して地面に Decal を作成します。プレイヤーがそれを越えるといったように、パーツに何かが当たると、デカールに適用されたテクスチャが変わり、サウンドが再生されます。

デカルのテクスチャを変更中

-- パーツを作成
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 sound = Instance.new("Sound")
sound.SoundId = "rbxasset://sounds/uuhhh.mp3" -- おお
sound.Parent = part
-- 顔を定義する
local happyFace = "http://www.roblox.com/asset/?id=26424652"
local sadFace = "http://www.roblox.com/asset/?id=147144198"
decal.Texture = happyFace
-- タッチイベント
local cooldown = false
part.Touched:Connect(function(hit)
if not cooldown then
if hit and hit.Parent then
cooldown = true
sound:Play()
decal.Texture = sadFace
task.wait(1)
decal.Texture = happyFace
task.wait(0.2)
cooldown = false
end
end
end)
-- ワークスペースに追加する
part.Parent = workspace

概要

プロパティ

  • 並列読み取り

    The Color3 の色合い of the Decal .

  • 非表示
    複製されていません
    並列読み取り

    デカールカルの Decal.Transparency プロパティのマルチプライヤーとして機能します。効果はローカルプレイヤーにのみ表示されます。

  • Texture:ContentId
    並列読み取り

    Decal に適用される画像のコンテンツID。

  • 並列読み取り
  • 並列読み取り

    透明度を決定します。Decal は 0 が完全に不透明で、1 が完全に透明です。

  • 並列読み取り

    複数のデカルが同じ顔を割り当てられたときのレンダリング順序を決定します。

FaceInstance から継承した プロパティ

プロパティ

  • 並列読み取り

    オブジェクトが表示されるブリックの面を設定します。

プロパティ

Color3

並列読み取り

コードサンプル

デカルカラー3

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.Texture = "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

LocalTransparencyModifier

非表示
複製されていません
並列読み取り

Texture

ContentId
並列読み取り

コードサンプル

デカルのテクスチャを変更中

-- パーツを作成
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 sound = Instance.new("Sound")
sound.SoundId = "rbxasset://sounds/uuhhh.mp3" -- おお
sound.Parent = part
-- 顔を定義する
local happyFace = "http://www.roblox.com/asset/?id=26424652"
local sadFace = "http://www.roblox.com/asset/?id=147144198"
decal.Texture = happyFace
-- タッチイベント
local cooldown = false
part.Touched:Connect(function(hit)
if not cooldown then
if hit and hit.Parent then
cooldown = true
sound:Play()
decal.Texture = sadFace
task.wait(1)
decal.Texture = happyFace
task.wait(0.2)
cooldown = false
end
end
end)
-- ワークスペースに追加する
part.Parent = workspace

TextureContent

並列読み取り

Transparency

並列読み取り

コードサンプル

Fading Decal

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.Texture = "http://www.roblox.com/asset/?id=699259085" -- roblox logo
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()

ZIndex

並列読み取り

方法

イベント