單個 CFrame 值的容器對象。
範例程式碼
This code sample creates a CFrameValue whose Value is set to the camera's current CFrame. This CFrame can be later recalled back into the camera's CFrame.
Store the Camera's CFrame
-- Create a CFrame that stores the camera's current position/orientation
local vSnapshot = Instance.new("CFrameValue")
vSnapshot.Value = workspace.CurrentCamera.CFrame
vSnapshot.Name = "Snapshot"
vSnapshot.Parent = workspace
-- Later, we can load the CFrame back into the camera
workspace.CurrentCamera.CFrame = vSnapshot.Value
概要
活動
每當 CFrameValue 的 CFrameValue.Value 被更改時,都會發射。
屬性
方法
活動
Changed
每當 CFrameValue.Value 的 CFrameValue 被更改時,都會發射。它將使用新值存儲在參數對物件中,而不是代表正在變更的屬性的字串。
這個事件,像其他已變更的事件一樣,可以用來跟蹤 CFrameValue 何時發生變更,以及它可能變更的不同值。
例個體、實例,這甚至可能在使用 CFrameValues 來跟蹤遊戲物件 CFrame 位置和運動的遊戲中有用。
相同類型的變更事件存在於類似物件,例如 NumberValue 和 StringValue,取決於哪種物件類型最適合需求。
參數
變更後的新值。
範例程式碼
This example prints the CFrameValue's new value each time it changes.
CFrameValue.Changed
local cframeValue = script.Parent.CFrameValue
cframeValue.Changed:Connect(print)
cframeValue.Value = CFrame.new(1, 2, 3)