x


The name 'Transform' does not denote a valid type ('not found'). Did you mean 'System.Net.Mime.TransferEncoding'? (BCE0018)

Hi all, I am new to game development, I am learning unity from http://www.vtc.com and when i came to scripting part it started giving me errors error image

D:My Unity ProjectsTutsAssetsStandard AssetsCharacter ControllersSourcesScriptsCharacterMotor.js(1,1): Error BCE0021: Namespace 'UnityEditor' not found, maybe you forgot to add an assembly reference? (BCE0021) (Assembly-UnityScript-firstpass) D:My Unity ProjectsTutsAssetsScriptsRespawn.js(13,13): Error BCE0005: Unknown identifier: 'Transform'. (BCE0005) (Respawn)

I never touched CharacterMotor.js but i started giving errors, and in my script respawn the I am not able to use Transform. Please help me.

edit(copied from comment)

It's a simple script:

function Update ()
{
    if (Transform.Position.y < -10)
    {
        print(Transform.Position.y);
    }
    if (Transform.Position.y < -20)
    {
        Transform.Position.x = 0;
        Transform.Position.y = 2; 
        Transform.Position.z = 0; 
    }
}

more ▼

asked Sep 29, 2011 at 11:37 AM

rocksean30 gravatar image

rocksean30
16 6 4 6

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

You need to put any scripts which use the UnityEditor namespace inside a subfolder called 'Editor'. This tells Unity that those scripts are edtior-only and not to include them in the build! It also lets the compiler know that the editor namespace exists.

more ▼

answered Sep 29, 2011 at 01:22 PM

syclamoth gravatar image

syclamoth
18.5k 20 28 131

I created a folder called 'Editor' in Scripts And i placed my scripts into D:My Unity ProjectsTutsAssetsStandard AssetsScriptsEditor still it is giving error

D:My Unity ProjectsTutsAssetsStandard AssetsCharacter ControllersSourcesScriptsCharacterMotor.js(1,1): Error BCE0021: Namespace 'UnityEditor' not found, maybe you forgot to add an assembly reference? (BCE0021) (Assembly-UnityScript-firstpass)

The same error with 11 other files

FPSInputController.js

PlatformInputController.js

ThirdPersonCamera.js

ThirdPersonController.js

TimedObjectDestructor.js

MouseOrbit.js

SmoothFollow.js

SmoothLook.js

Respawn.js

Shoot.js

DragRigidbody.js

http://www.flickr.com/photos/rocksean30/6195613168/in/photostream/lightbox/

Sep 29, 2011 at 04:08 PM rocksean30

Scripts in Editor can't be used and Transform can't be used outside of Editor What should I do ?

Oct 01, 2011 at 02:45 PM rocksean30

Thanx a lot i dont know what exactly solved my problem but i guess deleting the .csproj and .sln files in my project folder did it. And after that i also did this right click on the script file in the project window and selected synch monodevelop project. I hope this helps others also. :)

Oct 01, 2011 at 03:55 PM rocksean30

No you get that wrong. Only editor scripts (scripts that extend the functionality of the Unity-editor) have to be placed in an editor folder. All other scripts that are part of your game must not be placed in an editor folder, otherwise the scripts can't be used in your game.

Make sure you have installed the MonoDevelop version that comes with your Unity version. Also you could delete all ".sln" and ".csproj" files inside your project folder and then click "Sync MonoDevelop Project" inside Unity. That will recreate the solution and project files.

Also be careful, Unity creates several ".sln" files but i'm not sure if they all work with MonoDevelop. I don't use MonoDevelop. I use C# only so i'm using Visualstudio.

Oct 01, 2011 at 11:52 AM Bunny83
(comments are locked)
10|3000 characters needed characters left

The 'UnityEditor' namespace error may be a bug of Unity 3.4.1f5. Many people have reported it (See unity 3.4.1f5 namespace error - Unity Answers).
Despite the errors being given in MonoDevelop, Unity can compile the scripts successfully. So, just ignore them :)

The Transform error seems to be caused because there's something wrong with your script 'Respawn.js', but I'm not sure about it.

more ▼

answered Oct 01, 2011 at 11:21 AM

dai1741 gravatar image

dai1741
76 1 1 4

Its a simple script function Update () { if (Transform.Position.y < -10) { print(Transform.Position.y); } if (Transform.Position.y < -20) { Transform.Position.x = 0; Transform.Position.y = 2; Transform.Position.z = 0; } }

Oct 01, 2011 at 02:44 PM rocksean30

Transform is not transform, as Bunny83 said :)

Oct 02, 2011 at 11:52 AM dai1741
(comments are locked)
10|3000 characters needed characters left

Transform is a type! You can't use a type like a variable. To access the Transform component of your GameObject you have to use transform (notice the lower-case "t" ) instead of Transform.

Also the .position property have to be lower-case.

more ▼

answered Oct 01, 2011 at 04:16 PM

Bunny83 gravatar image

Bunny83
85.9k 31 169 438

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x9514
x6473
x3762
x2327

asked: Sep 29, 2011 at 11:37 AM

Seen: 5067 times

Last Updated: Oct 02, 2011 at 11:52 AM