Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Bugfix: Standalone profiler no longer crashed with CM.
- Bugfix: Cinemachine does not produce compiler error in unity editor versions older than 2020, when Input System package is installed.
- Bugfix: EmbeddedAssetProperties were not displayed correctly in the editor.
- Timeline guards added to scripts that rely on it.

## [2.9.0-pre.6] - 2022-01-12
- Bugfix: Negative Near Clip Plane value is kept when camera is orthographic.
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
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
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