x


Can anyone translate this to C# (Change cursor appearance)

Hello guys. I Want to change cursor appearance for my game. I found this useful script from another answer and it works perfectly. The only problem is that it is witten in Java. Can anyone translate this into C#

    var cursorImage : Texture;

function Start() {
    Screen.showCursor = false;
}

function OnGUI() {
    var mousePos : Vector3 = Input.mousePosition;
    var pos : Rect = Rect(mousePos.x,Screen.height - mousePos.y,cursorImage.width,cursorImage.height);
    GUI.Label(pos,cursorImage);
}

Thank you for your time.

more ▼

asked Apr 05 '10 at 08:13 PM

gotmilk gravatar image

gotmilk
45 3 4 8

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
public Texture cursorImage;

public void Start() 
{
    Screen.showCursor = false;
}

public void OnGUI()
{
    Vector3 mousePos = Input.mousePosition;
    Rect pos = new Rect(mousePos.x, Screen.height - mousePos.y, 
        cursorImage.width, cursorImage.height);
    GUI.Label(pos, cursorImage);
}
more ▼

answered Apr 05 '10 at 08:27 PM

Michael La Voie gravatar image

Michael La Voie
2.3k 7 12 43

Thank you man. Worked perfectly :)

Apr 06 '10 at 07:10 PM gotmilk
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x984
x206
x198

asked: Apr 05 '10 at 08:13 PM

Seen: 2571 times

Last Updated: Apr 05 '10 at 08:13 PM