Skip to content

Commit

Permalink
Merge branch 'main' into dev/input-asset-clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
glabute authored Jan 17, 2025
2 parents 7c1890f + dc13859 commit fdb29a1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 78 deletions.
2 changes: 1 addition & 1 deletion com.unity.cinemachine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- CameraActivated events were not sent consistently when activation was due to timeline blends.
- Bugfix: FramingTransposer with a dead zone would sometimes drift.
- Fixed the Radial Axis input axis in the CinemachineOrbitalFollow component to map to the y axis.
- The Deoccluder failed to reset its state when initially enabled.
- The Deoccluder failed to reset its state when initially enabled, and sometimes caused small spurious camera rotations.

### Changed
- Added delayed processing to near and far clip plane inspector fields for the CinemachineCamera lens.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,76 +223,6 @@ static CreatePipelineWithUndo()
};
}
}

// Because the cinemachine components are attached to hidden objects, their
// gizmos don't get drawn by default. We have to do it explicitly.
[InitializeOnLoad]
static class CollectGizmoDrawers
{
static CollectGizmoDrawers()
{
m_GizmoDrawers = new Dictionary<Type, MethodInfo>();
string definedIn = typeof(CinemachineComponentBase).Assembly.GetName().Name;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
// Note that we have to call GetName().Name. Just GetName() will not work.
if ((!assembly.GlobalAssemblyCache)
&& ((assembly.GetName().Name == definedIn)
|| assembly.GetReferencedAssemblies().Any(a => a.Name == definedIn)))
{
try
{
foreach (var type in assembly.GetTypes())
{
try
{
bool added = false;
foreach (var method in type.GetMethods(
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static))
{
if (added)
break;
if (!method.IsStatic)
continue;
var attributes = method.GetCustomAttributes(typeof(DrawGizmo), true) as DrawGizmo[];
foreach (var a in attributes)
{
if (typeof(CinemachineComponentBase).IsAssignableFrom(a.drawnType) && !a.drawnType.IsAbstract)
{
m_GizmoDrawers.Add(a.drawnType, method);
added = true;
break;
}
}
}
}
catch (Exception) {} // Just skip uncooperative types
}
}
catch (Exception) {} // Just skip uncooperative assemblies
}
}
}
public static Dictionary<Type, MethodInfo> m_GizmoDrawers;
}

[DrawGizmo(GizmoType.Active | GizmoType.InSelectionHierarchy, typeof(CinemachineVirtualCamera))]
static void DrawVirtualCameraGizmos(CinemachineVirtualCamera vcam, GizmoType selectionType)
{
var pipeline = vcam.GetComponentPipeline();
if (pipeline != null)
{
foreach (var c in pipeline)
{
if (c != null && CollectGizmoDrawers.m_GizmoDrawers.TryGetValue(c.GetType(), out var method))
{
if (method != null)
method.Invoke(null, new object[] {c, selectionType});
}
}
}
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,13 @@ public override void OnGUI(Rect rect, SerializedProperty property, GUIContent la
}
}
}

partial class OutputChannelsPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
{
EditorGUI.PropertyField(rect, property, label);
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Unity.Cinemachine.Editor
{
[CustomPropertyDrawer(typeof(OutputChannels))]
class OutputChannelsPropertyDrawer : PropertyDrawer
partial class OutputChannelsPropertyDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,11 @@ protected override void PostPipelineStageCallback(
newCamPos = state.GetCorrectedPosition();

// Adjust the damping bypass to account for the displacement
if (hasLookAt)
if (hasLookAt && displacement.sqrMagnitude > Epsilon)
{
// Restore the lookAt offset
if (displacement.sqrMagnitude > Epsilon)
{
var q = Quaternion.LookRotation(lookAtPoint - newCamPos, up);
state.RawOrientation = q.ApplyCameraRotation(-lookAtScreenOffset, up);
}
var q = Quaternion.LookRotation(lookAtPoint - newCamPos, up);
state.RawOrientation = q.ApplyCameraRotation(-lookAtScreenOffset, up);
if (vcam.PreviousStateIsValid && extra.StateIsValid)
{
var dir0 = extra.PreviousCameraPosition - lookAtPoint;
Expand Down

0 comments on commit fdb29a1

Please sign in to comment.