Help! .. Script variables not working in Build

Below is a JS file that I am using on several objects. Each object has scrollSpeed set to a different number from the INSPECTOR.

From within the game window everything looks great but in the Build, the different numbers do not hold and they all scroll at the initial setting of 1.

What am I missing???

// Scroll main texture based on time
var scrollSpeed = 1;
function Update () 
{
    var offset = Time.time * scrollSpeed;
    
    renderer.material.SetTextureOffset ("_MainTex", Vector2(offset/10.0, offset));
}
  1. Welcome to the forums! :smile:

  2. When posting to the forums and included code make sure to use the Code button, or manually wrap your scripts/code in a code tags ( [ code ]…[ /code ], without the spaces) for better formatting, I’ll edit your post so you can look at that as an example.

  3. I don’t know why you’d be having issues as the code is simple and straightforward enough. Are you editing the variable values in the editor while playing your content? If so then please know that when you stop playback the values will be thrown out (a good thing, it lets you experiment without worry). Make sure that your values have “stuck” after stopping playback in the editor and before building.

Thanx for reply Higgy.

But I am using the editor during normal editing operation… ie Not during testing.

The code I included isn’t the only script not functioning… I have included camera smoothing with slerp in a script but the added slerp functions simply refuse to call. Well at least that’s what it looks like.

Is there a possibility that Build is refusing to use new files? somehow locking itself to seeing old data??

Is there a possibility? I’m doubtful but clearly something is amiss. Can you perhaps share an example project? You can do that either by posting it here in this thread or even sending it directly to me so I can test on my end. Something is off and so far it’s very hard to sort out what so a first-hand peek might help.

I think I’ve found the cause.

I decided to rebuild a new Project using the same assets. The first time I try to build, I get an error saying that it can not copy some part of mono.

I clicked “Try Again” about 50 times before I just clicked cancel. At this point it just continues the build and the resulting build is faulty.

Every subsequent build does not include the error message but will not execute new code.

Is there a way to clear all pre-compilation or a way to re-build from scratch without creating a new project everytime???

*** WARNING: Possible off-topic! ***

I’ve had similar problems with connecting to a database. I included the .dll required in the project folder. Tested inside editor, works.

When I build a STANDALONE app, it just doesn’t connect.
I’ve seen other very interesting bugs, but I won’t go into them right now.

Not that I’m immediately aware of, no. If/when you get a project in this “stuck” state, we would appreciate a bug logged on that and the project folder included so we can sort out why Unity is doing this as it simply shouldn’t. Having that bug and the offending project would be prime material if you can. Thanks.

Ok. I’ll upload/send it on the turn of the month when my internet quota refreshes.