U3D 随机数

  1. using System.Security.Cryptographt;
  2. using System;

  3. byte[] randomBytes = new byte[4];
  4. RNGCryptoServiceProvider rngCrypto =
  5. new RNGCryptoServiceProvider();
  6. rngCrypto.GetBytes(randomBytes);

  7. int rngNum = BitConverter.ToInt32(randomBytes, 0) % n;//此为随机数

N是范围,用U3D的random太容易出相同数了;

猜你喜欢

转载自blog.csdn.net/qq_18604483/article/details/79077112
今日推荐