Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 14 additions & 1 deletion general/PowerButtonCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,23 @@ void toggleOption(string pPower)
public static PowersTab GetTab(string pId)
{
if (string.IsNullOrEmpty(pId)) return null;

// Fast path (valid up to 0.51.0): hard-coded UI hierarchy lookup.
Transform tabTransform = CanvasMain.instance.canvas_ui.transform.Find(
$"CanvasBottom/BottomElements/BottomElementsMover/CanvasScrollView/Scroll View/Viewport/Content/Power Tabs/{pId}");
if (tabTransform != null)
{
var found = tabTransform.GetComponent<PowersTab>();
if (found != null) return found;
}

// Fallback (0.51.1+): the hierarchy moved. Locate the tab by its object name.
foreach (var tab in Resources.FindObjectsOfTypeAll<PowersTab>())
{
if (tab != null && tab.name == pId) return tab;
}

return tabTransform == null ? null : tabTransform.GetComponent<PowersTab>();
return null;
}

/// <summary>
Expand Down
16 changes: 12 additions & 4 deletions general/ui/tab/WrappedPowersTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@ public WrappedPowersTab(PowersTab pPowersTab)
{
Tab = pPowersTab;

Modifiable = !PowerTabNames.GetNames().Contains(Tab.name);

ButtonGroups = new();
CustomRectGroups = new();

AddGroup("Default");

_inactive_lines = new();
_active_lines = new();

if (Tab == null)
{
// Tab not found (e.g. hierarchy changed in a newer WorldBox build):
// don't NRE, just leave this wrapper inert.
Modifiable = false;
return;
}

Modifiable = !PowerTabNames.GetNames().Contains(Tab.name);

AddGroup("Default");
}

internal void RecordLine(GameObject line)
Expand Down