一个容器对象为单个 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,根据需求选择最适合的对象类型。
参数
更改后的新值。
代码示例
这个例子每次更改时打印 CFrameValue 的新值。
CFRameValue.Changed
local cframeValue = script.Parent.CFrameValue
cframeValue.Changed:Connect(print)
cframeValue.Value = CFrame.new(1, 2, 3)