Skip to content

Commit a9a2588

Browse files
committed
Fixed copilot comments
1 parent 573c208 commit a9a2588

File tree

4 files changed

+31
-35
lines changed

4 files changed

+31
-35
lines changed

Assets/AltTester/Runtime/Commands/ObjectCommands/AltSetTextCommand.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,25 @@ public override AltObject Execute()
4646

4747
foreach (var property in textProperties)
4848
{
49-
UnityEngine.Debug.LogWarning($"Trying to set text on {property.Component}.{property.Property}");
5049
try
5150
{
5251
var type = GetType(property.Component, property.Assembly);
5352
string valueText = Newtonsoft.Json.JsonConvert.SerializeObject(CommandParams.value); // Ensure Newtonsoft.Json is correctly referenced
5453
SetValueForMember(CommandParams.altObject, property.Property.Split('.'), type, valueText);
5554
if (targetObject.TryGetComponent<UnityEngine.UI.InputField>(out var uiInputFieldComp))
5655
{
57-
if (uiInputFieldComp != null)
58-
{
59-
uiInputFieldComp.onValueChanged.Invoke(CommandParams.value);
60-
checkSubmit(uiInputFieldComp.gameObject);
56+
57+
uiInputFieldComp.onValueChanged.Invoke(CommandParams.value);
58+
checkSubmit(uiInputFieldComp.gameObject);
6159
#if UNITY_2021_1_OR_NEWER
62-
uiInputFieldComp.onSubmit.Invoke(CommandParams.value);
60+
uiInputFieldComp.onSubmit.Invoke(CommandParams.value);
6361
#endif
64-
uiInputFieldComp.onEndEdit.Invoke(CommandParams.value);
65-
}
62+
uiInputFieldComp.onEndEdit.Invoke(CommandParams.value);
6663
}
6764
#if TMP_PRESENT
6865
else
6966
{
70-
var tMPInputFieldComp = targetObject.GetComponent<TMPro.TMP_InputField>();
71-
if (tMPInputFieldComp != null)
67+
if (targetObject.TryGetComponent<TMPro.TMP_InputField>(out var tMPInputFieldComp))
7268
{
7369
tMPInputFieldComp.onValueChanged.Invoke(CommandParams.value);
7470
checkSubmit(tMPInputFieldComp.gameObject);

Assets/AltTester/Runtime/UI/AltDialog.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,11 @@ private IEnumerator getRequest()
724724
else
725725
{
726726
isNewVersionAvailable = true;
727-
newVersionMessage = $"<size=26>Version <b>{releasedVersion}</b> is available to <b><color={colorCode}><u><link=\"download\">download</link></u></color></b>.</size>";
727+
newVersionMessage = $"<size=26>Version <b>{releasedVersion}</b> is available to <b><color={colorCode}>download</color></b>.</size>";
728728
}
729729
}
730730
}
731+
731732
}
732733

733734
private bool isCurrentVersionOlderOrEqualThanRelease(string releasedVersion, string version)
@@ -786,9 +787,9 @@ private IEnumerator showNewVersionMessage()
786787
}
787788
while (currentTime < totalTime)
788789
{
789-
MessageText.text = $"{newVersionMessage} {Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}" +
790+
MessageText.text = $"{newVersionMessage} {Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}" +
790791
$"This message will disappear in <b>{totalTime - currentTime}</b> seconds.{Environment.NewLine}" +
791-
$"<b><color={colorCode}><u><link=\"close\">Click here to close.</link></u></color></b>";
792+
$"<b><color={colorCode}>Click here to close.</color></b>";
792793

793794

794795
yield return new WaitForSeconds(interval);

Assets/AltTester/Runtime/UI/MessageClickHandler.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,35 @@ namespace AltTester.AltTesterUnitySDK.UI
66
{
77
public class MessageClickHandler : MonoBehaviour, IPointerClickHandler
88
{
9-
private Text messageText;
9+
private Text textComponent;
1010
private AltDialog dialog;
11+
private Canvas canvas;
1112
public void Awake()
1213
{
13-
messageText = GetComponent<Text>();
14+
textComponent = GetComponent<Text>();
1415
dialog = GetComponentInParent<AltDialog>();
16+
canvas = GetComponentInParent<Canvas>();
1517
}
1618

1719
public void OnPointerClick(PointerEventData eventData)
1820
{
19-
// Check if the clicked text is a link
20-
// int linkIndex = TMP_TextUtilities.FindIntersectingLink(messageText, eventData.position, null);
21-
// if (linkIndex != -1)
22-
// {
23-
// TMP_LinkInfo linkInfo = messageText.textInfo.linkInfo[linkIndex];
24-
// if (linkInfo.GetLinkID() == "close")
25-
// {
26-
// Debug.Log("Close link clicked!");
27-
// dialog.CloseNewVersionMessage(true);
28-
// }
29-
// else if (linkInfo.GetLinkID() == "download")
30-
// {
31-
// Debug.Log("Download link clicked!");
32-
// dialog.DownloadNewVersion();
33-
// }
34-
// }
21+
Vector2 localPoint;
22+
23+
Camera camera = (canvas.renderMode == RenderMode.ScreenSpaceOverlay) ? null : canvas.worldCamera;
24+
RectTransformUtility.ScreenPointToLocalPointInRectangle(
25+
textComponent.rectTransform,
26+
eventData.position,
27+
camera,
28+
out localPoint
29+
);
30+
if (localPoint.y > 0)
31+
{
32+
dialog.DownloadNewVersion();
33+
}
34+
else
35+
{
36+
dialog.CloseNewVersionMessage(true);
37+
}
3538
}
3639
}
3740
}

Assets/Editor/CreateAltPrefab.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,6 @@ public static Button CreateCloseButton(RectTransform parent)
626626

627627
return CloseButtonGameObject.GetComponent<Button>();
628628
}
629-
public static void SetupIcons()
630-
{
631-
632-
}
633629

634630
public static Image CreateAltTesterIcon(RectTransform parent)
635631
{

0 commit comments

Comments
 (0)