|
ive got a custom cursor script from Unify, it works fine at first but im trying to change it depending on what button is pressed. Except my console is giving me errors like: Assets/cursorScript.js(71,9): BCE0044: expecting }, found 'else'. Assets/cursorScript.js(42,4): BCE0043: Unexpected token: ). Assets/cursorScript.js(142,9): BCE0044: expecting EOF, found '}'. Assets/cursorScript.js(43,9): BCE0044: expecting ), found '{'. Any ideas?? :S im quite new to Java and i understand most of whats in the script ill post my script aswell so you can have a look. var GrassButton : Texture2D; // The texture for when the cursor isn't near a screen edge var WaterButton : Texture2D; var ForestButton : Texture2D; var CustomCursor : Texture2D; var nativeRatio = 1.3333333333333; // Aspect ratio of the monitor used to set up GUI elements private var lastPosition : Vector3; // Where the mouse position was last var normalAlpha = .5; // Normal alpha value of the cursor ... .5 is full var fadeTo = .2; // The alpha value the cursor fades to if not moved var fadeRate = .22; // The rate at which the cursor fades private var cursorIsFading = true; // Whether we should fade the cursor private var fadeValue : float; static var GrassPressed = 0; static var ForestPressed = 0; static var WaterPressed = 0; // Scale the cursor so it should look right in any aspect ratio, and turn off the OS mouse pointer function Start() { // Slightly weird but necessary way of forcing float evaluation var currentRatio : float = (0.0 + Screen.width) / Screen.height; transform.localScale.x *= nativeRatio / currentRatio; Screen.showCursor = false; fadeValue = normalAlpha; lastPosition = Input.mousePosition; } function Update() { var mousePos = Input.mousePosition; // If the mouse has moved since the last update if (mousePos != lastPosition) { lastPosition = mousePos; // Get mouse X and Y position as a percentage of screen width and height MoveMouse(mousePos.x/Screen.width, mousePos.y/Screen.height); } } function MoveMouse(mousePosX : float, mousePosY : float) { if() { // If the mouse is on a screen edge, first make sure the cursor doesn't go off the screen, then give it the appropriate cursor if (mousePosX < .005) { mousePosX = .005; guiElement.texture = CustomCursor; }
}
(comments are locked)
|
|
Might be the fact that you have an empty if statement in your MoveMouse. If thats not the problem you should check if your brackets are placed right and are all closed. would the empty brackets not activate anyway then the rest act is the parameters are met? or have i got it wrong?
May 05 '11 at 09:56 PM
Sean Goddard
(comments are locked)
|

sorry about it being untidy :/ im not quite perfect at using this site yet :P