Skip to content

Commit

Permalink
Fix UI layout
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfCYBER committed Feb 18, 2023
1 parent f51eb21 commit 7f9e009
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Heatmap.Unity/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.5.2.0")]
[assembly: AssemblyFileVersion("1.5.2.0")]
35 changes: 35 additions & 0 deletions Heatmap/Logging/Logging.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Text;
using UnityEngine;

namespace Heatmap.Logging
Expand Down Expand Up @@ -42,5 +43,39 @@ public static void Log(string message, LogLevel level)
if (level <= Level)
Debug.Log(_tag + _prefix[level] + message);
}

/// <summary>
/// Log a hierarchy of gameobjects with their components
/// </summary>
public static void DumpGameObjectRecursive(GameObject obj, int maxDepth = 2)
{
StringBuilder output = new StringBuilder();
DumpGameObjectRecursive(obj, ref output, maxDepth: maxDepth);

if (output.Length > 10000)
output.AppendLine("Safety limit of 10000 characters exceeded");

Debug.Log(output);
}

private static void DumpGameObjectRecursive(GameObject obj, ref StringBuilder output, int maxDepth, int depth = 0)
{
output.AppendLine();
if (output.Length > 10000) return; // Safety limit

// Print gameobject name
string objectPadding = new string(' ', depth * 4);
output.AppendLine($"{objectPadding}gameobject with name {obj.name}");

// Print the type of every component in the gameobject, indented one level relative to obj
string componentPadding = new string(' ', depth * 4 + 4);
foreach (Component component in obj.GetComponents<Component>())
output.AppendLine($"{componentPadding}component of type {component.GetType().FullName}");

// Call this function for every child object until maxdepth is reached
if (depth >= maxDepth) return;
for (int i = 0; i < obj.transform.childCount; i++)
DumpGameObjectRecursive(obj.transform.GetChild(i).gameObject, ref output, maxDepth, depth + 1);
}
}
}
4 changes: 2 additions & 2 deletions Heatmap/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.5.2.0")]
[assembly: AssemblyFileVersion("1.5.2.0")]
2 changes: 1 addition & 1 deletion Heatmap/UI/SettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SettingsPanel(GameObject parent)
PanelManager = _panel.GetComponent<SettingsPanelManager>();

// Move the panel so it is next to the toolbar
_panel.GetComponent<RectTransform>().anchoredPosition = new Vector2(200, -180);
_panel.GetComponent<RectTransform>().anchoredPosition = new Vector2(165, -5);

// Hook up events
PanelManager.Close.onClick.AddListener(Destroy);
Expand Down
8 changes: 1 addition & 7 deletions Heatmap/UI/ToolbarButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ToolbarButton()
// Copy the button and add it to the layoutgroup
_buttonHolder = Object.Instantiate(sourceButton);
Object.DontDestroyOnLoad(_buttonHolder);
_buttonHolder.transform.SetParent(buttonGroup.transform, worldPositionStays: false);
_buttonHolder.transform.SetParent(buttonGroup.transform.parent, worldPositionStays: false);
_buttonHolder.gameObject.SetActive(value: true);
_button = _buttonHolder.GetComponentInChildren<MultiTargetButton>();

Expand All @@ -47,12 +47,6 @@ public ToolbarButton()
// Make the button a toggle
_button.onClick = new Button.ButtonClickedEvent();
_button.onClick.AddListener(ButtonPressed);

// Not entirely sure what this exactly does, but it increases the
// layoutgroup size so that buttons are no longer squished
RectTransform rect = buttonGroup.gameObject.GetComponent<RectTransform>();
rect.sizeDelta = new Vector2(rect.sizeDelta.x, rect.sizeDelta.y * 1.5f);
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, rect.anchoredPosition.y * 1.5f);
}

internal async void ButtonPressed()
Expand Down

0 comments on commit 7f9e009

Please sign in to comment.