2014-09-10 27 views
0

我在Unity3D中使用NGUI工具包來構建進度條。 UISlider腳本具有範圍從0到1的值來控制滑塊。在Unity3D中構建2DTerrain

我的腳本是在同一個對象上,我用這種方式根據時間(60秒)設置它的值。

this.gameObject.GetComponent()。sliderValue = _______;

但它沒有完成。請幫助我。

回答

1

你是不是要求的正確類型UISlider

this.gameObject.GetComponent<UISlider>().sliderValue= _______ ; 

順便說一下這是很好的做法,假設任何事情,你得到可能返回一個空(畢竟你可能沒有足夠的部件裝配),因此它會更好:

UISlider lMySlider= this.gameObject.GetComponent<UISlider>(); 
if(lMySlider!=null) 
{ 
    lMySlider..sliderValue= _______ ; 
} 
else 
{ 
    Debug.Log (this.gameObject.name " is missing the UISlider") 
}