Open ValentinKalchev opened 11 years ago
I manage to add text to UIScrollableVerticalLayout, is not the best solution, and I dont know how to change the horientation of the text inside the UIScrollableVerticalLayout.
string instructionHdr="Finally some \ntext. Oops, there's \nbleeding. Need to \nfix the \ntexture map.";
var font1 = new UIText(text,"centuryGothic","centuryGothic.png");
var textSize = font1.sizeForText( instructionHdr );
var x = UIRelative.xPercentFrom( UIxAnchor.Left, .1f , .0f); //0.1f = 10% from Left
var y = UIRelative.yPercentFrom( UIyAnchor.Top, .05f , .0f ); //0.5f = 5% from Top
UITextInstance txt1 = font1.addTextInstance( instructionHdr, x, y,1f,0,Color.white,UITextAlignMode.Left,UITextVerticalAlignMode.Top );
var scrollable = new UIScrollableVerticalLayout( 5 );
text.addToTouchables(scrollable);
int textLenght=txt1.textSprites.Count;
UISprite[] children=new UISprite[textLenght];
for(int c=0;c<textLenght;c++){
children[c]=txt1.textSprites[c];
scrollable.addChild(children[c]);
}
scrollable.positionFromBottom(0.7f);
scrollable.setSize(Screen.width, Screen.height - 10);
I have a problem adding UIText to UIScrollableVerticalLayout and scrolling it. I assign the parentUI to be my scrollable variable - text is shown but it doesn't scroll. What is the best way to implement this? There is an example with UITouchableSprite and buttons but that doesn't help as UIText is not touchable and therefore it never calls onTouchMoved() in UIScrollableVerticalLayout class.
scrollable = new UIScrollableVerticalLayout(10); scrollable.alignMode = UIAbstractContainer.UIContainerAlignMode.Left; scrollable.position = new Vector3(Screen.width*(CameraNavigation.mainCameraNormalizedViewPortRect.width + 0.05f), -50, 0 );
//Reading data from resource .txt and assigning it to lines variable
for(int i = 0; i<lines.Length;i++) { var countryInfoText = textType.addTextInstance(lines[i],Screen.width* 0.05f,textSize, 0.4f, -1,Color.white,UITextAlignMode.Center, UITextVerticalAlignMode.Middle );
}