I have a script I'm trying to put on the character but it won't let me? - unity3d

Alright, so I'm working in Unity for a class and I'm doing the 3D Survival Shooter tutorial. I just finished making the Player Movement script and I'm trying to test it out, but when I press the play button, it says "All compiler errors have to be fixed before you can enter playmode!"
I was looking at the bottom and saw in the console that the error I have says: "Assets/_Complete-Game/MobileInput/Scripts/MobileControlRig.cs(12,29): error CS0234: The type or namespace name 'IActiveBuildTargetChanged' does not exist in the namespace 'UnityEditor.Build'. Are you missing an assembly reference?"
I've never used Unity before, so I have no idea what to do. Can anyone help me figure this out?
Things to note: I'm using Unity 5.6.0f3 Personal, and my computer's on Windows 7 (it's a school computer so we can't update them).

IActiveBuildTargetChanged is not available. That's causing the error.
You are using Unity 5.6.0f3 but IActiveBuildTargetChanged was added in Unity 2017.1. You need to download Unity 2017.1 or version above this in order to follow this tutorial.

Alright, thanks to the commenter who linked me to a Unity Forums website.
What I got from it was you can avoid having that error by going in the script and deleting the lines "#if UNITY_EDITOR , UnityEditor.Build.IActiveBuildTargetChanged #endif:".
And if it happens in any of the other scripts, just delete it from them too.
Thanks for your help, everyone!

Related

I am trying to code movement in unity and I keep getting this error and I don't know what it means

This is the error I get in the output and I've been trying to diagnose the issue for an hour now, I'm new to unity so this is kind of confusing to me.
The error.
This is the code I'm using, following a brackeys tutorial
Your project may be set to New Input System. From the Edit menu, go to project setting and in the player section, change the Active Input Handling to Both.

How to get rid of unity directory not found error

i have annoying problem within unity. I think its nothing special but i dont know if it will not cause a problem later in project.
I tried reinstalling unity and unity hub. Tried to use another version. Error still appears.
Most likely your problem is caused by using comma in project name. Typically you should not do that.

Unity - Can't add script behaviour CallbackExecutor [duplicate]

Yesterday I updated unity from unity5 to 2018.2.2f1. Unity scripts are not loading after Update 2018.2.2f1.
Once I try to play the Scene the scripts are not loaded and I can't add the script again it gives this error:
Can't add script component 'CubeScript' because the script class
cannot be found. Make sure that there are no compile errors and that
the file name and class name match.
If you still have the old copy of the project, upgrade the Unity project to Unity 2017 first then to 2018.2.2f1.
Here are the few possible reasons you may get this error(Ordered from very likely)
1.Script name does not match class name.
If script name is called MyClass, the class name must be MyClass. This is also case-sensitive. Double check to make sure that this is not the issue. To make sure that's not the issue, copy the class name and paste it as the script name to make sure that this is not the issue.
Note that if you have have multiple classes in one script, the class name that should match with the script name is the class that derives from MonoBehaviour.
2.There is an error in your script. Since this is an upgrade, there is a chance you're using an API that is now deprecated and removed. Open your script with Visual Studio and see if there is an error there then fix it. There is usually a red line under a code that indicates there is an error.
3.Bad import with the Unity importer and its automatic upgrade script.
Things to try:
A.The first thing to do is restart the Unity Editor.
B.Right click on the Project Tab then click "Reimport All"
C.If there is still issue, the only left is deleting the problematic script and creating a new one. There is an easier way to do this if the script is attached to many GameObjects in your scene.
A.Open the script, copy its content into notepad.
B.From the Editor and on the Project tab right click on the script "CubeScript", select "Find References In Scene".
C.Unity will now only show all the GameObjects that has this script attached to them. Delete the old script. Create a new one then copy the content from the notepad to this new script. Now, you can just drag the new script to all the filtered GameObject in the scene. Do this for every script effected. This is a manual work but should fix your issues when completed.
Here, is some reason why that's heaping.
1. Your Script Name And your class name isn't same.
2. May be there is an error in your script.
Here, is the few way to resolve it.
1. Make a same name of script and class in to this script.
2. find there is the error? and try to resolve it.
Posting here for historic purposes and if someone from Google ends up here, I strictly had the same problem (I'm on Windows 10) and here's how I fixed it :
If you click on the Console, you should see a blank error. Don't worry, it's a Editor bug, and you can see the Editor Log by selecting the console's window dropdown and selecting Open Editor Log.
For me, the problem was that "Tools\Roslyn\csc" could not be found, something that Unity uses to compile C# files.
I opened C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts\unity_csc.bat and I added ".exe" to the line "%APPLICATION_CONTENTS%\Tools\Roslyn\csc" /shared %*
(This line should now be : "%APPLICATION_CONTENTS%\Tools\Roslyn\csc.exe" /shared %*)
Now it works perfectly.
I'm completely new to Unity and game development, but I found that making the error true by entering an incorrect name, then entering the right one seems to "trick" Unity into fixing its error.
I had the same error show up but for different reasons (in case someone ends up here from google).
I was a beginner and named my file with a space in it. I got the same error after that. Make sure to NOT include spaces in your C# script.
One more thing which might help apart from other answers
Make the class which inherits from the MonoBehaviour the first class in the file. It fixed this issue for me.
Checking the console bugs and fix them is a good way to solve the problems "Can't add script component because the script class cannot be found?", although the bug seems to be irrelevant.
This works for me when I fix a bug in the other script.
for me I found out it was a script that I wasn't using which was linked to the player and other scripts that I deleted.
For me, the problem was that there was an error in another script.
Once I fixed the error, I could FINALLY attach my other scripts onto my gameobjects.
I just had this issue where I had a perfect script, no errors, and the same name as it should be but no matter what it wouldn't let me add it to a gameObject.
There was another script that was completely unrelated but it had an error in that and somehow that prevented me from adding my good new script.
Like some folks already posted here - the issue might be of a different code.
I was trying to add a script that was referenced by another one which had errors - it doesn't tell you that is the reason, although visual studio kinda suggests it by showing you the errors in the open script.
Just delete the bigger (errored) script and start adding to the unity project from the basic ones.
I had this issue where I had a good script, no errors, good name, restarting unity, following a tutorial exactly but still had this issue.
The way I fixed this is just deleting this buggy script file and creating it again. It fixed my problem perfectly! Now I could add the script to my game object with no such errors!
Hope this helps you! Cheers!

error cs2001 source file could not be found 2018

Ever since i open my project in unity today every script existed/Created have been given me
Error cs2001 source file "ScriptName.Cs" could not be found
I have reinstalled Unity, Tried Updating it and even created a new project. Still same outcome.
Ever time i tried attached my scripts to a object, it's have given me the error
Can't add script behaviour VisualContainerAsset",Can't Add Script "The script needs to derive from MonoBehaviour!"
Here is some pics how it's looks after i create a C# Script.
Sorry if i sound a bit confused!
UPDATE!:
Malware Bytes was the problem, it would't allow mono developed.
Could you show me one of the scripts? Maybe it misses some of the imports (using UnityEngine;) at the top. Or maybe they don't inherit from MonoBehaviour (classname: MonoBehaviour). It's strange nonetheless...

Unity3D v4.6.9 game doesn't run on iOS8 with xCode7

When we try running the game we see our splash screen and then we are getting the error Thread1:EXC_BAD_ACCESS code=1
at
il2cpp::icalls::mscorlib::System::String::RedirectToCreateString:
It happens before any of our c# code gets executed - before Awake().
It does run properly on iOS9.
We have tried it on Unity4.6.9 and on Unity4.6.9p3.
We have managed to build and run it for iOS8 only from Unity4.6.6 with xCode6.4. But we do need iOS9.
We can't find any references to this issue on the web, any help will be greatly appreciated.
xCode screen shot:
Unity Player Settings
Edited:
We have tried it from Unity5.2.3 too, no luck.
Another factor you should probably know is that before we run into the issue described above, we have edited the 'Run Debug' scheme of our product in xCode and disabled the 'GPU Frame Capture' because we had a different issue that prevented us from running our game on iOS8.
Here is the link we followed.
And here is a screen shot of our original issue:
We are really stuck here, hope you can help.
Are you sure that this Unity project is using the mscorlib.dll assembly from the Unity version of Mono? It looks like it may not be.
The RedirectToCreateString icall should never actually be executed, as the Mono mscorlib assembly used in Unity build strings via a single CreateString method. When this happens it usually means the moscorlib.dll version is out of sync with the IL2CPP runtime.
I'm not sure why this is happening, but it might be worth trying 4.6.9p3 with an empty (or simple) project to note the difference.
Its a replay for Josh Peterson, I could not replay with an image in a comment to his answer.
I was looking for the mscorlib.dll in my project but couldn't find one, so I looked in an old project and did find it. Here is an image of the file system of both projects.
Any way I don't know the origin of the file, I didn't manually played with it.
I have tried now to copy the mscorlib.dll from the old project to the new with no luck.
Any way my company decided to stop this investigation now and jump to the latest Unity 5.
Hope we will have more luck over there.
Thank you again.