LINQ and Unity

Leave a comment

May 7, 2014 by Nikos

One of the most frequent tidbits of advice you can find on the internet about Unity3D is to not use LINQ expressions in the game. I can understand how LINQ can be performance heavy but on the other hand it can be incredibly useful when building editor tools. Granted you must always strive to write efficient code but sometimes the trade off is a lot better.

For example some times you have to manipulate the scenes somehow and you have to gather specific objects to perform a modification but that set being in a densely populated scene might be more than enough to be a pain for manual selection. Depending on the situation you can do something as simple as GameObject.FindGameObjectsWithTag and it’ll be enough.But sometimes you want a smaller set of objects with the same tag. You can either write a loop of any kind and try to distinguish which objects you want or you can use a LINQ expression of one line.

Since LINQ has an SQL-esque syntax it will be easy for someone with SQL experience to use it for creating subsets of lists very easily.Subsets that you’d normally need nested loops  and if-statements to create.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Copyright

© Nikolaos Patsiouras and Adventure Game Adventures, 2013. Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Nikolaos Patsiouras and Adventure Game Adventures with appropriate and specific direction to the original content.
Mike Taulty

I do some developer stuff for Microsoft UK

Geoff Lester | Technical Artist

Game Development, CGI and Programming

Andrew Fray

On games programming and AI

Fuzzy Reflection

Personal Space for Self-Reflection

ScrawkBlog

Game programming and asset creation

bitsquid: development blog

blog about my projects,thoughts and other stuff

Graphics in Plain Language

blog about my projects,thoughts and other stuff

tavianator.com

blog about my projects,thoughts and other stuff

Andreas on Coding

Thoughts about programming.

Aras' website

blog about my projects,thoughts and other stuff

duangle

blog about my projects,thoughts and other stuff

extremeistan

thoughts about computer graphics, game engine programming

The ryg blog

When I grow up I'll be an inventor.

Coding in the Dark

A technical blog of game development.

Dan Luu

blog about my projects,thoughts and other stuff

Molecular Musings

Development blog of the Molecule Engine

Taking Initiative

Bobby Anguelov's Tech Blog

%d bloggers like this: