プレイヤーは、自分がいるスペースの構築に参加しているような感覚を楽しむことがよくあります。 SurfaceArt 開発者モジュールでは、プレイヤーがバーチャル空間内に文字通り爪あとを残すことができます。
モジュールの使用法
インストール
バーチャル空間内でSurfaceArtモジュールを使用するには、次の手順に従います。
表示タブから、ツールボックスを開き、マーケットプレイスタブを選択します。
モデルのソートが選択されていることを確認し、カテゴリのすべてのボタンを表示をクリックします。
DEV モジュールタイルを見つけてクリックします。
Surface Artモジュールを見つけてクリックするか、3D ビューにドラッグ&ドロップします。
エクスプローラウィンドウで、SurfaceArtモデル全体をServerScriptServiceに移動します。 バーチャル空間を実行すると、モジュールはそれ自体をさまざまなサービスに配布し、実行を開始します。
キャンバスの配置
モジュールには、3D ワールドに配置できるSurfaceCanvasモデルが付属しています。 このモデルは、プレイヤーが表面にアートをプレースするために対話するものです。
モジュールのメインフォルダのワークスペースフォルダにSurfaceCanvasメッシュを見つけます。
それを最上位レベルのワークスペース階層に移動し、必要な場所に配置します。
テストセッションを公開/実行すると、プレイヤーは、ProximityPromptを介してオブジェクトを操作し、定義された表面にアートをプレースできるようになります。
キャンバス面の変更
フードの下で、モジュールは、SurfaceGuiを使用して、アートアイテムを表示します。 アートが表示される面を設定するには、次の手順に従います。
SurfaceCanvasメッシュを選択します。
プロパティウィンドウの下で、デフォルト値右を持つSurfaceCanvasFace属性を見つけます。
属性をクリックし、Enum.NormalIdを説明する 6 つの値のいずれかを入力します。
属性の値 | 対応するノーマルID |
---|---|
フロント | Enum.NormalId.Front |
戻る | Enum.NormalId.Back |
右 | Enum.NormalId.Right |
左 | Enum.NormalId.Left |
トップ | Enum.NormalId.Top |
下 | Enum.NormalId.Bottom |
カスタムアートアセットの使用
バーチャル空間のテーマにより適合させるために、デフォルトの代わりに独自のカスタムアセットセットを使用できます。 これは、ServerScriptServiceScriptから呼び出される設定関数を介して行うことができます。
Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))local customAssets = {CustomAsset1 = {name = "Custom Asset 1",assetId = "rbxassetid://7322508294",},CustomAsset2 = {name = "Custom Asset 2",assetId = "rbxassetid://7322547665",},}SurfaceArt.configure({assets = customAssets,})
すべてのキャンバスの消去
ワールドのすべてのキャンバスからすべての既存のアートを削除するには、からremoveAllArt関数を呼び出しますScript。
Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))SurfaceArt.removeAllArt()
カスタムエフェクトの表示
アートワークが配置されたときに、追加の視覚効果を含める場合があります。 このモジュールでは、クライアントでartChangedというイベントを公開し、接続して独自のロジックを追加できます。
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))
local function createParticleEmitter(canvas, position)
local attachment = Instance.new("Attachment")
attachment.Position = canvas.CFrame:PointToObjectSpace(position)
attachment.Axis = Vector3.new(0, 0, 1)
attachment.SecondaryAxis = Vector3.new(1, 0, 0)
attachment.Parent = canvas
local particleEmitter = Instance.new("ParticleEmitter")
particleEmitter.Speed = NumberRange.new(50)
particleEmitter.Rate = 50
particleEmitter.Color = ColorSequence.new(Color3.fromRGB(128, 254, 7))
particleEmitter.SpreadAngle = Vector2.new(35, 35)
particleEmitter.Parent = attachment
return attachment
end
SurfaceArt.artChanged:Connect(function(canvas, spot, spotPosition, artId, ownerId)
if artId then
-- Show some sparkles for 3 seconds
task.spawn(function()
local emitterAttachment = createParticleEmitter(canvas, spotPosition)
task.wait(3)
emitterAttachment:Destroy()
end)
end
end)
API リファレンス
種類
SurfaceArtAsset
キャンバスのアートとして使用する画像は、2 つの値を持つテーブルで表現されます。
キー | 概要 |
---|---|
name | メタデータ表示名。 |
assetId | 含める画像のアセットID。 |
関数
設定
configure(config:table):nil
デフォルト設定オプションは、configテーブル内の以下のキー/値を使用して上書きします。 この関数は、Scriptからのみ呼び出すことができます。
Script Editor
キー | 概要 | デフォルト |
---|---|---|
enabled | モジュールの機能をオンまたはオフに切り替えます。 | true |
assets | SurfaceArtAssetタイプのリスト。 | (コードを参照する) |
quotaPerPlayer | 各プレイヤーが配置できるアート作品の最大数。 | 2 |
Data
キー | 概要 | デフォルト |
---|---|---|
rowsPerCanvas | キャンバスグリッドの行数 | 2 |
colsPerCanvas | キャンバスグリッド内の列数。 | 5 |
itemsPerPage | 左右にページングするときにスキップするアイテム数。 | 3 |
canvasPaddingLeft | サーフェスキャンバスの左パディング(UDim)。 | (0, 8) |
canvasPaddingRight | サーフェスキャンバスの右パディング(UDim)。 | (0, 8) |
canvasPaddingTop | サーフェキャンバスのトップパディング(UDim)。 | (0, 8) |
canvasPaddingBottom | サーフェスキャンバスのパディング(UDim)。 | (0, 8) |
promptImage | アート選択ビューを入力するためディシジョンプロンプトに表示されるアイコン。 | "rbxassetid://8076723774" |
leftArrowPageImage | 前のページにフリップする左矢印の画像。 | "rbxassetid://6998633654" |
leftArrowItemImage | 前のアートアイテムを選択するための左矢印の画像。 | "rbxassetid://8072765021" |
rightArrowPageImage | 次のページにフリップする矢印の画像。 | "rbxassetid://6998635824" |
rightArrowItemImage | 次のアートアイテムを選択するための右矢印の画像。 | "rbxassetid://8072764852" |
インタラクション
キー | 概要 | デフォルト |
---|---|---|
promptKeyCode | アート選択を入力するためのプロンプトをアクティブ化するため使用するキーボードショートカット(Enum.KeyCode)。 | E |
promptRequiresLineOfSight | Proximityプロンプトがユーザーとキャンバスの間の視界に入っているか判断するブール値。 | true |
promptMaxActivationDistance | プロンプトが表示されるまでに、プレイヤーのキャラクターがキャンバスから離れることができる最大距離。 | 10 |
promptExclusivity | 同時に表示できるプロンプトを指定するEnum.ProximityPromptExclusivityです。 | OnePerButton |
usePageHotkeys | ページホットキーが使用されているかどうか。 trueの場合、nextPageKeyとprevPageKeyは、ページ間を循環させるために使用されます。 | true |
nextPageKey | アートワークの次のページに移動するために使用されるキー(Enum.KeyCode)。 | E |
nextItemKey | アートワークを次のアイテムに循環させるために使用されるキー(Enum.KeyCode)。 | Right |
prevPageKey | アートワークの前のページに移動するために使用されるキー(Enum.KeyCode)。 | Q |
prevItemKey | アートワークの前のアイテムにサイクルするために使用されるキー(Enum.KeyCode)。 | Left |
Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))SurfaceArt.configure({quotaPerPlayer = 4,promptKeyCode = Enum.KeyCode.T,promptMaxActivationDistance = 8,})
getCanvases
getCanvases():table
SurfaceCanvasタグでタグ付けされたすべてのキャンバスを返します。
Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))local canvases = SurfaceArt.getCanvases()
placeArt
placeArt(player:Player, canvas:BasePart):nil
プレイヤーに代わってアートピースをプログラム的に配置します。 サーバーが初期化されると、canvasオブジェクトは、サーバーが初期化されるとき、タSurfaceCanvasグでタグ付けされている必要がありますから、注意してください。 getCanvasesから返されるキャンバスでのみこれを使用することをお勧めします。
Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))
local remoteEvent = ReplicatedStorage:WaitForChild("SurfaceArtRemoteEvent")
remoteEvent.OnServerEvent:Connect(function(player)
-- Place the Bloxy Award from default art assets into the first canvas
local canvases = SurfaceArt.getCanvases()
SurfaceArt.placeArt(player, canvases[1], "BloxyAward")
end)
removeAllArt
removeAllArt():nil
すべてのサーフェスからすべてのアートワークを削除します。
Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))SurfaceArt.removeAllArt()
イベント
artChanged
artChanged(canvas:BasePart,spot:Frame, spotPosition:Vector3, artId:string, ownerUserId:number): RBXScriptSignal
キャンバス上の特定の場所でアートワークが変更されると発生します。 アートワークが削除されると、artIdはnilになります。 イベントハンドラへの第 3 パラメータとしてVector3値が移動されることに注意してください。 アートワークが配置される正確な位置カスタムエフェクトを位置ことができます。 このイベントは、LocalScript内でのみ接続できます
パラメータ | |
---|---|
キャンバス:BasePart | アートワークが変更されたキャンバス。 |
スポット:Frame | アートワーImageLabelクを含む内部Frame。 |
spotPosition:Vector3 | アートワークが配置さたれた正確な位置。 |
artId:string | 新しいアートワークのアセットID。 |
ownerUserId:number | アートを配置したプレイヤーのUserId |
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))
SurfaceArt.artChanged:Connect(function(canvas, spot, spotPosition, artId, ownerId)
print("Art placed at:", spotPosition)
print("Art asset ID:", artId)
print("Art placed by:", ownerId)
end)
promptShown
promptShown(canvas:BasePart): RBXScriptSignal
キャンバスインタラクションプロンプトがプレイヤーに対して表示されると発生します。 接続された関数は、プロンプトが表示されているキャンバスを受け取ります。 このイベントは、LocalScript内でのみ接続できます
パラメータ | |
---|---|
キャンバス:BasePart | プロンプトが表示されているキャンバス。 |
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))
SurfaceArt.promptShown:Connect(function(canvas)
print(Players.LocalPlayer, canvas)
end)
promptHidden
promptHidden(canvas:BasePart): RBXScriptSignal
キャンバスインタラクションプロンプトが非表示にとなると発生します。 接続された関数は、プロンプトが表示されているキャンバスを受け取りました。 このイベントは、LocalScript内でのみ接続できます
パラメータ | |
---|---|
キャンバス:BasePart | プロンプトが表示されているキャンバス。 |
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))
SurfaceArt.promptClosed:Connect(function(canvas)
print(Players.LocalPlayer, canvas)
end)
selectorShown
selectorShown(): RBXScriptSignal
サーフェスアートセレクター UI がプレイヤーに表示されると発生します。 このイベントは、LocalScript内でのみ接続できます
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))
SurfaceArt.selectorShown:Connect(function()
print(Players.LocalPlayer, "opened surface art selector")
end)
selectorHidden
selectorHidden(): RBXScriptSignal
サーフェスアートセレクター UI は、プレイヤーから非表示にします。 このイベントは、LocalScript内でのみ接続できます
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local SurfaceArt = require(ReplicatedStorage:WaitForChild("SurfaceArt"))
SurfaceArt.selectorHidden:Connect(function()
print(Players.LocalPlayer, "closed surface art selector")
end)