diff --git a/Runtime/PopupContentBuilder.cs b/Runtime/PopupContentBuilder.cs
index e70beae..fa9b625 100644
--- a/Runtime/PopupContentBuilder.cs
+++ b/Runtime/PopupContentBuilder.cs
@@ -10,7 +10,7 @@ namespace Jovian.PopupSystem {
/// or convenience methods for common types.
///
public readonly struct PopupContentBuilder {
- readonly PopupView view;
+ private readonly PopupView view;
///
/// Creates a builder targeting the given popup view.
@@ -32,7 +32,7 @@ namespace Jovian.PopupSystem {
///
public PopupContentBuilder AddText(string text, PopupElementType elementType) {
var go = view.GetElement(elementType);
- if(go == null) {
+ if(!go) {
return this;
}
var tmp = go.GetComponentInChildren();
diff --git a/Runtime/PopupSystem.cs b/Runtime/PopupSystem.cs
index 00ae63e..2ff38cd 100644
--- a/Runtime/PopupSystem.cs
+++ b/Runtime/PopupSystem.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Jovian.PopupSystem.UI;
+using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using Object = UnityEngine.Object;
@@ -115,12 +116,7 @@ namespace Jovian.PopupSystem {
kvp.Value.animator.Tick(deltaTime);
}
- foreach(var kvp in categories) {
- var state = kvp.Value;
- if(!state.isPending) {
- continue;
- }
-
+ foreach(var state in categories.Select(kvp => kvp.Value).Where(state => state.isPending)) {
state.delayTimer -= deltaTime;
if(state.delayTimer > 0f) {
continue;
@@ -130,11 +126,8 @@ namespace Jovian.PopupSystem {
ShowImmediate(state);
}
- foreach(var kvp in categories) {
- var state = kvp.Value;
- if(state.view != null && state.view.IsVisible && state.isFollowMouse) {
- state.view.UpdatePosition();
- }
+ foreach(var state in categories.Select(kvp => kvp.Value).Where(state => state.view is { IsVisible: true } && state.isFollowMouse)) {
+ state.view.UpdatePosition();
}
}
@@ -216,7 +209,7 @@ namespace Jovian.PopupSystem {
state.view.SetFixedPosition(state.pendingScreenPos.Value, settings.screenEdgePadding);
state.isFollowMouse = false;
}
- else if(state.pendingAnchor != null) {
+ else if(state.pendingAnchor) {
state.view.SetAnchorMode(state.pendingAnchor, state.pendingAnchorSide, settings.screenEdgePadding);
state.isFollowMouse = false;
}
@@ -235,15 +228,10 @@ namespace Jovian.PopupSystem {
}
PopupReference popupRef;
- if(canvasParent != null) {
- popupRef = Object.Instantiate(viewPrefab, canvasParent);
- }
- else {
- popupRef = Object.Instantiate(viewPrefab);
- }
+ popupRef = !canvasParent ? Object.Instantiate(viewPrefab) : Object.Instantiate(viewPrefab, canvasParent);
var canvas = popupRef.GetComponent