[英]Errors in Unity3d
以下是我在Unity控制台中遇到的錯誤:
Assets / leavingPlayableAreaScript.cs(16,74):錯誤CS1729:類型'UnityEngine.Rect'不包含帶'3'參數的構造函數
Assets / leavingPlayableAreaScript.cs(16,21):錯誤CS1502:“UnityEngine.GUI.DrawTexture(UnityEngine.Rect,UnityEngine.Texture)”的最佳重載方法匹配有一些無效的參數
Assets / leavingPlayableAreaScript.cs(16,21):錯誤CS1503:參數'#1'無法將'object'表達式轉換為'UnityEngine.Rect'類型
這是我的代碼:
using UnityEngine;
using System.Collections;
public class leavingPlayableAreaScript : MonoBehaviour
{
public GUIStyle Stylesheet;
public bool inTrigger;
void Update () {
}
void OnGUI()
{
GUI.DrawTexture(new Rect((Screen.width/2) -600, 500, 800), Stylesheet);
}
}
錯誤是不言自明的。
類型'UnityEngine.Rect'不包含帶'3'參數的構造函數。
你錯過了一個論點:
Rect(left: float, top: float, width: float, height: float)
https://docs.unity3d.com/Documentation/ScriptReference/Rect-ctor.html
以下是文檔中的正確示例:
// Draws a texture on the screen at 10, 10 with 100 width, 100 height.
var aTexture : Texture;
function OnGUI() {
if(Event.current.type.Equals(EventType.Repaint))
Graphics.DrawTexture(Rect(10, 10, 100, 100), aTexture);
}
https://docs.unity3d.com/Documentation/ScriptReference/Graphics.DrawTexture.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.