Search Unity

Help! .. Script variables not working in Build

Discussion in 'Scripting' started by happyclappy, Aug 18, 2009.

  1. happyclappy

    happyclappy

    Joined:
    Aug 18, 2009
    Posts:
    24
    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????

    Code (csharp):
    1. // Scroll main texture based on time
    2. var scrollSpeed = 1;
    3. function Update ()
    4. {
    5.     var offset = Time.time * scrollSpeed;
    6.    
    7.     renderer.material.SetTextureOffset ("_MainTex", Vector2(offset/10.0, offset));
    8. }
     
  2. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    1. Welcome to the forums! :D

    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.
     
  3. happyclappy

    happyclappy

    Joined:
    Aug 18, 2009
    Posts:
    24
    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??
     
  4. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    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.
     
  5. happyclappy

    happyclappy

    Joined:
    Aug 18, 2009
    Posts:
    24
    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???
     
  6. pavlito

    pavlito

    Joined:
    Nov 27, 2007
    Posts:
    136
    *** 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.
     
  7. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    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.
     
  8. happyclappy

    happyclappy

    Joined:
    Aug 18, 2009
    Posts:
    24
    Ok. I'll upload/send it on the turn of the month when my internet quota refreshes.