Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b3db4f5
CMCL-667: Show calculated confiner for not live vcams. (#365)
gaborkb Dec 7, 2021
9728819
CMCL-661: remove illegal destructor (#364)
glabute Dec 7, 2021
5666cb4
CMCL-686: targets forget that they are groups (#366)
glabute Dec 8, 2021
50caacd
CMCL-648: backport (#372)
gaborkb Dec 9, 2021
a09e2ce
CMCL-706: Fix for InputProvider causes tiny GC alloc every frame (#369)
gaborkb Dec 9, 2021
ace2c9b
bumped package version to 2.8.4
Dec 9, 2021
e0312ee
CMCL-710: 3rd person gimbal lock fix (#370)
glabute Dec 9, 2021
8eb17a2
Update CHANGELOG.md
gaborkb Dec 10, 2021
89d77a8
Fixed missing changelog entry.
gaborkb Dec 10, 2021
ea6ba3a
CMCL-622
gaborkb Dec 16, 2021
fbae1f6
Backport: Bugfix: memory leak with PostProcessing if no PP layer is p…
glabute Feb 2, 2022
d577bd1
Backport: Bugfix: Cinemachine does not produce compiler error in unit…
gaborkb Feb 2, 2022
1fe9b7f
Backport: Bugfix: Standalone profiler no longer crashed with CM.
gaborkb Jan 28, 2022
cc41cb0
Merge branch 'release/2.8' into 2.8.5/release-prep
gaborkb Feb 2, 2022
41f6aea
backport: CMCL-779
gaborkb Feb 2, 2022
9a87220
Merge branch '2.8.5/release-prep' of https://github.com/Unity-Technol…
gaborkb Feb 2, 2022
9d95795
Fix part 2. Legacy type was not displayed when part of an array
gaborkb Feb 3, 2022
5d37032
CMCL-783: Timeline guard (#398)
gaborkb Feb 7, 2022
55b5819
Package version bump
gaborkb Feb 7, 2022
f95e291
Changelog release date
gaborkb Feb 7, 2022
ae38f42
Changelog fixes
gaborkb Feb 7, 2022
3f1e621
version in core
gaborkb Feb 9, 2022
c7afd52
Moved changelog line
gaborkb Feb 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.8.5] - 2022-02-15
- Bugfix: A memory leak no longer occurs with PostProcessing if no PP layer is present on the camera.
- Bugfix: Cinemachine no longer produces a compiler error in Unity Editor versions older than 2020 when an Input System package is installed.
- Bugfix: Standalone profiler no longer crashes with CM.
- Bugfix: EmbeddedAssetProperties were not displayed correctly in the editor.
- Timeline guards added to scripts that rely on it.
- Regression fix: Axis input was ignoring CM's IgnoreTimeScale setting.


## [2.8.4] - 2021-12-10
- Regression fix: virtual cameras no longer forget that they are targeting groups on domain reload.
- Bugfix: 3rdPersonFollow logged console messages when looking straight up or down.
Expand Down
7 changes: 4 additions & 3 deletions Editor/Helpers/CinemachineTriggerActionEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ bool DrawActionSettings(SerializedProperty property, bool expanded)
if (isBoost)
EditorGUILayout.PropertyField(property.FindPropertyRelative(() => def.m_BoostAmount));

#if CINEMACHINE_TIMELINE
bool isPlay = actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Play;
if (isPlay)
{
Expand All @@ -97,7 +98,7 @@ bool DrawActionSettings(SerializedProperty property, bool expanded)
InspectorUtility.MultiPropertyOnLine(
EditorGUILayout.GetControlRect(), null, props, sublabels);
}

#endif
if (actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Custom)
{
EditorGUILayout.HelpBox("Use the Event() list below to call custom methods", MessageType.Info);
Expand All @@ -117,7 +118,7 @@ bool DrawActionSettings(SerializedProperty property, bool expanded)
if (value != null && (value as Behaviour) == null)
EditorGUILayout.HelpBox("Target must be a Behaviour in order to Enable/Disable", MessageType.Warning);
}

#if CINEMACHINE_TIMELINE
bool isPlayStop = isPlay
|| actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Stop;
if (isPlayStop)
Expand All @@ -128,7 +129,7 @@ bool DrawActionSettings(SerializedProperty property, bool expanded)
EditorGUILayout.HelpBox("Target must have a PlayableDirector or Animator in order to Play/Stop", MessageType.Warning);
}
}

#endif
if (!isCustom && targetProp.objectReferenceValue == null)
EditorGUILayout.HelpBox("No action will be taken because target is not valid", MessageType.Info);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ float LegacyModeGetPropertyHeight(SerializedProperty prop, GUIContent label)
prop.NextVisible(true); // Skip outer foldout
do
{
if (!prop.propertyPath.StartsWith(prefix))
if (!prop.propertyPath.Contains(prefix)) // if it is part of an array, then it won't StartWith prefix
break;
string header = HeaderText(prop);
if (header != null)
Expand Down Expand Up @@ -327,7 +327,7 @@ void LegacyModeOnGUI(Rect rect, SerializedProperty prop, GUIContent label)
prop.NextVisible(true); // Skip outer foldout
do
{
if (!prop.propertyPath.StartsWith(prefix))
if (!prop.propertyPath.Contains(prefix)) // if it is part of an array, then it won't StartWith prefix
break;
string header = HeaderText(prop);
if (header != null)
Expand Down
8 changes: 6 additions & 2 deletions Editor/PropertyDrawers/EmbeddedAssetPropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ Type EmbeddedAssetType(SerializedProperty property)
Type type = property.serializedObject.targetObject.GetType();
var a = property.propertyPath.Split('.');
for (int i = 0; i < a.Length; ++i)
type = type.GetField(a[i],
{
var field = type.GetField(a[i],
System.Reflection.BindingFlags.Public
| System.Reflection.BindingFlags.NonPublic
| System.Reflection.BindingFlags.Instance).FieldType;
| System.Reflection.BindingFlags.Instance);
if (field == null) continue;
type = field.FieldType;
}
return type;
}

Expand Down
6 changes: 6 additions & 0 deletions Editor/Windows/CinemachineSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,15 @@ internal static Texture2D CinemachineHeader
/// after adding a virtual camera to the project for the first time
static void OnPackageLoadedInEditor()
{
#if UNITY_2020_3_OR_NEWER
// Nothing to load in the context of a secondary process.
if ((int)UnityEditor.MPE.ProcessService.level == 2 /*UnityEditor.MPE.ProcessLevel.Secondary*/)
return;
#endif
if (CinemachineLogoTexture == null)
{
// After adding the CM to a project, we need to wait for one update cycle for the assets to load
EditorApplication.update -= OnPackageLoadedInEditor;
EditorApplication.update += OnPackageLoadedInEditor;
}
else
Expand Down
10 changes: 5 additions & 5 deletions Runtime/Core/AxisState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ public void SetInputAxisProvider(int axis, IInputAxisProvider provider)
public bool HasInputProvider { get => m_InputAxisProvider != null; }

/// <summary>
/// Updates the state of this axis based on the axis defined
/// Updates the state of this axis based on the Input axis defined
/// by AxisState.m_AxisName
/// </summary>
/// <param name="deltaTime">Delta time in seconds</param>
/// <returns>Returns <b>true</b> if this axis' input was non-zero this Update,
/// <returns>Returns <b>true</b> if this axis's input was non-zero this Update,
/// <b>false</b> otherwise</returns>
public bool Update(float deltaTime)
{
Expand All @@ -213,9 +213,9 @@ public bool Update(float deltaTime)
// Cheating: we want the render frame time, not the fixed frame time
if (CinemachineCore.UniformDeltaTimeOverride >= 0)
deltaTime = CinemachineCore.UniformDeltaTimeOverride;
else if (deltaTime >= 0 && m_LastUpdateTime != 0)
deltaTime = Time.time - m_LastUpdateTime;
m_LastUpdateTime = Time.time;
else if (Time.inFixedTimeStep && deltaTime >= 0 && m_LastUpdateTime != 0)
deltaTime = Time.realtimeSinceStartup - m_LastUpdateTime;
m_LastUpdateTime = Time.realtimeSinceStartup;

if (m_InputAxisProvider != null)
m_InputAxisValue = m_InputAxisProvider.GetAxisValue(m_InputAxisIndex);
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Core/CinemachineCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public sealed class CinemachineCore
public static readonly int kStreamingVersion = 20170927;

/// <summary>Human-readable Cinemachine Version</summary>
public static readonly string kVersionString = "2.8.4";
public static readonly string kVersionString = "2.8.5";

/// <summary>
/// Stages in the Cinemachine Component pipeline, used for
Expand Down
7 changes: 4 additions & 3 deletions Runtime/Helpers/CinemachineInputProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ protected InputAction ResolveForPlayer(int axis, InputActionReference actionRef)
m_cachedActions[axis].Enable();

return m_cachedActions[axis];
// local static function to wrap the lambda which otherwise causes a tiny gc
static InputAction GetFirstMatch(in InputUser user, InputActionReference actionRef) =>
user.actions.First(x => x.id == actionRef.action.id);

// local function to wrap the lambda which otherwise causes a tiny gc
InputAction GetFirstMatch(in InputUser user, InputActionReference aRef) =>
user.actions.First(x => x.id == aRef.action.id);
}

// Clean up
Expand Down
4 changes: 4 additions & 0 deletions Runtime/Helpers/CinemachineTriggerAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ public enum Mode
Enable,
/// <summary>Disable a component</summary>
Disable,
#if CINEMACHINE_TIMELINE
/// <summary>Start animation on target</summary>
Play,
/// <summary>Stop animation on target</summary>
Stop
#endif
}

/// <summary>Serializable parameterless game event</summary>
Expand Down Expand Up @@ -184,6 +186,7 @@ CinemachineVirtualCameraBase vcam
targetBehaviour.enabled = false;
break;
}
#if CINEMACHINE_TIMELINE
case Mode.Play:
{
PlayableDirector playable
Expand Down Expand Up @@ -234,6 +237,7 @@ PlayableDirector playable
}
break;
}
#endif
}
}
m_Event.Invoke();
Expand Down
49 changes: 36 additions & 13 deletions Runtime/PostProcessing/CinemachinePostProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,31 +318,47 @@ static PostProcessLayer GetPPLayer(CinemachineBrain brain)
if (layer != null)
return layer; // layer is valid and in our lookup

if (found)
// If the layer in the lookup table is a deleted object, we must remove
// the brain's callback for it
if (found && !ReferenceEquals(layer, null))
{
// layer is a deleted object
brain.m_CameraCutEvent.RemoveListener(OnCameraCut);
mBrainToLayer.Remove(brain);
layer = null;
found = false;
}
// Brain is not in our lookup - add it

// Brain is not in our lookup - add it.
#if UNITY_2019_2_OR_NEWER
brain.TryGetComponent(out layer);
#else
layer = brain.GetComponent<PostProcessLayer>();
#endif
if (layer != null)
{
brain.m_CameraCutEvent.AddListener(OnCameraCut); // valid layer
#if UNITY_EDITOR
// Never add null in edit mode in case user adds a layer dynamically
if (Application.isPlaying || layer != null)
#endif
mBrainToLayer[brain] = layer;
}
#else
// In order to avoid calling GetComponent() every frame in the case
// where there is legitimately no layer on the brain, we will add
// null to the lookup table if no layer is present.
if (!found)
{
layer = brain.GetComponent<PostProcessLayer>();
if (layer != null)
brain.m_CameraCutEvent.AddListener(OnCameraCut); // valid layer

// Exception: never add null in the case where user adds a layer while
// in the editor. If we were to add null in this case, then the new
// layer would not be detected. We are willing to live with
// calling GetComponent() every frame while in edit mode.
if (Application.isPlaying || layer != null)
mBrainToLayer[brain] = layer;
}
#endif
return layer;
}

static void OnSceneUnloaded(Scene scene)
static void CleanupLookupTable()
{
var iter = mBrainToLayer.GetEnumerator();
while (iter.MoveNext())
Expand All @@ -356,17 +372,24 @@ static void OnSceneUnloaded(Scene scene)

#if UNITY_EDITOR
[UnityEditor.InitializeOnLoad]
class EditorInitialize { static EditorInitialize() { InitializeModule(); } }
class EditorInitialize
{
static EditorInitialize()
{
UnityEditor.EditorApplication.playModeStateChanged += (pmsc) => CleanupLookupTable();
InitializeModule();
}
}
#endif
[RuntimeInitializeOnLoadMethod]
static void InitializeModule()
{
// Afetr the brain pushes the state to the camera, hook in to the PostFX
// After the brain pushes the state to the camera, hook in to the PostFX
CinemachineCore.CameraUpdatedEvent.RemoveListener(ApplyPostFX);
CinemachineCore.CameraUpdatedEvent.AddListener(ApplyPostFX);

// Clean up our resources
SceneManager.sceneUnloaded += OnSceneUnloaded;
SceneManager.sceneUnloaded += (scene) => CleanupLookupTable();
}
}
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
using UnityEngine;
#if CINEMACHINE_TIMELINE
using UnityEngine;
using UnityEngine.Playables;

namespace Cinemachine.Examples
{

public class GenericTrigger : MonoBehaviour
{
public PlayableDirector timeline;

// Use this for initialization
void Start()
public class GenericTrigger : MonoBehaviour
{
timeline = GetComponent<PlayableDirector>();
}
public PlayableDirector timeline;

// Use this for initialization
void Start()
{
timeline = GetComponent<PlayableDirector>();
}

void OnTriggerExit(Collider c)
{
if (c.gameObject.CompareTag("Player"))
void OnTriggerExit(Collider c)
{
// Jump to the end of the timeline where the blend happens
// This value (in seconds) needs to be adjusted as needed if the timeline is modified
timeline.time = 27;
if (c.gameObject.CompareTag("Player"))
{
// Jump to the end of the timeline where the blend happens
// This value (in seconds) needs to be adjusted as needed if the timeline is modified
timeline.time = 27;
}
}
}

void OnTriggerEnter(Collider c)
{
if (c.gameObject.CompareTag("Player"))
void OnTriggerEnter(Collider c)
{
timeline.Stop(); // Make sure the timeline is stopped before starting it
timeline.Play();
if (c.gameObject.CompareTag("Player"))
{
timeline.Stop(); // Make sure the timeline is stopped before starting it
timeline.Play();
}
}
}
}

}
#endif
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.unity.cinemachine",
"displayName": "Cinemachine",
"version": "2.8.4",
"version": "2.8.5",
"unity": "2019.4",
"description": "Smart camera tools for passionate creators. \n\nNew starting from 2.7.1: Are you looking for the Cinemachine menu? It has moved to the GameObject menu.\n\nIMPORTANT NOTE: If you are upgrading from the legacy Asset Store version of Cinemachine, delete the Cinemachine asset from your project BEFORE installing this version from the Package Manager.",
"keywords": [ "camera", "follow", "rig", "fps", "cinematography", "aim", "orbit", "cutscene", "cinematic", "collision", "freelook", "cinemachine", "compose", "composition", "dolly", "track", "clearshot", "noise", "framing", "handheld", "lens", "impulse" ],
Expand Down