This commit is contained in:
Kamila Stawarska 2025-03-03 19:17:05 +01:00
parent b3c1d2fd14
commit f7a7427610
14 changed files with 31 additions and 24 deletions

View File

@ -1,5 +1,4 @@
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement;
namespace NEG.Utils namespace NEG.Utils
{ {

View File

@ -185,8 +185,10 @@ public static class BuildingUtils
string command = string command =
$"cd {Application.dataPath}/../../{Application.productName}-Steam/ContentBuilder && push_build.bat"; $"cd {Application.dataPath}/../../{Application.productName}-Steam/ContentBuilder && push_build.bat";
if (demo) if (demo)
{
command = command =
$"cd {Application.dataPath}/../../{Application.productName}-Steam/ContentBuilder && push_demo.bat"; $"cd {Application.dataPath}/../../{Application.productName}-Steam/ContentBuilder && push_demo.bat";
}
var processInfo = new ProcessStartInfo("cmd.exe", $"/c {command}") var processInfo = new ProcessStartInfo("cmd.exe", $"/c {command}")
{ {

View File

@ -102,8 +102,10 @@ namespace NegUtils.Editor
return; return;
if (EditorPrefs.GetBool("GoToCurrentSceneAfterPlay")) if (EditorPrefs.GetBool("GoToCurrentSceneAfterPlay"))
{
EditorSceneManager.LoadSceneInPlayMode(EditorPrefs.GetString("LastOpenedScenePath"), EditorSceneManager.LoadSceneInPlayMode(EditorPrefs.GetString("LastOpenedScenePath"),
new LoadSceneParameters(LoadSceneMode.Single)); new LoadSceneParameters(LoadSceneMode.Single));
}
else if (EditorPrefs.GetBool("GoToFirstSceneAfterPlay")) else if (EditorPrefs.GetBool("GoToFirstSceneAfterPlay"))
SceneManager.LoadScene(1); SceneManager.LoadScene(1);
} }

View File

@ -31,8 +31,10 @@ namespace NEG.Utils
var methodFields = var methodFields =
type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
for (int i = 0; i < methodFields.Length; i++) for (int i = 0; i < methodFields.Length; i++)
{
if (Attribute.GetCustomAttribute(methodFields[i], typeof(FactoryRegistration)) != null) if (Attribute.GetCustomAttribute(methodFields[i], typeof(FactoryRegistration)) != null)
methodFields[i].Invoke(null, Array.Empty<object>()); methodFields[i].Invoke(null, Array.Empty<object>());
}
} }
} }

View File

@ -248,8 +248,10 @@ namespace System.Collections.Generic
public PriorityQueue(int initialCapacity, IComparer<TPriority>? comparer) public PriorityQueue(int initialCapacity, IComparer<TPriority>? comparer)
{ {
if (initialCapacity < 0) if (initialCapacity < 0)
{
throw new ArgumentOutOfRangeException( throw new ArgumentOutOfRangeException(
nameof(initialCapacity), initialCapacity, SR.ArgumentOutOfRange_NeedNonNegNum); nameof(initialCapacity), initialCapacity, SR.ArgumentOutOfRange_NeedNonNegNum);
}
_nodes = new (TElement, TPriority)[initialCapacity]; _nodes = new (TElement, TPriority)[initialCapacity];
_comparer = InitializeComparer(comparer); _comparer = InitializeComparer(comparer);
@ -508,9 +510,8 @@ namespace System.Collections.Generic
if (_size > 1) Heapify(); if (_size > 1) Heapify();
} }
else else
{ foreach (var (element, priority) in items)
foreach (var (element, priority) in items) Enqueue(element, priority); Enqueue(element, priority);
}
} }
/// <summary> /// <summary>
@ -554,9 +555,8 @@ namespace System.Collections.Generic
if (i > 1) Heapify(); if (i > 1) Heapify();
} }
else else
{ foreach (var element in elements)
foreach (var element in elements) Enqueue(element, priority); Enqueue(element, priority);
}
} }
/// <summary> /// <summary>
@ -684,11 +684,15 @@ namespace System.Collections.Generic
int lastParentWithChildren = GetParentIndex(_size - 1); int lastParentWithChildren = GetParentIndex(_size - 1);
if (_comparer == null) if (_comparer == null)
{
for (int index = lastParentWithChildren; index >= 0; --index) for (int index = lastParentWithChildren; index >= 0; --index)
MoveDownDefaultComparer(nodes[index], index); MoveDownDefaultComparer(nodes[index], index);
}
else else
{
for (int index = lastParentWithChildren; index >= 0; --index) for (int index = lastParentWithChildren; index >= 0; --index)
MoveDownCustomComparer(nodes[index], index); MoveDownCustomComparer(nodes[index], index);
}
} }
/// <summary> /// <summary>
@ -715,9 +719,7 @@ namespace System.Collections.Generic
nodeIndex = parentIndex; nodeIndex = parentIndex;
} }
else else
{
break; break;
}
} }
nodes[nodeIndex] = node; nodes[nodeIndex] = node;
@ -748,9 +750,7 @@ namespace System.Collections.Generic
nodeIndex = parentIndex; nodeIndex = parentIndex;
} }
else else
{
break; break;
}
} }
nodes[nodeIndex] = node; nodes[nodeIndex] = node;
@ -894,8 +894,10 @@ namespace System.Collections.Generic
if (array.GetLowerBound(0) != 0) throw new ArgumentException(SR.Arg_NonZeroLowerBound, nameof(array)); if (array.GetLowerBound(0) != 0) throw new ArgumentException(SR.Arg_NonZeroLowerBound, nameof(array));
if (index < 0 || index > array.Length) if (index < 0 || index > array.Length)
{
throw new ArgumentOutOfRangeException(nameof(index), index, throw new ArgumentOutOfRangeException(nameof(index), index,
SR.ArgumentOutOfRange_IndexMustBeLessOrEqual); SR.ArgumentOutOfRange_IndexMustBeLessOrEqual);
}
if (array.Length - index < _queue._size) throw new ArgumentException(SR.Argument_InvalidOffLen); if (array.Length - index < _queue._size) throw new ArgumentException(SR.Argument_InvalidOffLen);

View File

@ -29,7 +29,7 @@ namespace NEG.UI.Area
private void OnDestroy() private void OnDestroy()
{ {
if(UiManager.Instance == null) if (UiManager.Instance == null)
return; return;
if (ReferenceEquals(UiManager.Instance.CurrentArea, this)) if (ReferenceEquals(UiManager.Instance.CurrentArea, this))
UiManager.Instance.CurrentArea = null; UiManager.Instance.CurrentArea = null;

View File

@ -43,10 +43,7 @@ namespace NEG.UI.UnityUi.Buttons
private void Start() => OnDeselect(null); private void Start() => OnDeselect(null);
private void OnValidate() private void OnValidate() => this.ValidateRefs();
{
this.ValidateRefs();
}
public void OnDeselect(BaseEventData eventData) => OnDeselected?.Invoke(eventData is SilentEventData); public void OnDeselect(BaseEventData eventData) => OnDeselected?.Invoke(eventData is SilentEventData);

View File

@ -1,3 +1,4 @@
using UnityEditor;
using UnityEngine; using UnityEngine;
namespace NEG.UI.UnityUi.Buttons.Reactions namespace NEG.UI.UnityUi.Buttons.Reactions
@ -7,7 +8,7 @@ namespace NEG.UI.UnityUi.Buttons.Reactions
protected override void OnClicked() protected override void OnClicked()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false; EditorApplication.isPlaying = false;
#endif #endif
Application.Quit(); Application.Quit();
} }

View File

@ -74,10 +74,12 @@ namespace NEG.UI.UnityUi
var data = new PointerEventData(EventSystem.current); var data = new PointerEventData(EventSystem.current);
var currentSelected = EventSystem.current.currentSelectedGameObject; var currentSelected = EventSystem.current.currentSelectedGameObject;
if (currentSelected != null) if (currentSelected != null)
{
for (var current = EventSystem.current.currentSelectedGameObject.transform; for (var current = EventSystem.current.currentSelectedGameObject.transform;
current != null; current != null;
current = current.parent) current = current.parent)
ExecuteEvents.Execute(current.gameObject, data, ExecuteEvents.pointerExitHandler); ExecuteEvents.Execute(current.gameObject, data, ExecuteEvents.pointerExitHandler);
}
EventSystem.current.SetSelectedGameObject(currentSelected); EventSystem.current.SetSelectedGameObject(currentSelected);
} }

View File

@ -27,7 +27,7 @@ namespace NEG.UI.UnityUi.Window
private void OnDestroy() private void OnDestroy()
{ {
if(UiManager.Instance == null) if (UiManager.Instance == null)
return; return;
if (IsOpened) if (IsOpened)
UiManager.Instance.OnWindowClosed(this); UiManager.Instance.OnWindowClosed(this);

View File

@ -5,5 +5,4 @@ namespace NEG.Utils
public class ReadOnlyAttribute : PropertyAttribute public class ReadOnlyAttribute : PropertyAttribute
{ {
} }
} }

View File

@ -10,9 +10,8 @@ namespace NEG.Utils.UiToolkits
{ {
public class MultiSelectChips : VisualElement public class MultiSelectChips : VisualElement
{ {
private readonly List<MultiSelectChipItem> spawnedItems = new();
private readonly VisualTreeAsset itemPrefab; private readonly VisualTreeAsset itemPrefab;
private readonly List<MultiSelectChipItem> spawnedItems = new();
private ICollection<IMultiSelectChipItem> itemsSource; private ICollection<IMultiSelectChipItem> itemsSource;
@ -86,8 +85,10 @@ namespace NEG.Utils.UiToolkits
List<IMultiSelectChipItem> itemsToAdd = new(itemsSource); List<IMultiSelectChipItem> itemsToAdd = new(itemsSource);
foreach (var item in spawnedItems) foreach (var item in spawnedItems)
{
if (itemsToAdd.Contains(item.ChipItem)) if (itemsToAdd.Contains(item.ChipItem))
itemsToAdd.Remove(item.ChipItem); itemsToAdd.Remove(item.ChipItem);
}
foreach (var item in itemsToAdd) foreach (var item in itemsToAdd)
{ {

View File

@ -1,4 +1,4 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" <ui:UXML xmlns:ui="UnityEngine.UIElements"
xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:VisualElement name="VisualElement" class="unity-button" <ui:VisualElement name="VisualElement" class="unity-button"

View File

@ -1,4 +1,4 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" <ui:UXML xmlns:ui="UnityEngine.UIElements"
xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:VisualElement style="flex-direction: row; flex-wrap: wrap;"> <ui:VisualElement style="flex-direction: row; flex-wrap: wrap;">