Thread: Improve My Unity Game Development Code

  1. #1
    Registered User Kyle Flores's Avatar
    Join Date
    Nov 2016

    Post Improve My Unity Game Development Code

    Hi, Being a learner. I am here to participate just like other Mobile Development Blogs to enhance my knowledge regarding Unity 3D & Android collaboration & I would like to Improve my code using threads, so the 1000000 random number generation runs without spoiling performance. which has become difficult to debug. I hope any tech developer help me in resolving this issue.

    class RandomGenerator : MonoBehaviour
        public float[] randomList;
        void Start()
            randomList = new float[1000000];
        void Generate()
            System.Random rnd = new System.Random();
            for(int i=0;i<randomList.Length;i++) randomList[i] = (float)rnd.NextDouble();

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Not sure what you mean by "spoiling performance"? Are you getting overflows or negative values, or is the random generation not 'random' enough?
    Double Helix STL

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    I think he means that he wants to parallelize the random array generation to take full advantage of the CPU's cores.
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner C Minesweeper game - How can i improve it?
    By NappySlapper in forum C Programming
    Replies: 6
    Last Post: 12-05-2016, 12:14 PM
  2. Please Improve my code
    By hariharaan in forum C Programming
    Replies: 0
    Last Post: 05-20-2015, 02:05 AM
  3. help improve my code
    By lambs4 in forum C Programming
    Replies: 3
    Last Post: 11-21-2001, 11:33 AM

Tags for this Thread