浏览代码

Merge branch 'feature-ME/dolly' of https://github.com/Unity-Technologies/FontainebleauDemo into feature-ME/dolly

/cinematic-demo-ME
Adam-Myhill 5 年前
当前提交
cb55748f
共有 4 个文件被更改,包括 60 次插入137 次删除
  1. 54
      Assets/Scenes/Demo/Demo.unity
  2. 36
      Assets/ClusterDisplay/Scripts/DollyController.cs
  3. 107
      Assets/ClusterDisplay/Scripts/DollyCameraController.cs
  4. 0
      /Assets/ClusterDisplay/Scripts/DollyController.cs.meta

54
Assets/Scenes/Demo/Demo.unity


m_Component:
- component: {fileID: 1367818372}
- component: {fileID: 1367818373}
- component: {fileID: 1367818374}
- component: {fileID: 1367818375}
m_Layer: 0
m_Name: CM dolly cam

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1367818371}
m_LocalRotation: {x: 0.011873469, y: 0.55416125, z: -0.007905705, w: 0.83228713}
m_LocalPosition: {x: -11.946312, y: -3.0700922, z: -48.594177}
m_LocalRotation: {x: -0.018706951, y: 0.7540966, z: 0.021499597, w: 0.65614486}
m_LocalPosition: {x: -30.837025, y: -3.3809624, z: -53.206177}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 979275772}

m_Calls: []
m_LegacyBlendHint: 0
m_ComponentOwner: {fileID: 979275772}
--- !u!114 &1367818374
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1367818371}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1a49aa03c779a7b4e992c853226ec40e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Paths:
- {fileID: 1413143612}
- {fileID: 1415043723}
- {fileID: 264422019}
m_MaxSpeed: 1
m_MinSpeed: 0
m_DefaultSpeed: 0.5
m_SpeedDeltaPerFrame: 0.01
m_ShowGUI: 0
--- !u!95 &1367818375
Animator:
serializedVersion: 3

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1367818371}
m_Enabled: 1
m_Enabled: 0
m_Avatar: {fileID: 0}
m_Controller: {fileID: 0}
m_CullingMode: 0

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1957780952}
m_LocalRotation: {x: 0, y: 0.87928015, z: 0, w: 0.83228713}
m_LocalRotation: {x: 0, y: 0.7262475, z: 0, w: 0.6874333}
m_LocalPosition: {x: -23.117512, y: 8.381705, z: -35.445152}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []

serializedVersion: 6
m_Component:
- component: {fileID: 1963778101}
- component: {fileID: 1963778099}
- component: {fileID: 1963778099}
- component: {fileID: 1963778102}
m_Layer: 0
m_Name: DollyCart1
m_TagString: Untagged

m_Path: {fileID: 1413143612}
m_UpdateMethod: 0
m_PositionUnits: 1
m_Speed: 0
m_Speed: 0.5
m_Position: 268.84
--- !u!4 &1963778101
Transform:

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1963778098}
m_LocalRotation: {x: 0.020274084, y: 0.52791363, z: -0.012607113, w: 0.8489624}
m_LocalPosition: {x: -11.946312, y: -3.0700922, z: -48.594177}
m_LocalRotation: {x: -0.018706951, y: 0.7540966, z: 0.021499597, w: 0.65614486}
m_LocalPosition: {x: -30.837025, y: -3.3809624, z: -53.206177}
--- !u!114 &1963778102
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1963778098}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1a49aa03c779a7b4e992c853226ec40e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_MaxSpeed: 2
m_MinSpeed: 0
m_SpeedDeltaPerFrame: 0.01
--- !u!1 &2007101360
GameObject:
m_ObjectHideFlags: 0

36
Assets/ClusterDisplay/Scripts/DollyController.cs


using System;
using Cinemachine;
using UnityEngine;
[RequireComponent(typeof(CinemachineDollyCart))]
public class DollyController : MonoBehaviour
{
[SerializeField]
float m_MaxSpeed;
[SerializeField]
float m_MinSpeed;
[SerializeField]
float m_SpeedDeltaPerFrame;
CinemachineDollyCart m_TrackedDolly;
void OnEnable()
{
m_TrackedDolly = GetComponent<CinemachineDollyCart>();
m_TrackedDolly.m_Position = 0;
m_TrackedDolly.m_Speed = Mathf.Clamp(m_TrackedDolly.m_Speed, m_MinSpeed, m_MaxSpeed);
}
void Update()
{
var delta = 0;
if (Input.GetKey(KeyCode.DownArrow))
delta = -1;
else if (Input.GetKey(KeyCode.UpArrow))
delta = 1;
m_TrackedDolly.m_Speed = Mathf.Clamp(m_TrackedDolly.m_Speed + delta * m_SpeedDeltaPerFrame, m_MinSpeed, m_MaxSpeed);
}
}

107
Assets/ClusterDisplay/Scripts/DollyCameraController.cs


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;
}
}

/Assets/ClusterDisplay/Scripts/DollyCameraController.cs.meta → /Assets/ClusterDisplay/Scripts/DollyController.cs.meta

正在加载...
取消
保存