0
\$\begingroup\$

I am not able to assign a particular C# script to a game object. When I try to do so, I get this error as shown below Only the script I have is different. error when trying to drag a script to a gameobject In brief, just like the error above I am getting it as Can't Add Script Component 'AIWaypointNetwork' because the script class cannot be found. Make sure that there are no compile errors and that the file name and the class name match

And when I try to create a script component, I get the warning Associated Script cannot be loaded. Please fix compile errors and assign a valid script. Here is a screenshot of the situation. warning screenshot

As far as I know, I don't see anything wrong with the script and it's pretty simple too.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AIWaypointNetwork : MonoBehaviour
{
    public List<Transform> Waypoints = new List<Transform>();
}

The unity version that I am using right now is Version 2020.1.11f1 Personal. And I have not faced these types of errors before. Based on my search, I see that I would probably have to reimport assets over again. How do we do that in this version of unity?

Is there something else I am missing here?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Did you rename the script? The error box is calling the script NavAgentExample while your script is AIWaypointNetwork \$\endgroup\$
    – Zibelas
    Jan 2 at 10:22
  • \$\begingroup\$ @Zibelas As I had already said, I am getting the same error, but for the script that I have. Apologies for the miscommunication. What I meant to say was I am getting the error as Can't Add Script Component 'AIWaypointNetwork' because the script class cannot be found. Make sure that there are no compile errors and that the file name and the class name match. I have made the changes to the question to remove the misunderstanding \$\endgroup\$ Jan 2 at 11:49

Browse other questions tagged or ask your own question.