Cross Platform(including WSA)Getting different random number series(in WSA) even after using same System.Random seed for all platforms

Hi all,

I am trying to generate similar random number series using System.Random ( not UnityEngine.Random) and providing same seed for all the platforms.

Every other platform(Android, iOS, Web, Standalone) seems to be working and generating same random number series.

But somehow for WSA(even though same seed) the generated numbers are completely different.

Any idea why?

I don’t want to use UnityEngine.Random as unlike System.Random (where I can create instance of System.Random) all of its method are static and accessible to any one to modify the seed anywhere in my whole program.

Any suggestion would be a great help.

Thanks!
Deepesh

From the System.Random documentation

However, note that Random objects in processes running under different versions of the .NET Framework may return different series of random numbers even if they’re instantiated with identical seed values.

From the WSA Unity documentation

On Windows Store Apps Microsoft .NET is used instead of Mono. There is a special .NET version for this platform, which is not entirely compatible with Mono.

So that basically means you are out of luck without some extra work.

There are a couple of solutions that might be useful

  • Use your own random number generator
  • Implement System.Random yourself for the WSA. You should be able to break into the class and find out how it is implemented in Mono, no guarantees though.

Be aware that this will break again when Unity upgrades its version of .NET