Help, problem with semicolon
I have this script:
#pragma strict
public var speed = 0.5f;
function Update ()
{
Vector2 offset = new Vector2(0, Time.time * speed);
renderer.material.mainTextureOffset = offset;
}
And it says Assets/Sky.js(7,16): UCE0001: ';' expected. Insert a semicolon at the end. what is wrong?!
Comment
Best Answer
Answer by EmHuynh · Feb 17, 2016 at 11:13 PM
Hello, @Pejovski!
Here is the fixed version of your script, Sky.js:
#pragma strict
// Previous: public var speed = 0.5f;
// That was okay, but let's define its type for clarity.
public var speed : float = 0.5f;
function Update ()
{
// Previous: Vector2 offset = new Vector2( 0, Time.time * speed );
// That was an invalid way of declaring a variable.
// This is how we declare a certain type of variable in JS:
var offset : Vector2 = new Vector2( 0, Time.time * speed );
// Previous: renderer.material.mainTextureOffset = offset;
// That was obsolete. This is how we do it now:
GetComponent.< Renderer >().material.mainTextureOffset = offset;
}
Please read the comments to understand what the issues were and what changes were made.
Your answer
Follow this Question
Related Questions
Where to put ; 2 Answers
';' expected. Insert a semicolon at the end. Already have one 1 Answer
using UnityEngine.SceneManagement: How to use, etc? 1 Answer
missing Simikolon 0 Answers
Error with 6 line of code 1 Answer