SharedRandom.cs 475 B

1234567891011121314151617181920
  1. using Unity.Burst;
  2. using Unity.Mathematics;
  3. namespace LitMotion
  4. {
  5. static class SharedRandom
  6. {
  7. readonly struct Key { }
  8. static readonly SharedStatic<Random> sharedStatic = SharedStatic<Random>.GetOrCreate<Key>();
  9. public static ref Random Random
  10. {
  11. get
  12. {
  13. if (sharedStatic.Data.state == 0) sharedStatic.Data.InitState();
  14. return ref sharedStatic.Data;
  15. }
  16. }
  17. }
  18. }