Ошибка «The associated script cannot be loaded»
Была значит машинка из Standard Assets. Делал на её базе игру, потом по глупости переименовал, осознав свою ошибку вернул название обратно и получил ошибку «the associated script cannot be loaded please fix any compile errors». Скрипты не трогал. Да вообще любые скрипты перестали работать. Даже скрипт Post Processing. Что делать?
-
Sandirk - UNITрон
- Сообщения: 150
- Зарегистрирован: 04 фев 2019, 21:48
Re: Ошибка «The associated script cannot be loaded»
AngryCat 01 мар 2019, 18:38
Sandirk писал(а):Была значит машинка из Standard Assets. Делал на её базе игру, потом по глупости переименовал, осознав свою ошибку вернул название обратно и получил ошибку «the associated script cannot be loaded please fix any compile errors». Скрипты не трогал. Да вообще любые скрипты перестали работать. Даже скрипт Post Processing. Что делать?
Видимо эта машинка очень обиделась когда ты ее переименовал. А если серьезно, то лучше кинь полный скрин консоли с ошибками.
Здесь могла бы быть ваша реклама.
-
AngryCat - Старожил
- Сообщения: 714
- Зарегистрирован: 20 июл 2018, 22:29
- Skype: Дискорд — Флеш#4099
Re: Ошибка «The associated script cannot be loaded»
seaman 01 мар 2019, 19:07
Скорее всего все же переименовал скрипт.
Класс внутри него должен иметь тоже имя что файл.
- seaman
- Адепт
- Сообщения: 8352
- Зарегистрирован: 24 янв 2011, 12:32
- Откуда: Самара
Re: Ошибка «The associated script cannot be loaded»
Sandirk 02 мар 2019, 00:05
AngryCat писал(а):
Sandirk писал(а):Была значит машинка из Standard Assets. Делал на её базе игру, потом по глупости переименовал, осознав свою ошибку вернул название обратно и получил ошибку «the associated script cannot be loaded please fix any compile errors». Скрипты не трогал. Да вообще любые скрипты перестали работать. Даже скрипт Post Processing. Что делать?
Видимо эта машинка очень обиделась когда ты ее переименовал. А если серьезно, то лучше кинь полный скрин консоли с ошибками.
Я бы тоже обиделся, если бы меня из машинки в игрока переименовали.
Консоль:
http://priscree.ru/img/9fccd87212bb20.jpg
При запуске выдаёт подобные ошибки
http://priscree.ru/img/3bd8048bceab63.png
(Пардон за ссылки, скрины великоваты получились)
Последний раз редактировалось Sandirk 02 мар 2019, 00:11, всего редактировалось 1 раз.
-
Sandirk - UNITрон
- Сообщения: 150
- Зарегистрирован: 04 фев 2019, 21:48
Re: Ошибка «The associated script cannot be loaded»
Sandirk 02 мар 2019, 00:06
seaman писал(а):Скорее всего все же переименовал скрипт.
Класс внутри него должен иметь тоже имя что файл.
Вроде все названия какими были остались. Да и не мог я абсолютно все скрипты переименовать и не заметить.
-
Sandirk - UNITрон
- Сообщения: 150
- Зарегистрирован: 04 фев 2019, 21:48
Re: Ошибка «The associated script cannot be loaded»
seaman 02 мар 2019, 10:30
Читайте что пишет.
Вы (антивирус, кто бы то ни было…) удалили скомпилированные dll и у Юнити почему то теперь нет доступа, чтобы их снова перезаписать.
- seaman
- Адепт
- Сообщения: 8352
- Зарегистрирован: 24 янв 2011, 12:32
- Откуда: Самара
Re: Ошибка «The associated script cannot be loaded»
Sandirk 02 мар 2019, 22:37
seaman писал(а):Читайте что пишет.
Вы (антивирус, кто бы то ни было…) удалили скомпилированные dll и у Юнити почему то теперь нет доступа, чтобы их снова перезаписать.
И как с этим обстоять? Может есть какой-то способ?
-
Sandirk - UNITрон
- Сообщения: 150
- Зарегистрирован: 04 фев 2019, 21:48
Re: Ошибка «The associated script cannot be loaded»
AngryCat 03 мар 2019, 01:38
Sandirk писал(а):
seaman писал(а):Читайте что пишет.
Вы (антивирус, кто бы то ни было…) удалили скомпилированные dll и у Юнити почему то теперь нет доступа, чтобы их снова перезаписать.И как с этим обстоять? Может есть какой-то способ?
От имени администратора запусти
Здесь могла бы быть ваша реклама.
-
AngryCat - Старожил
- Сообщения: 714
- Зарегистрирован: 20 июл 2018, 22:29
- Skype: Дискорд — Флеш#4099
Re: Ошибка «The associated script cannot be loaded»
Sandirk 03 мар 2019, 15:13
AngryCat писал(а):
Sandirk писал(а):
seaman писал(а):Читайте что пишет.
Вы (антивирус, кто бы то ни было…) удалили скомпилированные dll и у Юнити почему то теперь нет доступа, чтобы их снова перезаписать.И как с этим обстоять? Может есть какой-то способ?
От имени администратора запусти
Что именно? Unity? Да и заранее скажу, что вряд ли заработает.
(Если это был подкол, то тонко. Очень тонко)
-
Sandirk - UNITрон
- Сообщения: 150
- Зарегистрирован: 04 фев 2019, 21:48
Re: Ошибка «The associated script cannot be loaded»
AngryCat 03 мар 2019, 23:22
Sandirk писал(а):
AngryCat писал(а):
Sandirk писал(а):
seaman писал(а):Читайте что пишет.
Вы (антивирус, кто бы то ни было…) удалили скомпилированные dll и у Юнити почему то теперь нет доступа, чтобы их снова перезаписать.И как с этим обстоять? Может есть какой-то способ?
От имени администратора запусти
Что именно? Unity? Да и заранее скажу, что вряд ли заработает.
(Если это был подкол, то тонко. Очень тонко)
Ты видимо каким-то раком удалил все Dll библиотеки. Попробуй создать новый проект и перенести туда скрипты и ассеты, если ошибки останутся, то проблема в другом
Здесь могла бы быть ваша реклама.
-
AngryCat - Старожил
- Сообщения: 714
- Зарегистрирован: 20 июл 2018, 22:29
- Skype: Дискорд — Флеш#4099
Re: Ошибка «The associated script cannot be loaded»
Sandirk 07 мар 2019, 17:20
AngryCat писал(а):
Sandirk писал(а):
AngryCat писал(а):
Sandirk писал(а):
seaman писал(а):Читайте что пишет.
Вы (антивирус, кто бы то ни было…) удалили скомпилированные dll и у Юнити почему то теперь нет доступа, чтобы их снова перезаписать.И как с этим обстоять? Может есть какой-то способ?
От имени администратора запусти
Что именно? Unity? Да и заранее скажу, что вряд ли заработает.
(Если это был подкол, то тонко. Очень тонко)Ты видимо каким-то раком удалил все Dll библиотеки. Попробуй создать новый проект и перенести туда скрипты и ассеты, если ошибки останутся, то проблема в другом
Пробовал. Не помогает.
-
Sandirk - UNITрон
- Сообщения: 150
- Зарегистрирован: 04 фев 2019, 21:48
Re: Ошибка «The associated script cannot be loaded»
seaman 07 мар 2019, 19:52
В пути к проекту нет русских букв? Где он вообще находится (путь к нему)?
Ну и самое верное:
В проекте много было? Если не очень много, или просто не жалко — может выложить архив с проектом. Наверняка кто-то разберется в чем дело.
- seaman
- Адепт
- Сообщения: 8352
- Зарегистрирован: 24 янв 2011, 12:32
- Откуда: Самара
Re: Ошибка «The associated script cannot be loaded»
Sandirk 08 мар 2019, 22:49
seaman писал(а):В пути к проекту нет русских букв? Где он вообще находится (путь к нему)?
Ну и самое верное:
В проекте много было? Если не очень много, или просто не жалко — может выложить архив с проектом. Наверняка кто-то разберется в чем дело.
Русских букв нет. Проект был небольшой, но переделывать лень. Хотя что тут поделать?
-
Sandirk - UNITрон
- Сообщения: 150
- Зарегистрирован: 04 фев 2019, 21:48
Вернуться в Почемучка
Кто сейчас на конференции
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 7
so I’m new to Unity and I’ve been trying to test the scene with the script attatched to a character. However, it keeps saying «The associated script cannot be loaded. Please fix any compile errors and assign a valid script.» It also says that the name of the file could be different from the name in the code but it isnt, and also it says that the code could be missing MonoBehaviour Scripts. It wont even allow me to attach the script to characters because it cant find the script class.
I’ve copied and downloaded character movement codes from the internet but they didnt work either. I’ve also tried deleting and re-making the CS files but that didnt work either. Even adding empty scripts to characters didnt work unless i do it from «Add component»
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
SpriteRenderer sprite;
Rigidbody2D rigid;
// Start is called before the first frame update
void Start()
{
sprite = GetComponent<SpriteRenderer>();
rigid = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
if (Input.GetKey("d"))
rigid.velocity = new Vector2(2, 0);
else if (Input.GetKey("a"))
rigid.velocity = new Vector2(-2, 0);
}
}
There are also these errors in Unity if that helps
Ruzihm
19.6k5 gold badges36 silver badges48 bronze badges
asked Jun 4, 2019 at 19:17
2
I think your class name is different from file name.
answered May 30, 2020 at 19:30
MarshallMarshall
591 silver badge4 bronze badges
3
First, it is recommended to use «Add component» to create a script, if you want to attach it to a GameObject, as it automatically imports necessary libraries. Implementing MonoBehaviour is necessary for adding a script to a GameObject.
Second, FixedUpdate() should not be set to private, it does not need an access modifier, just like Start(), see https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html.
Third, the errors in your first screenshot seem to imply that there is a problem with your Unity installation. Try reinstalling it and make sure that the Editor you install matches your operating system (64 or 32 bit?).
Fourth, the second screenshot is shown when you use any obsolete libraries or classes, which does not seem to be the case in the script you shared.
Hope that helps.
answered Jun 5, 2019 at 13:59
AhornAhorn
6494 silver badges19 bronze badges
1
It’s basically because you deleted some script or renamed it or degraded unity version. you might have to reassign the script at the required position/component.
Note: Make sure that class name is the same as the script name in unity.
answered Jun 4, 2019 at 21:31
1
0 / 0 / 0 Регистрация: 02.05.2020 Сообщений: 11 |
|
1 |
|
02.05.2020, 22:18. Показов 3314. Ответов 6
Скрипт работал нормально, но после перезахода в Unity вылезла такая ошибка. В интернете не на русскоязычных сайтах, не на Пробовал: Изображения
0 |
68 / 48 / 20 Регистрация: 09.10.2013 Сообщений: 156 |
|
03.05.2020, 12:17 |
2 |
А что в Консоли показывает?
0 |
0 / 0 / 0 Регистрация: 02.05.2020 Сообщений: 11 |
|
03.05.2020, 13:24 [ТС] |
3 |
В консоли ошибок нет
0 |
68 / 48 / 20 Регистрация: 09.10.2013 Сообщений: 156 |
|
03.05.2020, 13:36 |
4 |
Здесь у ребят что-то похожее.
0 |
0 / 0 / 0 Регистрация: 02.05.2020 Сообщений: 11 |
|
03.05.2020, 13:41 [ТС] |
5 |
Я видел это, но они говорят что кроме создание нового проекта ничего не помогает, я это уже пробовал, причём ошибка вылезла уже на другом скрипте. Я так понял это какой-то баг unity(хотя с 2013 года могли бы и пофиксить)
0 |
68 / 48 / 20 Регистрация: 09.10.2013 Сообщений: 156 |
|
03.05.2020, 13:43 |
6 |
AlpakeR, а вы пробовали meta-файлы удалять? Еще можно на всякий случай по [Assets/Reimport All] кликнуть.
0 |
3215 / 1700 / 965 Регистрация: 26.10.2018 Сообщений: 4,894 |
|
03.05.2020, 15:29 |
7 |
В консоли ошибок нет Проект запускается в редакторе? Еще может быть что имя скрипта не совпадает с именем файла.
0 |
When working with Unity, you may encounter the «The Associated Script Cannot Be Loaded» error. This error is often caused by an issue with the script’s file path, class name, or namespace. In this guide, we’ll walk you through the steps to resolve this error and get your Unity project back on track.
Table of Contents
- Check the File Path and Name
- Verify the Class Name and Namespace
- Reimport the Script
- Recompile the Project
- FAQ
Check the File Path and Name
The first thing you should do is to ensure that the script’s file path and name are correct. Unity requires that the script’s file name matches the class name exactly, including capitalization. To check this:
- Open the script in a text editor or IDE.
- Verify that the file name (including the
.cs
extension) matches the class name in the script. - Ensure that the script is located in the correct folder within your Unity project. By default, this should be in the
Assets
folder or one of its subfolders.
If you find any discrepancies, correct them and save the file.
Verify the Class Name and Namespace
Next, you should check the script’s class name and namespace to ensure they match the file name and project structure. To do this:
- Open the script in a text editor or IDE.
- Verify that the class name matches the file name (excluding the
.cs
extension). - If the script is part of a namespace, ensure that the namespace matches the folder structure within the
Assets
folder. For example, if the script is located inAssets/MyNamespace
, the script should includenamespace MyNamespace
at the top of the file.
If you find any discrepancies, correct them and save the file.
Reimport the Script
After verifying the file path, name, class name, and namespace, you should try reimporting the script in Unity. This can often resolve issues with the script not being recognized by the Unity editor. To reimport the script:
- In the Unity editor, select the script in the Project window.
- Right-click on the script and choose
Reimport
from the context menu.
Unity will reimport the script and update any references to it in your project.
Recompile the Project
If the error persists, try recompiling the entire project. This can help resolve any lingering issues with script references or dependencies. To recompile the project:
- In the Unity editor, go to
File
>Build Settings
. - Click the
Build
button to compile the project.
Once the build is complete, check to see if the error has been resolved.
FAQ
1. What causes the «The Associated Script Cannot Be Loaded» error?
This error is commonly caused by issues with the script’s file path, file name, class name, or namespace. Ensuring that these values are correct and consistent can help resolve the error.
2. How do I check the file path and name of my script?
Open the script in a text editor or IDE, and verify that the file name (including the .cs
extension) matches the class name in the script. Ensure that the script is located in the correct folder within your Unity project (typically the Assets
folder or one of its subfolders).
3. How do I verify the class name and namespace of my script?
Open the script in a text editor or IDE, and verify that the class name matches the file name (excluding the .cs
extension). If the script is part of a namespace, ensure that the namespace matches the folder structure within the Assets
folder.
4. How do I reimport a script in Unity?
In the Unity editor, select the script in the Project window, right-click on the script, and choose Reimport
from the context menu.
5. How do I recompile my entire Unity project?
In the Unity editor, go to File
> Build Settings
and click the Build
button to compile the project.
- Unity Scripting API
- Unity Manual: Script Compilation
- Unity Forums: Troubleshooting Script Compilation Errors
PLEASE HELP ME! The associated script can not be loaded.
Hi!
I am sort of a unity noob still, so the answer to this question might be obvious to you. But please help me anyways.
I am panicking as my project has basically collapsed. On every single gameobject with a script, the error message: «The associated script can not be loaded. Please fix any compile errors and assign a valid script» shows. The only thing is that I don’t have any problems in my script (at least no error messages) and the scripts are assigned. I’ve tried to delete all of the scripts in the project and reimporting them again, but the same problem occurs.
What should I do?