Skip to content

Commit 858af0c

Browse files
committed
tmp has new alignment options, mapped.
1 parent f745c0f commit 858af0c

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

Example/Assets/Plugins/NativeEditBox/NativeEditBox.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ enum ReturnButtonType
1515
Done,
1616
}
1717

18+
enum TextAnchor
19+
{
20+
TextAnchorUpperLeft,
21+
TextAnchorUpperCenter,
22+
TextAnchorUpperRight,
23+
TextAnchorMiddleLeft,
24+
TextAnchorMiddleCenter,
25+
TextAnchorMiddleRight,
26+
TextAnchorLowerLeft,
27+
TextAnchorLowerCenter,
28+
TextAnchorLowerRight
29+
};
30+
1831
public delegate void OnEventHandler();
1932
public delegate void OnTextChangedHandler(string text);
2033
public delegate void OnSubmitHandler(string text);

Example/Assets/Plugins/NativeEditBox/NativeEditBox.ios.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,33 @@ void SetupInputField()
192192
TMP_Text text = inputField.textComponent;
193193
TMP_Text placeholder = inputField.placeholder as TMP_Text;
194194

195+
//ugly, fix enum
196+
TextAnchor alignment = text.verticalAlignment switch
197+
{
198+
VerticalAlignmentOptions.Top => text.horizontalAlignment switch
199+
{
200+
HorizontalAlignmentOptions.Left => TextAnchor.TextAnchorUpperLeft,
201+
HorizontalAlignmentOptions.Center => TextAnchor.TextAnchorUpperCenter,
202+
HorizontalAlignmentOptions.Right => TextAnchor.TextAnchorUpperRight,
203+
_ => TextAnchor.TextAnchorUpperLeft
204+
},
205+
VerticalAlignmentOptions.Middle => text.horizontalAlignment switch
206+
{
207+
HorizontalAlignmentOptions.Left => TextAnchor.TextAnchorMiddleLeft,
208+
HorizontalAlignmentOptions.Center => TextAnchor.TextAnchorMiddleCenter,
209+
HorizontalAlignmentOptions.Right => TextAnchor.TextAnchorMiddleRight,
210+
_ => TextAnchor.TextAnchorMiddleLeft
211+
},
212+
VerticalAlignmentOptions.Bottom => text.horizontalAlignment switch
213+
{
214+
HorizontalAlignmentOptions.Left => TextAnchor.TextAnchorLowerLeft,
215+
HorizontalAlignmentOptions.Center => TextAnchor.TextAnchorLowerCenter,
216+
HorizontalAlignmentOptions.Right => TextAnchor.TextAnchorLowerRight,
217+
_ => TextAnchor.TextAnchorLowerLeft
218+
},
219+
_ => TextAnchor.TextAnchorUpperLeft
220+
};
221+
195222
editBox = _CNativeEditBox_Init(GetInstanceID(), inputField.lineType != TMP_InputField.LineType.SingleLine);
196223
_CNativeEditBox_RegisterKeyboardChangedCallback(delegateKeyboardChanged);
197224
_CNativeEditBox_RegisterTextCallbacks(DelegateTextChanged, DelegateDidEnd, DelegateSubmitPressed);
@@ -202,7 +229,7 @@ void SetupInputField()
202229
_CNativeEditBox_SetFontSize(editBox, Mathf.RoundToInt(text.fontSize * text.pixelsPerUnit));
203230
_CNativeEditBox_SetFontColor(editBox, text.color.r, text.color.g, text.color.b, text.color.a);
204231
_CNativeEditBox_SetPlaceholder(editBox, placeholder.text, placeholder.color.r, placeholder.color.g, placeholder.color.b, placeholder.color.a);
205-
_CNativeEditBox_SetTextAlignment(editBox, (int)text.alignment);
232+
_CNativeEditBox_SetTextAlignment(editBox, (int)alignment);
206233
_CNativeEditBox_SetInputType(editBox, (int)inputField.inputType);
207234
_CNativeEditBox_SetKeyboardType(editBox, (int)inputField.keyboardType);
208235
_CNativeEditBox_SetReturnButtonType(editBox, (int)returnButtonType);

0 commit comments

Comments
 (0)