Reputation: 707
I was using Unity 2019.1 and my project was running fine. After updating Unity to 2019.4 one of the scripts attached to a gameobject give me this warning: "The associated script can not be loaded" and I was not able to use the script.
I have no errors neither in the visual studio nor in Unity. After commenting and uncommenting codes from this script, I figured out what is making this problem: a variable from a library I am using in the project from dll file. (note that some variables from this dll work fine in my script and others are causing this problem).
I tried "Reimport all" and it didn't work.
Can you please help me to solve this problem?
Edit1:
I have no errors, just these 2 warnings:
Upvotes: 2
Views: 1638
Reputation: 180
It looks like you have or deleted or moved the file. the easiest way to fix this would be to remove and add the component to the object. if you get an error run the automatic API updater.
how to run the API updater: go to the top of your screen > assets > Run API Updater
Upvotes: 0
Reputation: 71
I found there are some answers on this Forums
You should check it out
Upvotes: 1
Reputation: 511
I did some research on this stuff and now I do not really understand why is this happening. It happens only when you declare variables in MonoBehavior class, but if a variable is declared in a function or class which not inherits from MonoBehavior this works fine.
Although I can't find the reason, you can evade this problem by declaring a variable in another class for storing data.
Just like this:
using UnityEngine;
using OpenTok;
public class SceneScript : MonoBehaviour
{
private SceneData data;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
public class SceneData
{
private Session session;
}
Upvotes: 1