Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scaling in chatbot sample #16

Merged
merged 3 commits into from
Jan 12, 2024
Merged
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
6 changes: 5 additions & 1 deletion Samples~/ChatBot/Bubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void SetBubblePosition(RectTransform bubbleRectTransform, RectTransform imageRec
bubbleRectTransform.pivot = new Vector2(bubbleUI.leftPosition, bubbleUI.bottomPosition);
bubbleRectTransform.anchorMin = new Vector2(bubbleUI.leftPosition, bubbleUI.bottomPosition);
bubbleRectTransform.anchorMax = new Vector2(bubbleUI.leftPosition, bubbleUI.bottomPosition);
bubbleRectTransform.localScale = Vector3.one;
Vector2 anchoredPosition = new Vector2(bubbleUI.bubbleOffset + bubbleUI.textPadding, bubbleUI.bubbleOffset + bubbleUI.textPadding);
if (bubbleUI.leftPosition == 1) anchoredPosition.x *= -1;
if (bubbleUI.bottomPosition == 1) anchoredPosition.y *= -1;
Expand Down Expand Up @@ -156,6 +157,7 @@ GameObject CreatePlaceholderObject(Transform parent, RectTransform textRectTrans
RectTransform placeholderRectTransform = placeholderObject.GetComponent<RectTransform>();
placeholderRectTransform.sizeDelta = textRectTransform.sizeDelta;
placeholderRectTransform.anchoredPosition = textRectTransform.anchoredPosition;
placeholderRectTransform.localScale = Vector3.one;
SyncParentRectTransform(placeholderRectTransform);
return placeholderObject;
}
Expand All @@ -170,7 +172,9 @@ GameObject CreateInputFieldObject(Transform parent, Text textObject, Text placeh
inputField.lineType = InputField.LineType.MultiLineSubmit;
inputField.shouldHideMobileInput = false;
inputField.shouldActivateOnSelect = true;
SyncParentRectTransform(inputFieldObject.GetComponent<RectTransform>());
RectTransform inputFieldRect = inputFieldObject.GetComponent<RectTransform>();
inputFieldRect.localScale = Vector3.one;
SyncParentRectTransform(inputFieldRect);
return inputFieldObject;
}

Expand Down
2 changes: 1 addition & 1 deletion Samples~/ChatBot/ChatBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void UpdateBubblePositions()
for (int i = chatBubbles.Count - 1; i >= 0; i--) {
Bubble bubble = chatBubbles[i];
RectTransform childRect = bubble.GetRectTransform();
childRect.position = new Vector2(childRect.position.x, y);
childRect.anchoredPosition = new Vector2(childRect.anchoredPosition.x, y);

// last bubble outside the container
if (y > containerHeight && lastBubbleOutsideFOV == -1){
Expand Down
4 changes: 2 additions & 2 deletions Samples~/ChatBot/Scene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ MonoBehaviour:
aiColor: {r: 0.11372549, g: 0.11372549, b: 0.28627452, a: 1}
fontColor: {r: 1, g: 1, b: 1, a: 1}
font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
fontSize: 16
bubbleWidth: 450
fontSize: 20
bubbleWidth: 600
llm: {fileID: 817827756}
textPadding: 10
bubbleSpacing: 10
Expand Down