BBGamelib.CCLabelTTF.updateTexture C# (CSharp) Method

updateTexture() protected method

protected updateTexture ( ) : bool
return bool
		protected bool updateTexture()
		{				
			if (FloatUtils.EQ(_dimensions.x , 0) || FloatUtils.EQ(_dimensions.y , 0)) {
				_content.mesh.text = _text;
				Bounds localBounds = getLocalbounds();
				Vector2 textSize = ccUtils.UnitsToPixels (localBounds.size);
				this.contentSize = textSize;
			} else {
				string finalText = "";
				string originalText = _text;
				int preEmptyCharIndex = -1;
				for(int i=1; i<=originalText.Length; i++){
					char c = originalText[i-1];
					if(char.IsWhiteSpace(c)){
						preEmptyCharIndex = i-1;
					}
					string tmpStr = originalText.Substring(0, i);
					if(c == '\n'){
						finalText += tmpStr;
						originalText = originalText.Substring(i);
						i = 0;
					}

					_content.mesh.text = tmpStr;
					Bounds localBounds = getLocalbounds();
					Vector2 csize = ccUtils.UnitsToPixels (localBounds.size);
					if(FloatUtils.Big(csize.x , _dimensions.x)){
						if(preEmptyCharIndex==-1)
							tmpStr = originalText.Substring(0, i);
						else{
							tmpStr = originalText.Substring(0, preEmptyCharIndex);
							i = preEmptyCharIndex + 1;
							preEmptyCharIndex = -1;
						}
						finalText += tmpStr;
						if(i<originalText.Length){
							finalText += "\n";
							originalText = originalText.Substring(i);
							i = 0;
						}
					}else if(i==originalText.Length){
						tmpStr = originalText.Substring(0, i);
						finalText += tmpStr;
						break;
					}

//					string tmpStr = originalText.Substring(0, i);
//					_content.mesh.text = tmpStr;
//					Vector2 csize = _content.renderer.bounds.size;
//					csize = ccUtils.UnitsToPixels(csize);
//					if(FloatUtils.Small(csize.x , _dimensions.x) || i==1){
//						tmpStr = originalText.Substring(0, i);
//						finalText += tmpStr;
//						if(i<originalText.Length){
//							finalText += "\n";
//							originalText = originalText.Substring(i);
//							i = originalText.Length+1;
//						}else{
//							break;
//						}
//					}
				}
				_content.mesh.text = finalText;
				this.contentSize = _dimensions;
			}
			_isContentDirty = true;
			
			return true;
		}