Search Unity

Question error CS0815: Cannot assign void to an implicitly-typed variable

Discussion in 'Addressables' started by fwalker, Nov 6, 2022.

  1. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    Hopefully this is an easy one for someone. I have the following line of code:
    var myItem = await Addressables.InstantiateAsync(key, transform);

    When the .cs file containing this line under the Assets/Script/MyFolder folder it works just fine...
    But when I move my file under Assets/MyProject/Scrips/MyFoder (which contains a .asm file, and yes that asm file has a reference to the Unity.Addressables package) then I get the error:
    "error CS0815: Cannot assign void to an implicitly-typed variable"
    With every thing else compiling just fine.
    It feels to me like I am missing a package references in my asm file perhaps?
    Does anyone have any thoughts for me?
     
  2. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    391
    Maybe you don't reference Unity.ResourceManager in .asmdef:
     
  3. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    I do indeed reference that one. I guess I should have posted the ones I do reference:
    Unity.Addressables
    Unity.ResourceManager

    Unity.InputSystem
    Unity.Animation.Rigging
    Unity.ML-Agents
    Unity.TextMeashPro