- Home /
Unity error "is inaccessible due to its protection level"
I totally understand that I need to instantiate prefabs before using and so on, however, I am now getting such an "inaccessible" error with a Class of the C# collection.
I try to use a ConcurrentQueue (System.Collections.Concurrent.ConcurrentQueue) and the code looks like this:
using System.Collections.Concurrent;
using UnityEngine;
using System.Threading;
public class Agent : MonoBehaviour {
static private ConcurrentQueue<Storage> tasks = new ConcurrentQueue<Storage>();
Although the docs list "ConcurrentQueue" Unity keeps saying: "System.Collections.Concurrent.ConcurrentQueue is inaccessible due to its protection level"
How can I use it? Why does Unity complain at all, since the class is supplied by System.Collections.Concurrent?
Answer by Bunny83 · Jul 09, 2017 at 01:04 AM
The mono framework doesn't seem to have a ConcurrentQueue class in it's mscorlib while the .NET framework does have one. There is one that is declared as internal class inside the "nunit.framework". It's possible that your IDE might recognise that class but isn't allowed to access it since it's an internal class.
Though you might be able to just copy the reference source into your project. As alternative you could roll your own implementation.
ps: Just in case you don't know: Most parts of the Unity API is not thread-safe and is not allowed being used from another thread than the main thread.
@Bunny83 plz help T,T ive been trying to reach you! A few years ago you had a solution to lost scripts with ILSpy and if anyone needed help to ask. Please help i had tried doing what you said with the assemblies but i just got lost! $$anonymous$$ay i ask what your email is so i can send you the assemblies unity isnt allowing me to upload them hear in the box!
Your answer
