Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

C# Queue compilation issue

Discussion in 'Scripting' started by moose0847, Dec 26, 2019.

  1. moose0847

    moose0847

    Joined:
    Dec 26, 2019
    Posts:
    33
    Hello everyone,

    I am currently attempting to use a queue as part of a monobehaviour. I am able to create the queue by referencing System.Collections.Generic as you would expect, however if I make an attempt to call Enqueue, Peek, or Dequeue I get the following error in Unity when compiling scripts (the solution compiles fine in visual studio):

    For reference, the Queue I'm using is on unity 2019.3.0f3
    private readonly Queue<AssetReference> _stateRequestQueue = new Queue<AssetReference>();

    Is there something I'm missing here about using Queues in Unity?
     
  2. moose0847

    moose0847

    Joined:
    Dec 26, 2019
    Posts:
    33
    Note:
    This error only seems to happen when using the generic type Queue<T> using System.Collections.Queue seems to compile and run fine.
     
  3. TheSmokingGnu

    TheSmokingGnu

    Joined:
    May 1, 2017
    Posts:
    22
    Getting same error on Unity 2019.3.10f1. Interestingly, the error appears only when I try to compile
    Code (CSharp):
    1. m_commandQueue.Enqueue(1);
    member definition compiles fine:
    Code (CSharp):
    1. Queue<int> m_commandQueue = new Queue<int>();
    `