1
NGUI 3 Support / Re: Scrollable text Area
« on: April 16, 2014, 02:12:37 AM »
Thank's
In general i prefer avoid to modify directly your code, to avoid reimplementing changes at every ngui updates. I hope that in future NGUI release mCaret will'be accessible.
For now I'm accessing caret in this way
And get caret limit
Calculate ScrollView limit
At every key press I execute this method.
I simply look if caret is outside bounds area, and i move scroll for the difference between bounds area limit and cursor position.It's quite rudimental, but seems it works. Is it in your roadmap implements this kind of component in future NGUI release?
In general i prefer avoid to modify directly your code, to avoid reimplementing changes at every ngui updates. I hope that in future NGUI release mCaret will'be accessible.
For now I'm accessing caret in this way
- UITexture findCaret ()[
- {
- UITexture caretTexture = null;
- UITexture[] cs = label.GetComponentsInChildren<UITexture> ();
- foreach (UITexture c in cs) {
- if (c.name == "Input Caret") {
- caretTexture = c;
- break;
- }
- }
- return caretTexture;
- }
- void CalcCaretLimit(UITexture caret)
- {
- MaxCaretX = float.MinValue;
- MinCaretX = float.MaxValue;
- MaxCaretY = float.MaxValue;
- MinCaretY = float.MinValue;
- foreach (Vector3 v in caret.geometry.verts) {
- if (v.x > MaxCaretX) {
- MaxCaretX = v.x;
- }
- if (v.x < MinCaretX) {
- MinCaretX = v.x;
- }
- if (v.y > MinCaretY) {
- MinCaretY = v.y;
- }
- if (v.y < MaxCaretY) {
- MaxCaretY = v.y;
- }
- }
- }
- void CalcScrollViewLimit ()
- {
- minclipX = scrollViewPanel.clipOffset.x - initialOffsetX;
- maxClipX = (minclipX + scrollViewPanel.finalClipRegion.z);
- minclipY = scrollViewPanel.clipOffset.y - initialOffsetY;
- maxClipY = minclipY + (scrollViewPanel.finalClipRegion.w * -1);
- }
- void UpdateScroll ()
- {
- UITexture caret = findCaret ();
- CalcCaretLimit (caret);
- if (MaxCaretX != float.MinValue) {
- CalcScrollViewLimit ();
- if (MaxCaretX > minclipX && MaxCaretX < maxClipX) {
- // inside scroll area
- } else {
- if (MaxCaretX > maxClipX) {
- } else if (MinCaretX < minclipX) {
- }
- }
- if (MaxCaretY > minclipY && MaxCaretY < maxClipY) {
- // inside scroll area
- } else {
- if (MaxCaretY < maxClipY) {
- } else if (MinCaretY > minclipY) {
- }
- }
- }
- scroll.UpdateScrollbars (true);
- }
