Non-uniform Scaling Performance Issues. Need advice.

Hello,

First time asking a question here, so ill try explain my situation as best I can:

I’m making a side-scrolling music game using a C# FModEx library. All music data related functions are ran on separate threads (just in case that information is relevant). Here is a short video demonstrating what im making
[[YouTube Link]][3]

In the main scene, I have 1000 cube primitives spanning from one side of the screen to the other created at runtime (see images below). When the song starts, the cubes are given floats to scale the y axis to. One block represents one millisecond. Here is the code for the scaling:

	private static void Dynamic()
	{
		for(int i = 0; i < Blocks.Length; i++)
		{
			Scale.y = (Analyzer.ScanDb[Analyzer.CurrentPosition + i] * 250.0f);
			Blocks*.transform.localScale = Scale;*
  •  }*
    
  • }*
    Right now im running at about 50-70 fps. So my main question is: Is there any way to make the scaling process less intensive or just a better process all together?
    Thanks in advance and i hope ive supplied enough information :slight_smile:
    [17533-idle.png|17533]*
    [17532-playing.png|17532]*

[3]: - YouTube

I’m not sure how primitives are handled by Unity, but prefabs are designed to be as efficient as possible for memory and rendering performance. Check out the number of draw calls your code is currently generating (via the profiler on the game panel), then switch the cube to a prefab and check again… it will probably reduce drastically. If the prefabbed cubes all use the same material etc they should only need one draw call to render them all.