Quantcast
Channel: Questions in topic: "protection"
Viewing all articles
Browse latest Browse all 107

Unity 5.6.1 Causes Error When Using System.Lazy

$
0
0
I recently tried updating Unity to version 5.6.1 from version 5.6.0. After updating, I opened a project which I had been working on and was error-free with the previous version. I got an error in the Unity console as below: Assets/Scripts/Singletons/Singleton.cs(32,26): error CS0122: `System.Lazy' is inaccessible due to its protection level In Visual Studio Code, which I use for script editing, I got a matching error: 'Lazy' is inaccessible due to its protection level [Assembly-CSharp] The error occurred on the line of code below, where I declare a field of type `System.Lazy<>`: private static readonly Lazy _instance = new Lazy(() => CreateInstance()); I've been using the `System.Lazy` class since the start of the project and have had no problems with it until this update to version 5.6.1. To verify that this was actually the cause of the problem, I uninstalled Unity and reverted to the previous version, 5.6.0, again. The error disappeared and I was able to run the game without a problem. Then I uninstalled again and reinstalled the new version, 5.6.1, and the error returned. Finally, to remove all other factors, I created a new empty project using the new Unity version, 5.6.1, and created a single script containing only this: using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class Test : MonoBehaviour { public Lazy myLazy; } This produced the same error as the line of code I mentioned above. I'm wondering whether this is something that should be a bug report, but I thought it was worth it to check here in case someone has encountered something like this before and there is a known fix. **Has anyone else encountered similar problems with either this Unity version update or a previous one, and if so, how was the problem resolved (if it was)?** For now, I've gone back to version 5.6.0 and have not experienced the error since.

Viewing all articles
Browse latest Browse all 107

Trending Articles