minor syntax
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Jovian.PopupSystem {
|
|||||||
/// or convenience methods for common types.
|
/// or convenience methods for common types.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly struct PopupContentBuilder {
|
public readonly struct PopupContentBuilder {
|
||||||
readonly PopupView view;
|
private readonly PopupView view;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a builder targeting the given popup view.
|
/// Creates a builder targeting the given popup view.
|
||||||
@@ -32,7 +32,7 @@ namespace Jovian.PopupSystem {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public PopupContentBuilder AddText(string text, PopupElementType elementType) {
|
public PopupContentBuilder AddText(string text, PopupElementType elementType) {
|
||||||
var go = view.GetElement(elementType);
|
var go = view.GetElement(elementType);
|
||||||
if(go == null) {
|
if(!go) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
var tmp = go.GetComponentInChildren<TMP_Text>();
|
var tmp = go.GetComponentInChildren<TMP_Text>();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Jovian.PopupSystem.UI;
|
using Jovian.PopupSystem.UI;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
@@ -115,12 +116,7 @@ namespace Jovian.PopupSystem {
|
|||||||
kvp.Value.animator.Tick(deltaTime);
|
kvp.Value.animator.Tick(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(var kvp in categories) {
|
foreach(var state in categories.Select(kvp => kvp.Value).Where(state => state.isPending)) {
|
||||||
var state = kvp.Value;
|
|
||||||
if(!state.isPending) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
state.delayTimer -= deltaTime;
|
state.delayTimer -= deltaTime;
|
||||||
if(state.delayTimer > 0f) {
|
if(state.delayTimer > 0f) {
|
||||||
continue;
|
continue;
|
||||||
@@ -130,11 +126,8 @@ namespace Jovian.PopupSystem {
|
|||||||
ShowImmediate(state);
|
ShowImmediate(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(var kvp in categories) {
|
foreach(var state in categories.Select(kvp => kvp.Value).Where(state => state.view is { IsVisible: true } && state.isFollowMouse)) {
|
||||||
var state = kvp.Value;
|
state.view.UpdatePosition();
|
||||||
if(state.view != null && state.view.IsVisible && state.isFollowMouse) {
|
|
||||||
state.view.UpdatePosition();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +209,7 @@ namespace Jovian.PopupSystem {
|
|||||||
state.view.SetFixedPosition(state.pendingScreenPos.Value, settings.screenEdgePadding);
|
state.view.SetFixedPosition(state.pendingScreenPos.Value, settings.screenEdgePadding);
|
||||||
state.isFollowMouse = false;
|
state.isFollowMouse = false;
|
||||||
}
|
}
|
||||||
else if(state.pendingAnchor != null) {
|
else if(state.pendingAnchor) {
|
||||||
state.view.SetAnchorMode(state.pendingAnchor, state.pendingAnchorSide, settings.screenEdgePadding);
|
state.view.SetAnchorMode(state.pendingAnchor, state.pendingAnchorSide, settings.screenEdgePadding);
|
||||||
state.isFollowMouse = false;
|
state.isFollowMouse = false;
|
||||||
}
|
}
|
||||||
@@ -235,15 +228,10 @@ namespace Jovian.PopupSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PopupReference popupRef;
|
PopupReference popupRef;
|
||||||
if(canvasParent != null) {
|
popupRef = !canvasParent ? Object.Instantiate(viewPrefab) : Object.Instantiate(viewPrefab, canvasParent);
|
||||||
popupRef = Object.Instantiate(viewPrefab, canvasParent);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
popupRef = Object.Instantiate(viewPrefab);
|
|
||||||
}
|
|
||||||
|
|
||||||
var canvas = popupRef.GetComponent<Canvas>();
|
var canvas = popupRef.GetComponent<Canvas>();
|
||||||
if(canvas != null) {
|
if(canvas) {
|
||||||
canvas.overrideSorting = true;
|
canvas.overrideSorting = true;
|
||||||
canvas.sortingOrder = settings.sortingOrder;
|
canvas.sortingOrder = settings.sortingOrder;
|
||||||
}
|
}
|
||||||
@@ -256,12 +244,13 @@ namespace Jovian.PopupSystem {
|
|||||||
private void DismissLowerPriority(int showingPriority) {
|
private void DismissLowerPriority(int showingPriority) {
|
||||||
foreach(var kvp in categories) {
|
foreach(var kvp in categories) {
|
||||||
var state = kvp.Value;
|
var state = kvp.Value;
|
||||||
if(state.priority < showingPriority && state.view != null && state.view.IsVisible) {
|
if(state.priority >= showingPriority || state.view is not { IsVisible: true }) {
|
||||||
state.isPending = false;
|
continue;
|
||||||
state.animator.Hide(state.view.CanvasGroup, settings.fadeDuration, () => {
|
|
||||||
state.view.SetVisible(false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
state.isPending = false;
|
||||||
|
state.animator.Hide(state.view.CanvasGroup, settings.fadeDuration, () => {
|
||||||
|
state.view.SetVisible(false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user