Reputation: 223
Here are the errors I'm getting in the Unity console:
Assets/leavingPlayableAreaScript.cs(16,74): error CS1729: The type 'UnityEngine.Rect' does not contain a constructor that takes '3' arguments
Assets/leavingPlayableAreaScript.cs(16,21): error CS1502: The best overloaded method match for `UnityEngine.GUI.DrawTexture(UnityEngine.Rect, UnityEngine.Texture)' has some invalid arguments
Assets/leavingPlayableAreaScript.cs(16,21): error CS1503: Argument '#1' cannot convert 'object' expression to type 'UnityEngine.Rect'
Here is my code:
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);
}
}
Upvotes: 0
Views: 606
Reputation: 10152
The error is self-explanatory.
The type 'UnityEngine.Rect' does not contain a constructor that takes '3' arguments.
You're missing an argument:
Rect(left: float, top: float, width: float, height: float)
https://docs.unity3d.com/Documentation/ScriptReference/Rect-ctor.html
Here's a proper example from documentation:
// 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
Upvotes: 2