etienne cella
5 年前
当前提交
e6c92fb5
共有 6 个文件被更改,包括 214 次插入 和 900 次删除
-
974Assets/Scenes/Demo/Demo.unity
-
107Assets/ClusterDisplay/Scripts/DollyCameraController.cs
-
11Assets/ClusterDisplay/Scripts/DollyCameraController.cs.meta
-
14Assets/ClusterDisplay/ResetVolumetricsSignal.signal
-
8Assets/ClusterDisplay/ResetVolumetricsSignal.signal.meta
974
Assets/Scenes/Demo/Demo.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using System; |
|||
using Cinemachine; |
|||
using UnityEngine; |
|||
|
|||
[RequireComponent(typeof(CinemachineVirtualCamera))] |
|||
public class DollyCameraController : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
CinemachineSmoothPath[] m_Paths; |
|||
|
|||
[SerializeField] |
|||
float m_MaxSpeed; |
|||
|
|||
[SerializeField] |
|||
float m_MinSpeed; |
|||
|
|||
[SerializeField] |
|||
float m_DefaultSpeed; |
|||
|
|||
[SerializeField] |
|||
float m_SpeedDeltaPerFrame; |
|||
|
|||
int m_CurrentPathIndex; |
|||
float m_CurrentSpeed; |
|||
float m_CurrentPathMinPos; |
|||
float m_CurrentPathMaxPos; |
|||
bool m_CurrentPathIsLooped; |
|||
CinemachineVirtualCamera m_VCamera; |
|||
CinemachineTrackedDolly m_TrackedDolly; |
|||
|
|||
[SerializeField] |
|||
bool m_ShowGUI; |
|||
|
|||
// Will be removed.
|
|||
void OnGUI() |
|||
{ |
|||
if (!m_ShowGUI) |
|||
return; |
|||
|
|||
GUILayout.Label($"PathIndex [{m_CurrentPathIndex}]"); |
|||
GUILayout.Label($"PathMinPos [{m_CurrentPathMinPos}]"); |
|||
GUILayout.Label($"PathMaxPos [{m_CurrentPathMaxPos}]"); |
|||
GUILayout.Label($"PathIsLooped [{m_CurrentPathIsLooped}]"); |
|||
GUILayout.Label($"Speed [{m_CurrentSpeed}]"); |
|||
GUILayout.Label($"Position [{m_TrackedDolly.m_PathPosition}]"); |
|||
} |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_CurrentSpeed = m_DefaultSpeed; |
|||
m_VCamera = GetComponent<CinemachineVirtualCamera>(); |
|||
m_TrackedDolly = m_VCamera.GetCinemachineComponent<CinemachineTrackedDolly>(); |
|||
Reset(); |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
{ // Select Dolly track.
|
|||
var index = -1; |
|||
if (Input.GetKeyDown(KeyCode.Alpha1)) |
|||
index = 0; |
|||
else if (Input.GetKeyDown(KeyCode.Alpha2)) |
|||
index = 1; |
|||
else if (Input.GetKeyDown(KeyCode.Alpha3)) |
|||
index = 2; |
|||
|
|||
if (index != -1) |
|||
SetPath(index); |
|||
} |
|||
{ // Update Camera Speed.
|
|||
var delta = 0; |
|||
if (Input.GetKey(KeyCode.DownArrow)) |
|||
delta = -1; |
|||
else if (Input.GetKey(KeyCode.UpArrow)) |
|||
delta = 1; |
|||
|
|||
m_CurrentSpeed = Mathf.Clamp(m_CurrentSpeed + delta * m_SpeedDeltaPerFrame, m_MinSpeed, m_MaxSpeed); |
|||
} |
|||
{ // Move along path (we assume the camera may only move forward)
|
|||
var pos = m_TrackedDolly.m_PathPosition + m_CurrentSpeed * Time.deltaTime; |
|||
if (pos > m_CurrentPathMaxPos) |
|||
{ |
|||
// Switch to next path if the current one does not loop.
|
|||
if (!m_CurrentPathIsLooped) |
|||
SetPath((m_CurrentPathIndex + 1) % m_Paths.Length); |
|||
pos = m_CurrentPathMinPos; |
|||
} |
|||
m_TrackedDolly.m_PathPosition = pos; |
|||
} |
|||
} |
|||
|
|||
void SetPath(int index) |
|||
{ |
|||
m_CurrentPathIndex = index; |
|||
var path = m_Paths[index]; |
|||
m_TrackedDolly.m_Path = path; |
|||
m_CurrentPathMinPos = path.MinPos; |
|||
m_CurrentPathMaxPos = path.MaxPos; |
|||
m_CurrentPathIsLooped = path.Looped; |
|||
} |
|||
|
|||
public void Reset() |
|||
{ |
|||
SetPath(0); |
|||
m_TrackedDolly.m_PathPosition = m_CurrentPathMinPos; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1a49aa03c779a7b4e992c853226ec40e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d6fa2d92fc1b3f34da284357edf89c3b, type: 3} |
|||
m_Name: ResetVolumetricsSignal |
|||
m_EditorClassIdentifier: |
|
|||
fileFormatVersion: 2 |
|||
guid: e47d7a3303764d94e9bf428801439ceb |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue