Basics of Optimization in Unity

Unity Profiler Course

Using the unity Profiler, we can optimize the game but how do we optimize the code to optimize the game.

We can use Profiler inside the code to seal a set of code which can be used to confirm the frame spike from that set of code.

Here, Vector3 and GameObject both use new keyword but the Vector3 doesn’t cause frame spike as much as GameObject while using new keyword because Vector3 is a Struct which is a value type and does not allocate memory while GameObject is a Class which is a reference type and allocate memory. So you should cache the new keyword when using with reference types to optimize code.

It is also better to use List rather than Array as it is more performance friendly and easy to navigate and use.




Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How do you create an Efficient Data Structure for Spatial Indexing?

Analog Enters MVB IV Incubation Program By BNB Chain

Copy-by-value Vs Copy-by-reference

Introducing the Summer of Kubernetes

Java Heap Space OOM on Eclipse MAT — How to fix

Getting started with AWS X-Ray

PySpark Broadcast and Accumulator

MADNFT Weekly Update

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niraj Karki

Niraj Karki

Unity Developer

More from Medium

Using GetComponent in Unity for Script Communication!

Create a Lens Flare in Unity 2021 using HDRP

Getting a Clue with GetComponent — Script Communication in Unity.

Adding Emissions