Skip to content

Commit

Permalink
Fix injected Tool api property names
Browse files Browse the repository at this point in the history
  • Loading branch information
andybak committed Jul 18, 2023
1 parent c3358a0 commit 9d5dde2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Assets/Editor/LuaExampleScriptsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ static void DoTest()
foreach (var example in toolScripts)
{
var script = example.Value;
LuaManager.Instance.SetApiProperty(script, LuaNames.ToolScriptVector, Vector3.one);
LuaManager.Instance.SetApiProperty(script, LuaNames.ToolScriptRotation, Quaternion.LookRotation(Vector3.one));
LuaManager.Instance.SetApiProperty(script, $"Tool.{LuaNames.ToolScriptVector}", Vector3.one);
LuaManager.Instance.SetApiProperty(script, $"Tool.{LuaNames.ToolScriptRotation}", Quaternion.LookRotation(Vector3.one));
TestAllKnown(script);
}

Expand Down Expand Up @@ -167,8 +167,8 @@ void SubmitDropDownValue(string value)

var startPoint = Vector3.up;
var endPoint = Vector3.up + Vector3.one;
LuaManager.Instance.SetApiProperty(script, LuaNames.ToolScriptVector, endPoint - startPoint);
LuaManager.Instance.SetApiProperty(script, LuaNames.ToolScriptRotation, Quaternion.LookRotation(endPoint - startPoint));
LuaManager.Instance.SetApiProperty(script, $"Tool.{LuaNames.ToolScriptVector}", endPoint - startPoint);
LuaManager.Instance.SetApiProperty(script, $"Tool.{LuaNames.ToolScriptRotation}", Quaternion.LookRotation(endPoint - startPoint));
LuaManager.Instance.DoToolScript(LuaNames.Main, TrTransform.T(startPoint), TrTransform.T(endPoint));
}
}
Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/API/Lua/LuaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public static class LuaNames

// Injected Toolscript properties

public static string ToolScriptStartPoint => "Tool.startPoint";
public static string ToolScriptEndPoint => "Tool.endPoint";
public static string ToolScriptVector => "Tool.vector";
public static string ToolScriptRotation => "Tool.rotation";
public static string ToolScriptStartPoint => "startPoint";
public static string ToolScriptEndPoint => "endPoint";
public static string ToolScriptVector => "vector";
public static string ToolScriptRotation => "rotation";

}

Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/Tools/ScriptedTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ override public void UpdateTool()
m_FirstPositionClicked_CS = rAttachPoint_CS;
m_FirstPositionClicked_GS = rAttachPoint_GS;

SetApiProperty(LuaNames.ToolScriptStartPoint, m_FirstPositionClicked_CS);
SetApiProperty($"Tool.{LuaNames.ToolScriptStartPoint}", m_FirstPositionClicked_CS);
ApiManager.Instance.StartUndo();
}

Expand Down Expand Up @@ -220,9 +220,9 @@ override public void UpdateTool()
{
m_WasClicked = false;
var drawnVector_CS = rAttachPoint_CS.translation - m_FirstPositionClicked_CS.translation;
SetApiProperty(LuaNames.ToolScriptEndPoint, rAttachPoint_CS);
SetApiProperty(LuaNames.ToolScriptVector, drawnVector_CS);
SetApiProperty(LuaNames.ToolScriptRotation, Quaternion.LookRotation(drawnVector_CS, Vector3.up));
SetApiProperty($"Tool.{LuaNames.ToolScriptEndPoint}", rAttachPoint_CS);
SetApiProperty($"Tool.{LuaNames.ToolScriptVector}", drawnVector_CS);
SetApiProperty($"Tool.{LuaNames.ToolScriptRotation}", Quaternion.LookRotation(drawnVector_CS, Vector3.up));
shouldEndUndo = true;
}
}
Expand Down

0 comments on commit 9d5dde2

Please sign in to comment.