Skip to content

Commit

Permalink
Fix bug in script init logic
Browse files Browse the repository at this point in the history
[CI BUILD]
  • Loading branch information
andybak committed Mar 29, 2023
1 parent b497fc0 commit ab15e80
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Assets/Scripts/API/Lua/LuaManager.cs
Expand Up @@ -584,10 +584,29 @@ private void _SetActiveScript(LuaApiCategory category, int index)
{
ActiveScripts[category] = index;
var script = GetActiveScript(category);
if (PointerScriptsEnabled) InitScript(script);
if (IsCategoryActive(category)) InitScript(script);
ConfigureScriptButton(category);
}

private bool IsCategoryActive(LuaApiCategory category)
{
// We have booleans for Background and Pointer scripts
// For symmetry and tool scripts, the UI buttons bypass LuaManager to activate the mode
// So we have to query their status more indirectly.
switch (category)
{
case LuaApiCategory.BackgroundScript:
return BackgroundScriptsEnabled;
case LuaApiCategory.PointerScript:
return PointerScriptsEnabled;
case LuaApiCategory.SymmetryScript:
return PointerManager.m_Instance.CurrentSymmetryMode == PointerManager.SymmetryMode.ScriptedSymmetryMode;
case LuaApiCategory.ToolScript:
return SketchSurfacePanel.m_Instance.GetCurrentToolType() == BaseTool.ToolType.ScriptedTool;
}
return false;
}

public void ConfigureScriptButton(LuaApiCategory category)
{
var script = GetActiveScript(category);
Expand Down

0 comments on commit ab15e80

Please sign in to comment.