1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750 |
-
- #define SCKeyboard
- using SC.XR.Unity.Module_Keyboard;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- namespace SC.XR.Unity
- {
- [AddComponentMenu("UI/UGUI - SC Input Field", 32)]
- public class UGUI_SCInputField : SCInputField
- {
- protected UGUI_SCInputField()
- {
- this.EnforceTextHOverflow();
- }
- public override bool shouldHideMobileInput
- {
- get
- {
- #if SCKeyboard
- RuntimePlatform platform = Application.platform;
- return (platform != RuntimePlatform.IPhonePlayer &&
- platform != RuntimePlatform.tvOS)
- || this.m_HideMobileInput
-
- || (platform == RuntimePlatform.Android);
- #elif TouchScreenKeyboard
- RuntimePlatform platform = Application.platform;
- return (platform != RuntimePlatform.IPhonePlayer && platform != RuntimePlatform.Android && platform != RuntimePlatform.tvOS) || this.m_HideMobileInput;
- #endif
- }
- set
- {
- SCSetPropertyUtility.SetStruct<bool>(ref this.m_HideMobileInput, value);
- }
- }
- #region SCKeyboard
- private bool shouldDeactivateOnDeselect
- {
- get
- {
-
- return (m_Keyboard == null || m_Keyboard.status > 0)
- && EventSystem.current.currentSelectedGameObject != this.gameObject;
- }
- }
- #endregion
- public override string text
- {
- get
- {
- return this.m_Text;
- }
- set
- {
- this.SetText(value, true);
- }
- }
- public void SetTextWithoutNotify(string input)
- {
- this.SetText(input, false);
- }
- private void SetText(string value, bool sendCallback = true)
- {
- bool flag = this.text == value;
- if (!flag)
- {
- bool flag2 = value == null;
- if (flag2)
- {
- value = "";
- }
- value = value.Replace("\0", string.Empty);
- bool flag3 = this.m_LineType == UGUI_SCInputField.LineType.SingleLine;
- if (flag3)
- {
- value = value.Replace("\n", "").Replace("\t", "");
- }
- bool flag4 = this.onValidateInput != null || this.characterValidation > UGUI_SCInputField.CharacterValidation.None;
- if (flag4)
- {
- this.m_Text = "";
- UGUI_SCInputField.OnValidateInput validatorMethod = this.onValidateInput ?? new UGUI_SCInputField.OnValidateInput(this.Validate);
- this.m_CaretPosition = (this.m_CaretSelectPosition = value.Length);
- int charactersToCheck = (this.characterLimit > 0) ? Math.Min(this.characterLimit, value.Length) : value.Length;
- for (int i = 0; i < charactersToCheck; i++)
- {
- char c = validatorMethod(this.m_Text, this.m_Text.Length, value[i]);
- bool flag5 = c > '\0';
- if (flag5)
- {
- this.m_Text += c.ToString();
- }
- }
- }
- else
- {
- this.m_Text = ((this.characterLimit > 0 && value.Length > this.characterLimit) ? value.Substring(0, this.characterLimit) : value);
- }
- bool flag6 = !Application.isPlaying;
- if (flag6)
- {
- this.SendOnValueChangedAndUpdateLabel();
- }
- else
- {
- bool flag7 = this.m_Keyboard != null;
- if (flag7)
- {
- this.m_Keyboard.text = this.m_Text;
- }
- bool flag8 = this.m_CaretPosition > this.m_Text.Length;
- if (flag8)
- {
- this.m_CaretPosition = (this.m_CaretSelectPosition = this.m_Text.Length);
- }
- else
- {
- bool flag9 = this.m_CaretSelectPosition > this.m_Text.Length;
- if (flag9)
- {
- this.m_CaretSelectPosition = this.m_Text.Length;
- }
- }
- if (sendCallback)
- {
- this.SendOnValueChanged();
- }
- this.UpdateLabel();
- }
- }
- }
- public override int characterLimit
- {
- get
- {
- return this.m_CharacterLimit;
- }
- set
- {
- bool flag = SCSetPropertyUtility.SetStruct<int>(ref this.m_CharacterLimit, Math.Max(0, value));
- if (flag)
- {
- this.UpdateLabel();
- bool flag2 = this.m_Keyboard != null;
- if (flag2)
- {
- this.m_Keyboard.characterLimit = value;
- }
- }
- }
- }
- #if SCKeyboard
- public SCKeyboard scKeyboard
- {
- get
- {
- return this.m_Keyboard;
- }
- }
- #elif TouchScreenKeyboard
- public TouchScreenKeyboard touchScreenKeyboard
- {
- get
- {
- return this.m_Keyboard;
- }
- }
- #endif
- #if SCKeyboard
- public SCKeyboardEnum scKeyboardEnum
- {
- get
- {
- return this.m_SCKeyboardEnum;
- }
- set
- {
- bool flag = SCSetPropertyUtility.SetStruct<SCKeyboardEnum>(ref this.m_SCKeyboardEnum, value);
- if (flag)
- {
- this.SetToCustom();
- }
- }
- }
- #endif
- #if SCKeyboard
- public SCKeyboardType scKeyboardType
- {
- get
- {
- return this.m_SCKeyboardType;
- }
- set
- {
- bool flag = SCSetPropertyUtility.SetStruct<SCKeyboardType>(ref this.m_SCKeyboardType, value);
- if (flag)
- {
- this.SetToCustom();
- }
- }
- }
- #elif TouchScreenKeyboard
- public override TouchScreenKeyboardType keyboardType
- {
- get
- {
- return this.m_KeyboardType;
- }
- set
- {
- bool flag = SCSetPropertyUtility.SetStruct<TouchScreenKeyboardType>(ref this.m_KeyboardType, value);
- if (flag)
- {
- this.SetToCustom();
- }
- }
- }
- #endif
- #if UNITY_EDITOR
- protected override void OnValidate()
- {
- base.OnValidate();
- this.EnforceContentType();
- this.EnforceTextHOverflow();
- this.m_CharacterLimit = Math.Max(0, this.m_CharacterLimit);
- bool flag = !this.IsActive();
- if (!flag)
- {
- this.ClampPos(ref this.m_CaretPosition);
- this.ClampPos(ref this.m_CaretSelectPosition);
- this.UpdateLabel();
- bool allowInput = this.m_AllowInput;
- if (allowInput)
- {
- this.SetCaretActive();
- }
- }
- }
- #endif
- protected override IEnumerator CaretBlink()
- {
- base.CaretBlink();
- yield break;
- }
- protected override bool InPlaceEditing()
- {
- #if SCKeyboard
- return !SCKeyboard.isSupported || this.m_TouchKeyboardAllowsInPlaceEditing;
- #elif TouchScreenKeyboard
- return !TouchScreenKeyboard.isSupported || this.m_TouchKeyboardAllowsInPlaceEditing;
- #endif
- }
- protected override void UpdateCaretFromKeyboard()
- {
- RangeInt selectionRange = this.m_Keyboard.selection;
- int selectionStart = selectionRange.start;
- int selectionEnd = selectionRange.end;
- bool caretChanged = false;
- bool flag = this.caretPositionInternal != selectionStart;
- if (flag)
- {
- caretChanged = true;
- this.caretPositionInternal = selectionStart;
- }
- bool flag2 = this.caretSelectPositionInternal != selectionEnd;
- if (flag2)
- {
- this.caretSelectPositionInternal = selectionEnd;
- caretChanged = true;
- }
- bool flag3 = caretChanged;
- if (flag3)
- {
- this.m_BlinkStartTime = Time.unscaledTime;
- this.UpdateLabel();
- }
- }
- protected override void LateUpdate()
- {
- bool shouldActivateNextUpdate = this.m_ShouldActivateNextUpdate;
- if (shouldActivateNextUpdate)
- {
- bool flag = !this.isFocused;
- if (flag)
- {
- this.ActivateInputFieldInternal();
- this.m_ShouldActivateNextUpdate = false;
- return;
- }
- this.m_ShouldActivateNextUpdate = false;
- }
- this.AssignPositioningIfNeeded();
- bool flag2 = !this.isFocused || this.InPlaceEditing();
- if (!flag2)
- {
- #if SCKeyboard
- bool flag3 = this.m_Keyboard == null || this.m_Keyboard.status > SCKeyboard.Status.Visible;
- #elif TouchScreenKeyboard
- bool flag3 = this.m_Keyboard == null || this.m_Keyboard.status > TouchScreenKeyboard.Status.Visible;
- #endif
- if (flag3)
- {
- bool flag4 = this.m_Keyboard != null;
- if (flag4)
- {
- bool flag5 = !this.m_ReadOnly;
- if (flag5)
- {
- this.text = this.m_Keyboard.text;
- }
- #if SCKeyboard
- bool flag6 = this.m_Keyboard.status == SCKeyboard.Status.Canceled;
- #elif TouchScreenKeyboard
- bool flag6 = this.m_Keyboard.status == TouchScreenKeyboard.Status.Canceled;
- #endif
- if (flag6)
- {
- this.m_WasCanceled = true;
- }
- }
- this.OnDeselect(null);
- }
- else
- {
- string val = this.m_Keyboard.text;
- bool flag7 = this.m_Text != val;
- if (flag7)
- {
- bool readOnly = this.m_ReadOnly;
- if (readOnly)
- {
- this.m_Keyboard.text = this.m_Text;
- }
- else
- {
- this.m_Text = "";
- for (int i = 0; i < val.Length; i++)
- {
- bool flag8 = val[i] == '\r' || val[i] == '\u0003';
- if (flag8)
- {
-
- val.Remove(i);
- val.Insert(i, "\n");
- }
- bool flag9 = this.onValidateInput != null;
- if (flag9)
- {
-
- char c = val[i];
- val.Remove(i);
- val.Insert(i, this.onValidateInput(this.m_Text, this.m_Text.Length, c).ToString());
- }
- else
- {
- bool flag10 = this.characterValidation > UGUI_SCInputField.CharacterValidation.None;
- if (flag10)
- {
-
- char c = val[i];
- val.Remove(i);
- val.Insert(i, this.Validate(this.m_Text, this.m_Text.Length, c).ToString());
- }
- }
- bool flag11 = this.lineType == UGUI_SCInputField.LineType.MultiLineSubmit && val[i] == '\n';
- if (flag11)
- {
- this.m_Keyboard.text = this.m_Text;
- this.OnDeselect(null);
- return;
- }
- bool flag12 = val[i] > '\0';
- if (flag12)
- {
- this.m_Text += val[i].ToString();
- }
- }
- bool flag13 = this.characterLimit > 0 && this.m_Text.Length > this.characterLimit;
- if (flag13)
- {
- this.m_Text = this.m_Text.Substring(0, this.characterLimit);
- }
- bool canGetSelection = this.m_Keyboard.canGetSelection;
- if (canGetSelection)
- {
- this.UpdateCaretFromKeyboard();
- }
- else
- {
- this.caretPositionInternal = (this.caretSelectPositionInternal = this.m_Text.Length);
- }
- bool flag14 = this.m_Text != val;
- if (flag14)
- {
- this.m_Keyboard.text = this.m_Text;
- }
- this.SendOnValueChangedAndUpdateLabel();
- }
- }
- else
- {
- bool flag15 = this.m_HideMobileInput && this.m_Keyboard.canSetSelection;
- if (flag15)
- {
- this.m_Keyboard.selection = new RangeInt(this.caretPositionInternal, this.caretSelectPositionInternal - this.caretPositionInternal);
- }
- else
- {
- bool flag16 = this.m_Keyboard.canGetSelection && !this.m_HideMobileInput;
- if (flag16)
- {
- this.UpdateCaretFromKeyboard();
- }
- }
- }
- #if SCKeyboard
- bool flag17 = this.m_Keyboard.status > SCKeyboard.Status.Visible;
- #elif TouchScreenKeyboard
- bool flag17 = this.m_Keyboard.status > TouchScreenKeyboard.Status.Visible;
- #endif
- if (flag17)
- {
- #if SCKeyboard
- bool flag18 = this.m_Keyboard.status == SCKeyboard.Status.Canceled;
- #elif TouchScreenKeyboard
- bool flag18 = this.m_Keyboard.status == TouchScreenKeyboard.Status.Canceled;
- #endif
- if (flag18)
- {
- this.m_WasCanceled = true;
- }
- this.OnDeselect(null);
- }
- }
- }
- #region SCKeyboard
- if (m_Keyboard != null && m_Keyboard.status > 0 && EventSystem.current.currentSelectedGameObject != this.gameObject)
- {
- this.m_ShouldDeactivateNextUpdate = true;
- }
- bool shouldDeactivateNextUpdate = this.m_ShouldDeactivateNextUpdate;
- if (shouldDeactivateNextUpdate)
- {
- OnDeselect(null);
- this.m_ShouldDeactivateNextUpdate = false;
- }
- #endregion
- }
- protected override bool MayDrag(PointerEventData eventData)
- {
- return this.IsActive() &&
- this.IsInteractable() &&
- eventData.button == PointerEventData.InputButton.Left &&
- this.m_TextComponent != null &&
- (this.InPlaceEditing() || this.m_HideMobileInput);
- }
- protected override IEnumerator MouseDragOutsideRect(PointerEventData eventData)
- {
- while (this.m_UpdateDrag && this.m_DragPositionOutOfBounds)
- {
- Vector2 localMousePos;
- RectTransformUtility.ScreenPointToLocalPointInRectangle(this.textComponent.rectTransform, eventData.position, eventData.pressEventCamera, out localMousePos);
- Rect rect = this.textComponent.rectTransform.rect;
- bool multiLine = this.multiLine;
- if (multiLine)
- {
- bool flag = localMousePos.y > rect.yMax;
- if (flag)
- {
- this.MoveUp(true, true);
- }
- else
- {
- bool flag2 = localMousePos.y < rect.yMin;
- if (flag2)
- {
- this.MoveDown(true, true);
- }
- }
- }
- else
- {
- bool flag3 = localMousePos.x < rect.xMin;
- if (flag3)
- {
- this.MoveLeft(true, false);
- }
- else
- {
- bool flag4 = localMousePos.x > rect.xMax;
- if (flag4)
- {
- this.MoveRight(true, false);
- }
- }
- }
- this.UpdateLabel();
- float delay = this.multiLine ? 0.1f : 0.05f;
- bool flag5 = this.m_WaitForSecondsRealtime == null;
- if (flag5)
- {
- this.m_WaitForSecondsRealtime = new WaitForSecondsRealtime(delay);
- }
- else
- {
- this.m_WaitForSecondsRealtime.waitTime = delay;
- }
- yield return this.m_WaitForSecondsRealtime;
- localMousePos = default(Vector2);
- rect = default(Rect);
- }
- this.m_DragCoroutine = null;
- yield break;
- }
- public override void OnPointerDown(PointerEventData eventData)
- {
- bool flag = !this.MayDrag(eventData);
- if (!flag)
- {
- EventSystem.current.SetSelectedGameObject(base.gameObject, eventData);
- bool hadFocusBefore = this.m_AllowInput;
- base.OnPointerDown(eventData);
- bool flag2 = !this.InPlaceEditing();
- if (flag2)
- {
- bool flag3 = this.m_Keyboard == null || !this.m_Keyboard.active;
- if (flag3)
- {
- this.OnSelect(eventData);
- return;
- }
- }
- bool flag4 = hadFocusBefore;
- if (flag4)
- {
- Vector2 localMousePos;
- RectTransformUtility.ScreenPointToLocalPointInRectangle(this.textComponent.rectTransform, eventData.position, eventData.pressEventCamera, out localMousePos);
- this.caretSelectPositionInternal = (this.caretPositionInternal = this.GetCharacterIndexFromPosition(localMousePos) + this.m_DrawStart);
- }
- this.UpdateLabel();
- eventData.Use();
- }
- }
- protected override UGUI_SCInputField.EditState KeyPressed(Event evt)
- {
- EventModifiers currentEventModifiers = evt.modifiers;
- bool ctrl = (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX) ? (((int)currentEventModifiers & 8) > 0) : (((int)currentEventModifiers & 2) > 0);
- bool shift = ((int)currentEventModifiers & 1) > 0;
- bool alt = ((int)currentEventModifiers & 4) > 0;
- bool ctrlOnly = ctrl && !alt && !shift;
- KeyCode keyCode = evt.keyCode;
- if (keyCode <= KeyCode.A)
- {
- if (keyCode <= KeyCode.Return)
- {
- if (keyCode == KeyCode.Backspace)
- {
- this.Backspace();
- return UGUI_SCInputField.EditState.Continue;
- }
- if (keyCode != KeyCode.Return)
- {
- goto IL_27D;
- }
- }
- else
- {
- if (keyCode == KeyCode.Escape)
- {
- this.m_WasCanceled = true;
- return UGUI_SCInputField.EditState.Finish;
- }
- if (keyCode != KeyCode.A)
- {
- goto IL_27D;
- }
- bool flag = ctrlOnly;
- if (flag)
- {
- this.SelectAll();
- return UGUI_SCInputField.EditState.Continue;
- }
- goto IL_27D;
- }
- }
- else if (keyCode <= KeyCode.V)
- {
- if (keyCode != KeyCode.C)
- {
- if (keyCode != KeyCode.V)
- {
- goto IL_27D;
- }
- bool flag2 = ctrlOnly;
- if (flag2)
- {
- this.Append(UGUI_SCInputField.clipboard);
- this.UpdateLabel();
- return UGUI_SCInputField.EditState.Continue;
- }
- goto IL_27D;
- }
- else
- {
- bool flag3 = ctrlOnly;
- if (flag3)
- {
- bool flag4 = this.inputType != UGUI_SCInputField.InputType.Password;
- if (flag4)
- {
- UGUI_SCInputField.clipboard = this.GetSelectedString();
- }
- else
- {
- UGUI_SCInputField.clipboard = "";
- }
- return UGUI_SCInputField.EditState.Continue;
- }
- goto IL_27D;
- }
- }
- else if (keyCode != KeyCode.X)
- {
- if (keyCode == KeyCode.Delete)
- {
- this.ForwardSpace();
- return UGUI_SCInputField.EditState.Continue;
- }
- switch (keyCode)
- {
- case KeyCode.KeypadEnter:
- break;
- case KeyCode.KeypadEquals:
- case KeyCode.Insert:
- goto IL_27D;
- case KeyCode.UpArrow:
- this.MoveUp(shift);
- return UGUI_SCInputField.EditState.Continue;
- case KeyCode.DownArrow:
- this.MoveDown(shift);
- return UGUI_SCInputField.EditState.Continue;
- case KeyCode.RightArrow:
- this.MoveRight(shift, ctrl);
- return UGUI_SCInputField.EditState.Continue;
- case KeyCode.LeftArrow:
- this.MoveLeft(shift, ctrl);
- return UGUI_SCInputField.EditState.Continue;
- case KeyCode.Home:
- this.MoveTextStart(shift);
- return UGUI_SCInputField.EditState.Continue;
- case KeyCode.End:
- this.MoveTextEnd(shift);
- return UGUI_SCInputField.EditState.Continue;
- default:
- goto IL_27D;
- }
- }
- else
- {
- bool flag5 = ctrlOnly;
- if (flag5)
- {
- bool flag6 = this.inputType != UGUI_SCInputField.InputType.Password;
- if (flag6)
- {
- UGUI_SCInputField.clipboard = this.GetSelectedString();
- }
- else
- {
- UGUI_SCInputField.clipboard = "";
- }
- this.Delete();
- this.UpdateTouchKeyboardFromEditChanges();
- this.SendOnValueChangedAndUpdateLabel();
- return UGUI_SCInputField.EditState.Continue;
- }
- goto IL_27D;
- }
- bool flag7 = this.lineType != UGUI_SCInputField.LineType.MultiLineNewline;
- if (flag7)
- {
- return UGUI_SCInputField.EditState.Finish;
- }
- IL_27D:
- char c = evt.character;
- bool flag8 = !this.multiLine && (c == '\t' || c == '\r' || c == '\n');
- UGUI_SCInputField.EditState result;
- if (flag8)
- {
- result = UGUI_SCInputField.EditState.Continue;
- }
- else
- {
- bool flag9 = c == '\r' || c == '\u0003';
- if (flag9)
- {
- c = '\n';
- }
- bool flag10 = this.IsValidChar(c);
- if (flag10)
- {
- this.Append(c);
- }
- bool flag11 = c == '\0';
- if (flag11)
- {
- bool flag12 = this.compositionString.Length > 0;
- if (flag12)
- {
- this.UpdateLabel();
- }
- }
- result = UGUI_SCInputField.EditState.Continue;
- }
- return result;
- }
- protected override bool IsValidChar(char c)
- {
- bool flag = c == '\u007f';
- bool result;
- if (flag)
- {
- result = false;
- }
- else
- {
- bool flag2 = c == '\t' || c == '\n';
- result = (flag2 || this.m_TextComponent.font.HasCharacter(c));
- }
- return result;
- }
- public override void OnUpdateSelected(BaseEventData eventData)
- {
- bool flag = !this.isFocused;
- if (!flag)
- {
- bool consumedEvent = false;
- while (Event.PopEvent(this.m_ProcessingEvent))
- {
- bool flag2 = (int)this.m_ProcessingEvent.rawType == 4;
- if (flag2)
- {
- consumedEvent = true;
- UGUI_SCInputField.EditState shouldContinue = this.KeyPressed(this.m_ProcessingEvent);
- bool flag3 = shouldContinue == UGUI_SCInputField.EditState.Finish;
- if (flag3)
- {
- this.DeactivateInputField();
- break;
- }
- }
- EventType type = this.m_ProcessingEvent.type;
- if ((int)type - 13 <= 1)
- {
- string commandName = this.m_ProcessingEvent.commandName;
- if (commandName == "SelectAll")
- {
- this.SelectAll();
- consumedEvent = true;
- }
- }
- }
- bool flag4 = consumedEvent;
- if (flag4)
- {
- this.UpdateLabel();
- }
- eventData.Use();
- }
- }
- protected override int DetermineCharacterLine(int charPos, TextGenerator generator)
- {
- for (int i = 0; i < generator.lineCount - 1; i++)
- {
- bool flag = generator.lines[i + 1].startCharIdx > charPos;
- if (flag)
- {
- return i;
- }
- }
- return generator.lineCount - 1;
- }
- protected override int LineUpCharacterPosition(int originalPos, bool goToFirstChar)
- {
- bool flag = originalPos >= this.cachedInputTextGenerator.characters.Count;
- int result;
- if (flag)
- {
- result = 0;
- }
- else
- {
- UICharInfo originChar = this.cachedInputTextGenerator.characters[originalPos];
- int originLine = this.DetermineCharacterLine(originalPos, this.cachedInputTextGenerator);
- bool flag2 = originLine <= 0;
- if (flag2)
- {
- result = (goToFirstChar ? 0 : originalPos);
- }
- else
- {
- int endCharIdx = this.cachedInputTextGenerator.lines[originLine].startCharIdx - 1;
- for (int i = this.cachedInputTextGenerator.lines[originLine - 1].startCharIdx; i < endCharIdx; i++)
- {
- bool flag3 = this.cachedInputTextGenerator.characters[i].cursorPos.x >= originChar.cursorPos.x;
- if (flag3)
- {
- return i;
- }
- }
- result = endCharIdx;
- }
- }
- return result;
- }
- protected override int LineDownCharacterPosition(int originalPos, bool goToLastChar)
- {
- bool flag = originalPos >= this.cachedInputTextGenerator.characterCountVisible;
- int result;
- if (flag)
- {
- result = this.text.Length;
- }
- else
- {
- UICharInfo originChar = this.cachedInputTextGenerator.characters[originalPos];
- int originLine = this.DetermineCharacterLine(originalPos, this.cachedInputTextGenerator);
- bool flag2 = originLine + 1 >= this.cachedInputTextGenerator.lineCount;
- if (flag2)
- {
- result = (goToLastChar ? this.text.Length : originalPos);
- }
- else
- {
- int endCharIdx = UGUI_SCInputField.GetLineEndPosition(this.cachedInputTextGenerator, originLine + 1);
- for (int i = this.cachedInputTextGenerator.lines[originLine + 1].startCharIdx; i < endCharIdx; i++)
- {
- bool flag3 = this.cachedInputTextGenerator.characters[i].cursorPos.x >= originChar.cursorPos.x;
- if (flag3)
- {
- return i;
- }
- }
- result = endCharIdx;
- }
- }
- return result;
- }
- protected override void ForwardSpace()
- {
- bool readOnly = this.m_ReadOnly;
- if (!readOnly)
- {
- bool hasSelection = this.hasSelection;
- if (hasSelection)
- {
- this.Delete();
- this.UpdateTouchKeyboardFromEditChanges();
- this.SendOnValueChangedAndUpdateLabel();
- }
- else
- {
- bool flag = this.caretPositionInternal < this.text.Length;
- if (flag)
- {
- this.m_Text = this.text.Remove(this.caretPositionInternal, 1);
- this.UpdateTouchKeyboardFromEditChanges();
- this.SendOnValueChangedAndUpdateLabel();
- }
- }
- }
- }
- protected override void Backspace()
- {
- bool readOnly = this.m_ReadOnly;
- if (!readOnly)
- {
- bool hasSelection = this.hasSelection;
- if (hasSelection)
- {
- this.Delete();
- this.UpdateTouchKeyboardFromEditChanges();
- this.SendOnValueChangedAndUpdateLabel();
- }
- else
- {
- bool flag = this.caretPositionInternal > 0;
- if (flag)
- {
- this.m_Text = this.text.Remove(this.caretPositionInternal - 1, 1);
- this.caretSelectPositionInternal = --this.caretPositionInternal;
- this.UpdateTouchKeyboardFromEditChanges();
- this.SendOnValueChangedAndUpdateLabel();
- }
- }
- }
- }
- protected override void Insert(char c)
- {
- bool readOnly = this.m_ReadOnly;
- if (!readOnly)
- {
- string replaceString = c.ToString();
- this.Delete();
- bool flag = this.characterLimit > 0 && this.text.Length >= this.characterLimit;
- if (!flag)
- {
- this.m_Text = this.text.Insert(this.m_CaretPosition, replaceString);
- this.caretSelectPositionInternal = (this.caretPositionInternal += replaceString.Length);
- this.UpdateTouchKeyboardFromEditChanges();
- this.SendOnValueChanged();
- }
- }
- }
- private void UpdateTouchKeyboardFromEditChanges()
- {
- bool flag = this.m_Keyboard != null && this.InPlaceEditing();
- if (flag)
- {
- this.m_Keyboard.text = this.m_Text;
- }
- }
- protected override void Append(string input)
- {
- bool readOnly = this.m_ReadOnly;
- if (!readOnly)
- {
- bool flag = !this.InPlaceEditing();
- if (!flag)
- {
- int i = 0;
- int imax = input.Length;
- while (i < imax)
- {
- char c = input[i];
- bool flag2 = c >= ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\n';
- if (flag2)
- {
- this.Append(c);
- }
- i++;
- }
- }
- }
- }
- protected override void Append(char input)
- {
- bool flag = char.IsSurrogate(input);
- if (!flag)
- {
- bool flag2 = this.m_ReadOnly || this.text.Length >= 16382;
- if (!flag2)
- {
- bool flag3 = !this.InPlaceEditing();
- if (!flag3)
- {
- int insertionPoint = Math.Min(this.selectionFocusPosition, this.selectionAnchorPosition);
- bool flag4 = this.onValidateInput != null;
- if (flag4)
- {
- input = this.onValidateInput(this.text, insertionPoint, input);
- }
- else
- {
- bool flag5 = this.characterValidation > UGUI_SCInputField.CharacterValidation.None;
- if (flag5)
- {
- input = this.Validate(this.text, insertionPoint, input);
- }
- }
- bool flag6 = input == '\0';
- if (!flag6)
- {
- this.Insert(input);
- }
- }
- }
- }
- }
- protected override bool IsSelectionVisible()
- {
- bool flag = this.m_DrawStart > this.caretPositionInternal || this.m_DrawStart > this.caretSelectPositionInternal;
- bool result;
- if (flag)
- {
- result = false;
- }
- else
- {
- bool flag2 = this.m_DrawEnd < this.caretPositionInternal || this.m_DrawEnd < this.caretSelectPositionInternal;
- result = !flag2;
- }
- return result;
- }
- protected override void SetDrawRangeToContainCaretPosition(int caretPos)
- {
- bool flag = this.cachedInputTextGenerator.lineCount <= 0;
- if (!flag)
- {
- Vector2 extents = this.cachedInputTextGenerator.rectExtents.size;
- bool multiLine = this.multiLine;
- if (multiLine)
- {
- IList<UILineInfo> lines = this.cachedInputTextGenerator.lines;
- int caretLine = this.DetermineCharacterLine(caretPos, this.cachedInputTextGenerator);
- bool flag2 = caretPos > this.m_DrawEnd;
- if (flag2)
- {
- this.m_DrawEnd = UGUI_SCInputField.GetLineEndPosition(this.cachedInputTextGenerator, caretLine);
- float bottomY = lines[caretLine].topY - (float)lines[caretLine].height;
- bool flag3 = caretLine == lines.Count - 1;
- if (flag3)
- {
- bottomY += lines[caretLine].leading;
- }
- int startLine;
- for (startLine = caretLine; startLine > 0; startLine--)
- {
- float topY = lines[startLine - 1].topY;
- bool flag4 = topY - bottomY > extents.y;
- if (flag4)
- {
- break;
- }
- }
- this.m_DrawStart = UGUI_SCInputField.GetLineStartPosition(this.cachedInputTextGenerator, startLine);
- }
- else
- {
- bool flag5 = caretPos < this.m_DrawStart;
- if (flag5)
- {
- this.m_DrawStart = UGUI_SCInputField.GetLineStartPosition(this.cachedInputTextGenerator, caretLine);
- }
- int startLine2 = this.DetermineCharacterLine(this.m_DrawStart, this.cachedInputTextGenerator);
- int endLine = startLine2;
- float topY2 = lines[startLine2].topY;
- float bottomY2 = lines[endLine].topY - (float)lines[endLine].height;
- bool flag6 = endLine == lines.Count - 1;
- if (flag6)
- {
- bottomY2 += lines[endLine].leading;
- }
- while (endLine < lines.Count - 1)
- {
- bottomY2 = lines[endLine + 1].topY - (float)lines[endLine + 1].height;
- bool flag7 = endLine + 1 == lines.Count - 1;
- if (flag7)
- {
- bottomY2 += lines[endLine + 1].leading;
- }
- bool flag8 = topY2 - bottomY2 > extents.y;
- if (flag8)
- {
- break;
- }
- endLine++;
- }
- this.m_DrawEnd = UGUI_SCInputField.GetLineEndPosition(this.cachedInputTextGenerator, endLine);
- while (startLine2 > 0)
- {
- topY2 = lines[startLine2 - 1].topY;
- bool flag9 = topY2 - bottomY2 > extents.y;
- if (flag9)
- {
- break;
- }
- startLine2--;
- }
- this.m_DrawStart = UGUI_SCInputField.GetLineStartPosition(this.cachedInputTextGenerator, startLine2);
- }
- }
- else
- {
- IList<UICharInfo> characters = this.cachedInputTextGenerator.characters;
- bool flag10 = this.m_DrawEnd > this.cachedInputTextGenerator.characterCountVisible;
- if (flag10)
- {
- this.m_DrawEnd = this.cachedInputTextGenerator.characterCountVisible;
- }
- float width = 0f;
- bool flag11 = caretPos > this.m_DrawEnd || (caretPos == this.m_DrawEnd && this.m_DrawStart > 0);
- if (flag11)
- {
- this.m_DrawEnd = caretPos;
- this.m_DrawStart = this.m_DrawEnd - 1;
- while (this.m_DrawStart >= 0)
- {
- bool flag12 = width + characters[this.m_DrawStart].charWidth > extents.x;
- if (flag12)
- {
- break;
- }
- width += characters[this.m_DrawStart].charWidth;
- this.m_DrawStart--;
- }
- this.m_DrawStart++;
- }
- else
- {
- bool flag13 = caretPos < this.m_DrawStart;
- if (flag13)
- {
- this.m_DrawStart = caretPos;
- }
- this.m_DrawEnd = this.m_DrawStart;
- }
- while (this.m_DrawEnd < this.cachedInputTextGenerator.characterCountVisible)
- {
- width += characters[this.m_DrawEnd].charWidth;
- bool flag14 = width > extents.x;
- if (flag14)
- {
- break;
- }
- this.m_DrawEnd++;
- }
- }
- }
- }
- #if UNITY_EDITOR
- protected override void MarkGeometryAsDirty()
- {
- bool flag = !Application.isPlaying || PrefabUtility.IsPartOfPrefabAsset(base.gameObject);
- if (!flag)
- {
- CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this);
- }
- }
- #else
- protected override void MarkGeometryAsDirty()
- {
- bool flag = !Application.isPlaying;
- if (!flag)
- {
- CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this);
- }
- }
- #endif
- protected override void UpdateGeometry()
- {
- bool flag = !Application.isPlaying;
- if (!flag)
- {
- bool flag2 = !this.shouldHideMobileInput;
- if (!flag2)
- {
- bool flag3 = this.m_CachedInputRenderer == null && this.m_TextComponent != null;
- if (flag3)
- {
- GameObject go = new GameObject(base.transform.name + " Input Caret", new Type[]
- {
- typeof(RectTransform),
- typeof(CanvasRenderer)
- });
- go.hideFlags = HideFlags.DontSave;
- go.transform.SetParent(this.m_TextComponent.transform.parent);
- go.transform.SetAsFirstSibling();
- go.layer = base.gameObject.layer;
- this.caretRectTrans = go.GetComponent<RectTransform>();
- this.m_CachedInputRenderer = go.GetComponent<CanvasRenderer>();
- this.m_CachedInputRenderer.SetMaterial(this.m_TextComponent.GetModifiedMaterial(Graphic.defaultGraphicMaterial), Texture2D.whiteTexture);
- go.AddComponent<LayoutElement>().ignoreLayout = true;
- this.AssignPositioningIfNeeded();
- }
- bool flag4 = this.m_CachedInputRenderer == null;
- if (!flag4)
- {
- this.OnFillVBO(this.mesh);
- this.m_CachedInputRenderer.SetMesh(this.mesh);
- }
- }
- }
- }
- private void GenerateHighlight(VertexHelper vbo, Vector2 roundingOffset)
- {
- int startChar = Mathf.Max(0, this.caretPositionInternal - this.m_DrawStart);
- int endChar = Mathf.Max(0, this.caretSelectPositionInternal - this.m_DrawStart);
- bool flag = startChar > endChar;
- if (flag)
- {
- int temp = startChar;
- startChar = endChar;
- endChar = temp;
- }
- endChar--;
- TextGenerator gen = this.m_TextComponent.cachedTextGenerator;
- bool flag2 = gen.lineCount <= 0;
- if (!flag2)
- {
- int currentLineIndex = this.DetermineCharacterLine(startChar, gen);
- int lastCharInLineIndex = UGUI_SCInputField.GetLineEndPosition(gen, currentLineIndex);
- UIVertex vert = UIVertex.simpleVert;
- vert.uv0 = Vector2.zero;
- vert.color = this.selectionColor;
- int currentChar = startChar;
- while (currentChar <= endChar && currentChar < gen.characterCount)
- {
- bool flag3 = currentChar == lastCharInLineIndex || currentChar == endChar;
- if (flag3)
- {
- UICharInfo startCharInfo = gen.characters[startChar];
- UICharInfo endCharInfo = gen.characters[currentChar];
- Vector2 startPosition = new Vector2(startCharInfo.cursorPos.x / this.m_TextComponent.pixelsPerUnit, gen.lines[currentLineIndex].topY / this.m_TextComponent.pixelsPerUnit);
- Vector2 endPosition = new Vector2((endCharInfo.cursorPos.x + endCharInfo.charWidth) / this.m_TextComponent.pixelsPerUnit, startPosition.y - (float)gen.lines[currentLineIndex].height / this.m_TextComponent.pixelsPerUnit);
- bool flag4 = endPosition.x > this.m_TextComponent.rectTransform.rect.xMax || endPosition.x < this.m_TextComponent.rectTransform.rect.xMin;
- if (flag4)
- {
- endPosition.x = this.m_TextComponent.rectTransform.rect.xMax;
- }
- int startIndex = vbo.currentVertCount;
- vert.position = new Vector3(startPosition.x, endPosition.y, 0f) + new Vector3(roundingOffset.x, roundingOffset.y, 0);
- vbo.AddVert(vert);
- vert.position = new Vector3(endPosition.x, endPosition.y, 0f) + new Vector3(roundingOffset.x, roundingOffset.y, 0);
- vbo.AddVert(vert);
- vert.position = new Vector3(endPosition.x, startPosition.y, 0f) + new Vector3(roundingOffset.x, roundingOffset.y, 0);
- vbo.AddVert(vert);
- vert.position = new Vector3(startPosition.x, startPosition.y, 0f) + new Vector3(roundingOffset.x, roundingOffset.y, 0);
- vbo.AddVert(vert);
- vbo.AddTriangle(startIndex, startIndex + 1, startIndex + 2);
- vbo.AddTriangle(startIndex + 2, startIndex + 3, startIndex);
- startChar = currentChar + 1;
- currentLineIndex++;
- lastCharInLineIndex = UGUI_SCInputField.GetLineEndPosition(gen, currentLineIndex);
- }
- currentChar++;
- }
- }
- }
- protected override char Validate(string text, int pos, char ch)
- {
- bool flag = this.characterValidation == UGUI_SCInputField.CharacterValidation.None || !base.enabled;
- char result;
- if (flag)
- {
- result = ch;
- }
- else
- {
- bool flag2 = this.characterValidation == UGUI_SCInputField.CharacterValidation.Integer || this.characterValidation == UGUI_SCInputField.CharacterValidation.Decimal;
- if (flag2)
- {
- bool cursorBeforeDash = pos == 0 && text.Length > 0 && text[0] == '-';
- bool dashInSelection = text.Length > 0 && text[0] == '-' && ((this.caretPositionInternal == 0 && this.caretSelectPositionInternal > 0) || (this.caretSelectPositionInternal == 0 && this.caretPositionInternal > 0));
- bool selectionAtStart = this.caretPositionInternal == 0 || this.caretSelectPositionInternal == 0;
- bool flag3 = !cursorBeforeDash || dashInSelection;
- if (flag3)
- {
- bool flag4 = ch >= '0' && ch <= '9';
- if (flag4)
- {
- return ch;
- }
- bool flag5 = ch == '-' && (pos == 0 || selectionAtStart);
- if (flag5)
- {
- return ch;
- }
- bool flag6 = (ch == '.' || ch == ',') && this.characterValidation == UGUI_SCInputField.CharacterValidation.Decimal && text.IndexOfAny(new char[]
- {
- '.',
- ','
- }) == -1;
- if (flag6)
- {
- return ch;
- }
- }
- }
- else
- {
- bool flag7 = this.characterValidation == UGUI_SCInputField.CharacterValidation.Alphanumeric;
- if (flag7)
- {
- bool flag8 = ch >= 'A' && ch <= 'Z';
- if (flag8)
- {
- return ch;
- }
- bool flag9 = ch >= 'a' && ch <= 'z';
- if (flag9)
- {
- return ch;
- }
- bool flag10 = ch >= '0' && ch <= '9';
- if (flag10)
- {
- return ch;
- }
- }
- else
- {
- bool flag11 = this.characterValidation == UGUI_SCInputField.CharacterValidation.Name;
- if (flag11)
- {
- bool flag12 = char.IsLetter(ch);
- if (flag12)
- {
- bool flag13 = char.IsLower(ch) && (pos == 0 || text[pos - 1] == ' ');
- if (flag13)
- {
- return char.ToUpper(ch);
- }
- bool flag14 = char.IsUpper(ch) && pos > 0 && text[pos - 1] != ' ' && text[pos - 1] != '\'';
- if (flag14)
- {
- return char.ToLower(ch);
- }
- return ch;
- }
- else
- {
- bool flag15 = ch == '\'';
- if (flag15)
- {
- bool flag16 = !text.Contains("'");
- if (flag16)
- {
- bool flag17 = (pos <= 0 || (text[pos - 1] != ' ' && text[pos - 1] != '\'')) && (pos >= text.Length || (text[pos] != ' ' && text[pos] != '\''));
- if (flag17)
- {
- return ch;
- }
- }
- }
- bool flag18 = ch == ' ';
- if (flag18)
- {
- bool flag19 = pos != 0;
- if (flag19)
- {
- bool flag20 = (pos <= 0 || (text[pos - 1] != ' ' && text[pos - 1] != '\'')) && (pos >= text.Length || (text[pos] != ' ' && text[pos] != '\''));
- if (flag20)
- {
- return ch;
- }
- }
- }
- }
- }
- else
- {
- bool flag21 = this.characterValidation == UGUI_SCInputField.CharacterValidation.EmailAddress;
- if (flag21)
- {
- bool flag22 = ch >= 'A' && ch <= 'Z';
- if (flag22)
- {
- return ch;
- }
- bool flag23 = ch >= 'a' && ch <= 'z';
- if (flag23)
- {
- return ch;
- }
- bool flag24 = ch >= '0' && ch <= '9';
- if (flag24)
- {
- return ch;
- }
- bool flag25 = ch == '@' && text.IndexOf('@') == -1;
- if (flag25)
- {
- return ch;
- }
- bool flag26 = "!#$%&'*+-/=?^_`{|}~".IndexOf(ch) != -1;
- if (flag26)
- {
- return ch;
- }
- bool flag27 = ch == '.';
- if (flag27)
- {
- char lastChar = (text.Length > 0) ? text[Mathf.Clamp(pos, 0, text.Length - 1)] : ' ';
- char nextChar = (text.Length > 0) ? text[Mathf.Clamp(pos + 1, 0, text.Length - 1)] : '\n';
- bool flag28 = lastChar != '.' && nextChar != '.';
- if (flag28)
- {
- return ch;
- }
- }
- }
- }
- }
- }
- result = '\0';
- }
- return result;
- }
- public override void ActivateInputField()
- {
- bool flag = this.m_TextComponent == null || this.m_TextComponent.font == null || !this.IsActive() || !this.IsInteractable();
- if (!flag)
- {
- bool isFocused = this.isFocused;
- if (isFocused)
- {
- bool flag2 = this.m_Keyboard != null && !this.m_Keyboard.active;
- if (flag2)
- {
- this.m_Keyboard.active = true;
- this.m_Keyboard.text = this.m_Text;
- }
- }
- this.m_ShouldActivateNextUpdate = true;
- }
- }
- protected override void ActivateInputFieldInternal()
- {
- bool flag = EventSystem.current == null;
- if (!flag)
- {
- bool flag2 = EventSystem.current.currentSelectedGameObject != base.gameObject;
- if (flag2)
- {
- EventSystem.current.SetSelectedGameObject(base.gameObject);
- }
- #if SCKeyboard
- bool isSupported = SCKeyboard.isSupported;
- #elif TouchScreenKeyboard
- bool isSupported = TouchScreenKeyboard.isSupported;
- #endif
- if (isSupported)
- {
- bool touchSupported = this.input.touchSupported;
- if (touchSupported)
- {
- #if SCKeyboard
- SCKeyboard.hideInput = this.shouldHideMobileInput;
- #elif TouchScreenKeyboard
- TouchScreenKeyboard.hideInput = this.shouldHideMobileInput;
- #endif
- }
- #if SCKeyboard
-
- m_Keyboard = SetKeyboardTransform();
-
- SetKeyboardOrderInLayer(m_OrderInLayer);
-
- SetKeyboardRegistEvents(m_Keyboard);
-
- this.m_TouchKeyboardAllowsInPlaceEditing = SCKeyboard.isInPlaceEditingAllowed;
- #elif TouchScreenKeyboard
- this.m_Keyboard = ((this.inputType == UGUI_SCInputField.InputType.Password) ? TouchScreenKeyboard.Open(this.m_Text, this.keyboardType, false, this.multiLine, true, false, "", this.characterLimit) : TouchScreenKeyboard.Open(this.m_Text, this.keyboardType, this.inputType == UGUI_SCInputField.InputType.AutoCorrect, this.multiLine, false, false, "", this.characterLimit));
- this.m_TouchKeyboardAllowsInPlaceEditing = TouchScreenKeyboard.isInPlaceEditingAllowed;
- #endif
- this.MoveTextEnd(false);
- }
- else
- {
- this.input.imeCompositionMode = IMECompositionMode.On;
- this.OnFocus();
- }
- this.m_AllowInput = true;
- this.m_OriginalText = this.text;
- this.m_WasCanceled = false;
- this.SetCaretVisible();
- this.UpdateLabel();
- }
- }
- public override void OnPointerClick(PointerEventData eventData)
- {
- bool flag = eventData.button > PointerEventData.InputButton.Left;
- if (!flag)
- {
- this.ActivateInputField();
- }
- }
- public override void DeactivateInputField()
- {
- bool flag = !this.m_AllowInput;
- if (!flag)
- {
- this.m_HasDoneFocusTransition = false;
- this.m_AllowInput = false;
- bool flag2 = this.m_Placeholder != null;
- if (flag2)
- {
- this.m_Placeholder.enabled = string.IsNullOrEmpty(this.m_Text);
- }
- bool flag3 = this.m_TextComponent != null && this.IsInteractable();
- if (flag3)
- {
- bool wasCanceled = this.m_WasCanceled;
- if (wasCanceled)
- {
- this.text = this.m_OriginalText;
- }
- this.SendOnSubmit();
- bool flag4 = this.m_Keyboard != null;
- if (flag4)
- {
- this.m_Keyboard.active = false;
- this.m_Keyboard = null;
- }
- this.m_CaretPosition = (this.m_CaretSelectPosition = 0);
- if (this.input != null) this.input.imeCompositionMode = IMECompositionMode.Auto;
- }
- this.MarkGeometryAsDirty();
- }
- }
- public override void OnDeselect(BaseEventData eventData)
- {
- if (shouldDeactivateOnDeselect)
- {
-
- base.OnDeselect(eventData);
- }
- }
- protected override void DoStateTransition(Selectable.SelectionState state, bool instant)
- {
- bool hasDoneFocusTransition = this.m_HasDoneFocusTransition;
- if (hasDoneFocusTransition)
- {
- state = Selectable.SelectionState.Selected;
- }
- else
- {
- bool flag = state == Selectable.SelectionState.Pressed;
- if (flag)
- {
- this.m_HasDoneFocusTransition = true;
- }
- }
- base.DoStateTransition(state, instant);
- }
-
-
-
-
- #if SCKeyboard
- protected new SCKeyboard m_Keyboard;
- #elif TouchScreenKeyboard
- protected TouchScreenKeyboard m_Keyboard;
- #endif
- private bool m_ShouldDeactivateNextUpdate = false;
- private WaitForSecondsRealtime m_WaitForSecondsRealtime;
- private bool m_TouchKeyboardAllowsInPlaceEditing = false;
- private const int k_MaxTextLength = 16382;
- #region SCKeyboard
- [SerializeField]
- public SCKeyboardType m_SCKeyboardType = SCKeyboardType.Default;
- [SerializeField]
- public SCKeyboardSpaceEnum m_SCKeyboardSpaceEnum = SCKeyboardSpaceEnum.WorldSpace;
- [SerializeField]
- protected float m_CustomDistance = 1.0f;
- [SerializeField]
- protected Vector2 m_CustomOffset = Vector2.down * 0.2f;
- [SerializeField]
- protected bool m_UseCustomOrderInLayer = false;
- [SerializeField]
- protected int m_OrderInLayer = 10;
- #endregion
- public void SetKeyboardLocalTransform(Vector3 position, Quaternion rotation, Vector3 localScale)
- {
- m_UseCustomTransform = true;
- m_SCKeyboardSpaceEnum = SCKeyboardSpaceEnum.LocalSpace;
- m_CustomPosition = position;
- m_CustomRotation = rotation.eulerAngles;
- m_CustomLocalScale = localScale;
- ResetKeyboardTransform();
- }
- public void SetKeyboardWorldTransform(Vector3 position, Quaternion rotation, Vector3 localScale)
- {
- m_UseCustomTransform = true;
- m_SCKeyboardSpaceEnum = SCKeyboardSpaceEnum.WorldSpace;
- m_CustomPosition = position;
- m_CustomRotation = rotation.eulerAngles;
- m_CustomLocalScale = localScale;
- ResetKeyboardTransform();
- }
- public void SetKeyboardOriginTransform(float distance, Vector2 offset, Quaternion rotation, Vector3 localScale)
- {
- m_UseCustomTransform = true;
- m_SCKeyboardSpaceEnum = SCKeyboardSpaceEnum.OriginSpace;
- m_CustomDistance = distance;
- m_CustomOffset = offset;
- m_CustomRotation = rotation.eulerAngles;
- m_CustomLocalScale = localScale;
- ResetKeyboardTransform();
- }
- public virtual void ResetKeyboardTransform()
- {
- if (m_Keyboard != null)
- {
- SetKeyboardTransform();
- }
- }
- private SCKeyboard SetKeyboardTransform()
- {
- Debug.Log("SetKeyboardTransformSetKeyboardTransformSetKeyboardTransform");
- SCKeyboard scKeyboard;
- Vector3 position = Vector3.zero;
- Quaternion rotation = Quaternion.identity;
- Vector3 localScale = Vector3.one;
- GetKeyboardTransform(ref position, ref rotation, ref localScale);
- scKeyboard = SCKeyboard.Open(this.scKeyboardEnum, m_Text, this.scKeyboardType, position, rotation, localScale);
- scKeyboard.transform.SetParent(this.transform);
- return scKeyboard;
- }
- private void SetKeyboardRegistEvents(SCKeyboard scKeyboard)
- {
- scKeyboard.Clear();
- scKeyboard.RegisterOnKeyClickEvent((str) => { Append(str); this.UpdateLabel(); });
- scKeyboard.RegisterOnSpecialKeyClickEvent(Module_Keyboard.SpecialKeyEnum.Delete, Backspace);
- }
- private void GetKeyboardTransform(ref Vector3 position, ref Quaternion rotation, ref Vector3 localScale)
- {
- Transform head = Camera.main.transform.transform;
- if (m_UseCustomTransform)
- {
- switch (m_SCKeyboardSpaceEnum)
- {
- case SCKeyboardSpaceEnum.OriginSpace:
- Vector3 direction = Vector3.ProjectOnPlane(head.forward, Vector3.up);
- position = head.position + direction * m_CustomDistance + (Vector3)m_CustomOffset;
- rotation = Quaternion.AngleAxis(head.rotation.eulerAngles.y, Vector3.up) * Quaternion.Euler(m_CustomRotation);
- localScale = m_CustomLocalScale;
- break;
- case SCKeyboardSpaceEnum.WorldSpace:
- case SCKeyboardSpaceEnum.LocalSpace:
- position = m_CustomPosition;
- rotation = Quaternion.Euler(m_CustomRotation);
- localScale = m_CustomLocalScale;
- break;
- }
- }
- else
- {
- Vector3 direction = Vector3.ProjectOnPlane(head.forward, Vector3.up);
- position = head.position + direction * 1 + Vector3.down * 0.2f;
- rotation = Quaternion.AngleAxis(head.rotation.eulerAngles.y, Vector3.up) * Quaternion.Euler(Vector3.right * 30);
- localScale = Vector3.one;
- }
- }
- private void SetKeyboardOrderInLayer(int value)
- {
- switch (m_SCKeyboardEnum)
- {
- case SCKeyboardEnum.SCKeyboard2D:
- Canvas canvas = m_Keyboard.transform.GetComponentInChildren<Canvas>();
- canvas.overrideSorting = true;
- canvas.sortingOrder = value;
- break;
- case SCKeyboardEnum.SCKeyboard3D:
- break;
- }
- }
- }
- #region SCKeyboard
- [Serializable]
- public enum SCKeyboardSpaceEnum
- {
- OriginSpace = 0,
- WorldSpace = 1,
- LocalSpace = 2
- }
- #endregion
- }
|