Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable horizontal inventory slot alignment #1400

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class InventoryView : View
[SerializeField] private GameObject EarRightPrefab;
[SerializeField] private GameObject DummyPrefab;


private HorizontalLayoutGroup layoutGroup;
private object lockObject = new object();

/// <summary>
Expand Down Expand Up @@ -87,6 +87,7 @@ public void Setup(HumanInventory inventory)
{
FillClothingLayoutWithDummySlots();
Inventory = inventory;
layoutGroup = HorizontalLayout.GetComponent<HorizontalLayoutGroup>();

foreach(var container in inventory.Containers)
{
Expand Down Expand Up @@ -120,6 +121,11 @@ private void HandleInventoryContainerAdded(AttachedContainer container)
if (Slots.Exists(x => x.Container == container))
return;

if (HorizontalSlotOrder.Contains(container.Type) && layoutGroup.enabled == false)
{
layoutGroup.enabled = true;
}

SingleItemContainerSlot slot;
switch (container.Type)
{
Expand Down Expand Up @@ -376,6 +382,11 @@ private void HandleInventoryContainerRemoved(AttachedContainer container)
SingleItemContainerSlot slot = Slots[indexToRemove];
if (slot == null) return;

if (HorizontalSlotOrder.Contains(container.Type) && layoutGroup.enabled)
{
layoutGroup.enabled = false;
}

slot?.gameObject.Dispose(true);
Slots.RemoveAt(indexToRemove);
}
Expand Down
Loading