2014-04-30 27 views
0

我有以下GUI.Label不能正常工作

GUI.Label(new Rect(3, 60, 150, 20), "No-speed circle radious: " + PlayerController.circleradious.ToString()); 

但只有No-speed circle radious:是屏幕

上,即使我做

GUI.Label(new Rect(3, 60, 150, 20), "No-speed circle radious: " + 100); 

是一樣的。我不明白我的錯誤是什麼。

所有代碼:

if (GUIEnabled) 
     { 
      GUI.Box(new Rect(0, 0, 550, 150), "Movement type : " + movementlabel); 
      GUI.Label(new Rect(3, 20, 150, 20), "Speed Factor: " + PlayerController.speedFactor.ToString()); 
      PlayerController.speedFactor = GUI.HorizontalSlider(new Rect(160, 25, 350, 20), PlayerController.speedFactor, 0.0F, 100F); 
      GUI.Label(new Rect(3, 40, 150, 20), "Velocity: " + (player.rigidbody.velocity.magnitude).ToString()); 
      if((PlayerController.movement == PlayerController.MoveType.KinectMovement)|| (PlayerController.movement == PlayerController.MoveType.KeyboardMovement)){ 
       GUI.Label(new Rect(3, 60, 150, 20), "Rotation Factor: " + PlayerController.rotationFactor.ToString()); 
       PlayerController.rotationFactor = GUI.HorizontalSlider(new Rect(160, 65, 350, 20), PlayerController.rotationFactor, 0.0F, 1000F); 
       GUI.Label(new Rect(3, 80, 150, 20), "Angular Velocity: " + (player.rigidbody.angularVelocity.magnitude).ToString()); 
      } 
      else if (PlayerController.movement == PlayerController.MoveType.CenterPointKinectWithoutHands) { 
       GUI.Label(new Rect(3, 60, 150, 20), "No-speed circle radious: " + PlayerController.circleradious.ToString()); 
       print(PlayerController.circleradious); 
       //PlayerController.circleradious = GUI.HorizontalSlider(new Rect(160, 65, 350, 20), PlayerController.circleradious, 0.0F, 20F); 
      } 
      GUI.Label(new Rect(3, 100, 150, 20), "Camera distance: " + mainCamera.transform.position.y); 
      mainCamera.transform.position = new Vector3(mainCamera.transform.position.x, GUI.HorizontalSlider(new Rect(160, 105, 350, 20), mainCamera.transform.position.y, 0.0F, 100F), mainCamera.transform.position.z); 
     } 

其他GUI.Label工作完美。

+0

你有沒有試過,返回功能該參數的字符串,例如string.Concat(「No-speed circle radious:」,PlayerController.circleradious.ToString())or string.Format(「No-speed circle radious:{0}」,PlayerController.circleradious.ToString())? – barrick

+0

看起來很好。座標是否顯示在屏幕上?或者它隱藏在某個地方的背景中?更改座標並重試。 – Raptor

+1

我是唯一一個認爲150px太短而無法顯示整個信息的人? –

回答

1

這可能是您的矩形是太小,請嘗試以下:

GUI.Label(new Rect(3, 60, 500, 20), ...); 


GUI.Label(new Rect(3, 60, 150, 200), ...); 

,並設置

GUIStyle.wordWrap = true;