Decal

非推奨を表示

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

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

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

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

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

デカールの代替品

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

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

コードサンプル

The following code will create a Part on the ground with a Decal applied to its top face. When something hits the part, such as when a player walks over it, the texture applied to the decal will change and a sound will play.

Changing Decal Texture

-- create part
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")
-- create decal
local decal = Instance.new("Decal")
decal.Face = Enum.NormalId.Top
decal.Parent = part
-- create sound
local sound = Instance.new("Sound")
sound.SoundId = "rbxasset://sounds/uuhhh.mp3" -- oof
sound.Parent = part
-- define faces
local happyFace = "http://www.roblox.com/asset/?id=26424652"
local sadFace = "http://www.roblox.com/asset/?id=147144198"
decal.Texture = happyFace
-- touched event
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)
-- add to workspace
part.Parent = workspace

概要

プロパティ

  • 並列読み取り

    The Color3 の色合い of the Decal .

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

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

  • Texture:ContentId
    並列読み取り

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

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

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

  • 並列読み取り

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

FaceInstance から継承した プロパティ
  • 並列読み取り

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

プロパティ

Color3

並列読み取り

The Color3 の色合い of the Decal .

開発者は、このプロパティが色ではなく、デカールの色のみを設定することに注意する必要があります。つまり、Decal に関連する画像が元々白ではなかった場合、このプロパティを使用して色を自由に変更することはできません。

連合で Color3 のRGBプロパティを減少することで、開発者はデカールをより暗くすることができます。

コードサンプル

This code sample creates a Decal in the workspace and changes its Decal.Color3 property on a loop using TweenService.

Decal 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.Texture = "http://www.roblox.com/asset/?id=1145367640" -- white circle
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

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

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

このプロパティは、Decal.Transparency が異なるスクリプトによって設定されている状況で使用する必要があります。ローカル透明性修正者の利点は、オリジナルの Decal.TransparencyDecal を気にすることなく変更できることです

ローカル透明性修正者が 1 に設定されると、元の透明度に関係なく、Decal は完全に見えなくなります。0に設定されると、デカールのレンダリング透明度は Decal.Transparency 値に一致します。これの式は:


Displayed Transparency = Transparency + ((1 - Transparency) * LocalTransparencyModifier)

注: このプロパティは、クライアント側でのみ使用し、サーバーには複製しないでください。

このプロパティのバリアントで BaseParts 、見るには BasePart.LocalTransparencyModifier

Texture

ContentId
並列読み取り

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

デカールをアップロードする方法は?

画像はコミュニティガイドラインに従う限り、Roblox にアップロードできます。画像のアップロード方法に関する情報は、テクスチャとデカール を参照してください。

デカールのコンテンツIDを見つける方法は?

Sound および Animation オブジェクトとは異なり、デカールのコンテンツIDは URL の番号と同じではありません。デカルのコンテンツ ID を見つける主な方法は 2つあります:

  • Roblox Studio のテクスチャプロパティに URLを貼り付けます。Roblox は、プロパティを正しいコンテンツ ID に自動的に更新します。注: これは Roblox Studio でのみ機能し、スクリプトから、またはゲームが実行中に行うことはできません。
  • デカールをゲームに挿入する、これは一般的に「マイデカル」の下のツールボックスで行われます。コンテンツ ID は、挿入されたデカルに見つけることができます。注意, InsertService:LoadAsset() 開発者がこのメソッドを自動化したい場合は, も使用できます。

コードサンプル

The following code will create a Part on the ground with a Decal applied to its top face. When something hits the part, such as when a player walks over it, the texture applied to the decal will change and a sound will play.

Changing Decal Texture

-- create part
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")
-- create decal
local decal = Instance.new("Decal")
decal.Face = Enum.NormalId.Top
decal.Parent = part
-- create sound
local sound = Instance.new("Sound")
sound.SoundId = "rbxasset://sounds/uuhhh.mp3" -- oof
sound.Parent = part
-- define faces
local happyFace = "http://www.roblox.com/asset/?id=26424652"
local sadFace = "http://www.roblox.com/asset/?id=147144198"
decal.Texture = happyFace
-- touched event
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)
-- add to workspace
part.Parent = workspace

TextureContent

並列読み取り

Transparency

並列読み取り

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

注意, Decals も Roblox(ロブロックス)blox にアップロードされたオリジナル画像ファイルの透明性を尊重します。これは、Roblox にアップロードする前に透明度を変更でき、透明度プロパティを使用する必要はありませんということです。

Decal.LocalTransparencyModifier はデカルの透明度の乗数として機能し、プレイヤーキャラクターの場合と同様、デカルの透明度が他のスクリプトによって変更される可能性があるときに使用する必要があります。

For BaseParts 、 see BasePart.Transparency

コードサンプル

The code below will create a transparent Part with a decal that will fade in and out using TweenService and Decal.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

並列読み取り

ZIndex は、同じ のデカルの順序を決定します。デカルは、 上位優先順位の秩序でレンダリングされ、最初に低い値がレンダリングされます したがって、ZIndex が高いデカールは、後で (そして上に) 低い ZIndex のデカールをレンダリングします。

有効な値の範囲は -MAX_INT から MAX_INT、含む (2,147,483,647 または (2^31 - 1)) です。将来、既存のデカルの間にデカルをレイヤーする必要があるかどうか不明な場合は、100 の倍数を使用するといいでしょう、つまり0, 100, 200.これにより、他の要素でレンダリングされた要素の間に使用できる ZIndex 値の大きなギャップが保たれます。

参照してください:

  • GuiObject.ZIndex , 同様の動作をするプロパティですが、GUI 要素用

方法

イベント