新手学unity,unity中c#脚本问题,求高手帮助
usingUnityEngine;usingSystem.Collections;publicclassNewBehaviourScript:MonoBehaviour{...
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
string str;
Texture imageTexture;
private int imageWidth;
private int imageHeight;
private int screenWidth;
private int screenHeight;
// Use this for initialization
void Start () {
screenWidth=Screen.width;
screenHeight=Screen.height;
imageWidth=imageTexture.width;
imageHeight=imageTexture.height;
}
// Update is called once per frame
void OnGUI () {
UnityEngine.GUI.Label(new Rect(100,10,100,30),str);
UnityEngine.GUI.Label(new Rect(100,40,100,30),"当前屏幕宽:{0}",screenWidth);
UnityEngine.GUI.Label(new Rect(100,80,100,30),"当前屏幕高:{0}",screenHeight);
UnityEngine.GUI.Label(new Rect(100,120,0,0),imageWidth,imageHeight,imageTexture);
}
}
错误提示Assets/NewBehaviourScript.cs(22,33): error CS1502: The best overloaded method match for `UnityEngine.GUI.Label(UnityEngine.Rect, string, UnityEngine.GUIStyle)' has some invalid arguments
Assets/NewBehaviourScript.cs(22,33): error CS1503: Argument `#3' cannot convert `int' expression to type `UnityEngine.GUIStyle'
Assets/NewBehaviourScript.cs(23,33): error CS1502: The best overloaded method match for `UnityEngine.GUI.Label(UnityEngine.Rect, string, UnityEngine.GUIStyle)' has some invalid arguments
Assets/NewBehaviourScript.cs(23,33): error CS1503: Argument `#3' cannot convert `int' expression to type `UnityEngine.GUIStyle'
Assets/NewBehaviourScript.cs(24,33): error CS1501: No overload for method `Label' takes `4' arguments 展开
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
string str;
Texture imageTexture;
private int imageWidth;
private int imageHeight;
private int screenWidth;
private int screenHeight;
// Use this for initialization
void Start () {
screenWidth=Screen.width;
screenHeight=Screen.height;
imageWidth=imageTexture.width;
imageHeight=imageTexture.height;
}
// Update is called once per frame
void OnGUI () {
UnityEngine.GUI.Label(new Rect(100,10,100,30),str);
UnityEngine.GUI.Label(new Rect(100,40,100,30),"当前屏幕宽:{0}",screenWidth);
UnityEngine.GUI.Label(new Rect(100,80,100,30),"当前屏幕高:{0}",screenHeight);
UnityEngine.GUI.Label(new Rect(100,120,0,0),imageWidth,imageHeight,imageTexture);
}
}
错误提示Assets/NewBehaviourScript.cs(22,33): error CS1502: The best overloaded method match for `UnityEngine.GUI.Label(UnityEngine.Rect, string, UnityEngine.GUIStyle)' has some invalid arguments
Assets/NewBehaviourScript.cs(22,33): error CS1503: Argument `#3' cannot convert `int' expression to type `UnityEngine.GUIStyle'
Assets/NewBehaviourScript.cs(23,33): error CS1502: The best overloaded method match for `UnityEngine.GUI.Label(UnityEngine.Rect, string, UnityEngine.GUIStyle)' has some invalid arguments
Assets/NewBehaviourScript.cs(23,33): error CS1503: Argument `#3' cannot convert `int' expression to type `UnityEngine.GUIStyle'
Assets/NewBehaviourScript.cs(24,33): error CS1501: No overload for method `Label' takes `4' arguments 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
1个回答
展开全部
函数重载方法错了 ,给你官方的脚本手册关于这个函数的
static function Label (position : Rect, text : string) : void
static
function Label (position : Rect, image : Texture) : void
static function
Label (position : Rect,
content : GUIContent) :
void
static function Label (position : Rect, text : string, style : GUIStyle) : void
static function
Label (position : Rect,
image : Texture, style :
GUIStyle) : void
static function
Label (position : Rect,
content : GUIContent,
style : GUIStyle) : void
它只有这几种重载形式……再给你说下各个参数的意思
position
标签使用的在屏幕上矩形的位置
text
在标签上显示的文本
image
在标签上显示的纹理
content
在标签上显示的文本,图片和信息提示
style
使用样式,如果不使用那么,标签样式应用当前的GUISKin皮肤。
希望能帮到你
static function Label (position : Rect, text : string) : void
static
function Label (position : Rect, image : Texture) : void
static function
Label (position : Rect,
content : GUIContent) :
void
static function Label (position : Rect, text : string, style : GUIStyle) : void
static function
Label (position : Rect,
image : Texture, style :
GUIStyle) : void
static function
Label (position : Rect,
content : GUIContent,
style : GUIStyle) : void
它只有这几种重载形式……再给你说下各个参数的意思
position
标签使用的在屏幕上矩形的位置
text
在标签上显示的文本
image
在标签上显示的纹理
content
在标签上显示的文本,图片和信息提示
style
使用样式,如果不使用那么,标签样式应用当前的GUISKin皮肤。
希望能帮到你
追问
static function Label()这个在java和c#是一样的吗?
你能不能在我的基础上帮我改改
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |