Building Problem

Hi there

I did a little game that plays perfectly inside Unity by clicking the Play button, but when I try to build it, some stuff that I made just don’t work.

What can I do?

You could start by being a little more specific. There is really no way to help you without more information.

sorry, i’ll try to be more specific by using a little example.

Atached to the player character, I have this simple script:

function Update ()
{
   if (Input.GetAxis("Horizontal") != 0)
       animation.CrossFade ("Run");
   else
      animation.CrossFade ("Idle");
}

When I click the play button inside Unity, the script runs perfectly, and the animations are played correctly.

When I click on File > Build Settings, and then on Add Current and then Build and run my compiled game, the animation doesn’t play correctly anymore.

This is happening with other script as well, but not with all of them.

Let me guess, the code is always executing the “Run” animation after built.

Checking the log file, I found this:

       Couldn't load the script "Anim" because its file name doesn't match the class name.
Please make sure the file name of the script is the same as the class defined inside it. 
(Filename: ..\..\Runtime\Mono\MonoScript.cpp Line: 384)

Anybody knows what to do?

classes must match the name of the file they are in or won’t work

I read that javascript classes do not need to have a name explicitly declared on the file. Is that correct?

This specific script do not have a name declared on the file.

Hi guys… No solution for this problem so far.

Anyone knows what to do, please?