Search Unity

Bug WebGL Error

Discussion in 'Scripting' started by JeffryGameDev, Jun 2, 2023.

  1. JeffryGameDev

    JeffryGameDev

    Joined:
    Aug 7, 2022
    Posts:
    3
    Hi, ive been getting this :
    InvalidOperationException: Sequence contains no matching element
    at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00000] in <00000000000000000000000000000000>:0 error, in my WEBGL build, which caused a ienumerator to not work, anyone had this issue before and fixed it? Ive got the error also on a windows build. here's the full project on github : https://github.com/DanPeled/Hexmone and here's the web build : https://jeffrygames.itch.io/hexmone
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,000
    You need to ask specific questions. When you get the error in a windows build, the log should give you a clear stacktrace in which method of which class the exception actually happens. You clearly using the "First" method on some collection with a filter method. Since your filter method does not find any element that matches your filter criteria the Find method will throw this exception because it SHOULD return an element and it can't. Maybe you wanted to use FirstOrDefault instead? This will return null for reference objects or whatever is the default for value types in case no element matches.

    Your project is way too big without any hint where or when this issue happens.
     
    Kurt-Dekker likes this.
  3. JeffryGameDev

    JeffryGameDev

    Joined:
    Aug 7, 2022
    Posts:
    3
    Ye, I was in a rush of something, I may have got it fixed after seeing your reply, thank's for the help.