Unite Europe 2017 - Squeezing Unity: Tips for raising performance
Vložit
- čas přidán 29. 08. 2024
- Mark and Ian from Unity's Enterprise Support team run through performance best practices drawn from real-world problems. Learn the underlying architecture of Unity's core systems to better understand how to push Unity to its absolute limits.
For more information on Unite Europe and future Unite events visit this page. unite.unity.com/
Slides available here: www.slideshare...
Ian Dundore - Unity Technologies
3:31 - Particle Systems: withChildren parameter and other things
7:14 - Array-returing APIs (e.g. Mesh.vertices, Input.touches, GetComponents, RaycastAll)
9:07 - Camera.main [part 1]
9:32 - Choosing between collections (list, dictionary, hash-set)
15:43 - Use Instance ID as a key for dictionaries
18:38 - Method inlining
23:29 - Unity UI
25:59 - Notable exception from Unity UI dirtying
28:00 - Slice up your Canvases! (and nest them)
30:48 - Disabling Pixel Perfect for scrolling UI
31:31 - Optimizing Scroll Rect in particular
32:24 - Disabling unneeded UI raycasting
33:58 - Not leaving Event Camera property blank
37:31 - Camera.main [part 2]
39:05 - Optiziming Layout (even when not using them!)
45:55 - Pooling UI in the correct order
46:47 - Hiding Canvases correctly
48:03 - Not using Animators on UI (unless always changing already)
You're a saint.
instaBlaster...
Based on this video, it seems that Unity has more work to do than any of us...
I love how Ian's talks are always about which parts of Unity are to be avoided
Solid information here, but I really must say that is one nice jacket man!
this is definitely the best talk this year, hope we can have more advice from this awesome guy soon !
I like this guy. He's calling out bad design in unity itself and how to work around it. I wonder if anything he's called out here got optimized since?
I must say I've seen dozens of I.T. tech presentations in my day and this ranks as one of the best. Very informative, around 35% is common sense if you are an experienced developer but there are some gems in here, the UI section was interesting.
"Don't do that." - Ian
Unacceptable.
DUDE! I had no idea Pixel Perfect was THAT heavy.. makes sense now that I think about it though. Damn that has made a massive half order of magnitude difference to certain scroll heavy parts of my projects. Thanks Ian!
Is 2020 and still the best performance tips what I usualy recommend to watch!
We need more talk like this instead of all the beginner's stuff they are focusing on all these days
Especially when this information getting outdated everyday.
Dude you saved me 10 ms for just UI optimization. I had no idea layout groups comes at this cost. a bit late to this session, but better late than never.
one of the best talks of Unite ever
the problem of Unity Learn or other official tutorials for beginner is that they always teach your an official wrong way first ,then re-correct your mind again in the advanced workshop a few years later.
Amazing talk! i will need to watch this one a few times.
Excellent talk with various points that are immediately actionable on multiple projects for me so thanks very much!
Bruh you went crazy with the suit! The talk was absolutely fantastic as well! You did a hell of a job from last year to now keep it up and you’ll be seeing some bread come your way somehow!
Excellent talk. Ian's talk is a great blend of information and entertainment.
So we're now at unity2019, how much of this is still relevant?
mid 2020, actually, and still VERY MUCH.
Even though ECS is there, this talk goes into data structures (or C# in general) and - as a main topic - UI, which isn't and will probably never by substituted by an ECS equivalent.
@@47Mortuus good i watched this video i thought they fixed it by 2021
2020 LTS, animator on UI still hit profiling. Keep use dotween or whatever tween you like.
What an awesome talk. Hope the UI lead made it home OK.
[23:46] UI optimalization
"How to solve your performance issue:
1. dont use the unity component
2. write your own custom solution
3. OR use it in this unintuitive and unrecommended way that contradicts official unity tutorials"
Really? Reeeaaaaaaally? ... "Unacceptable"
Maybe programming isn't for you
You can't expect the tools to do everything for you. Sometimes the tools themselves are broken and you have to write workaround, this has happened since the dawn of languages and compilers.
Making your own solutions to problems is part of game development. Don't expect everyone to make the game for you.
Did he just scold someone at 30:31?
Awesome video tutorial! So many useful information... worth of thousands of dollars.
That was a fabulous presentation. Thank you so much!
This guy is amazing
best presentation of all
I really am very happy that Unity published their C# code (as mentioned within this talk), but 90% of it is just extern signatures to their C++ code, where 90% of the real code actually lives. Any chance you're ever going to publish *that*? Even the subset directly referenced by the extern signatures would be very helpful. Also, almost everything you've mentioned here is programmatically detectable with static analysis. Have you considered publishing a tool similar to Microsoft's Code Analysis and / or ReSharper's Inspector? It would need to analyze both the scene Hierarchy and the game's script code, but that seems entirely doable.
Wow, that was insane!! Love it!
Incredible talk, thank you so much !
I've profiled 25 world space canvases with the event camera set vs not set...
I've profiled this same set of canvases with the graphics raycasters enabled and disabled...
I've profiled this same set of canvases with the textmeshpros on them set to Enable Raycast Target, and un-enabled...
I've got to say, I can't reproduce any significant performance increase from doing any of these things. It's really frustrating not to be able to verify these things. Did they get addressed in later versions of Unity?
I definitely liked the presenter though. Didn't seem like a bullshitter... wondering if I'm doing something wrong.
I’m on the same boat. I had about 20 transparent and animated child ui objects on one Canvas, and adding a canvas to them did absolutely nothing. 2022 Unity, wondering if it’s necessary anymore.
Programming stuff is basically a list of things that you normally study in a Computer Science career. I suggest people who came from a different background to study computer science / software engineering books, to get better at these things.
great speaker, and amazing tips !
If you maintain a list of objects with tags, why don't you update Camera.main when an object with the "MainCamera" tag is added or removed. That way access will always be up to date and super super fast.
I appreciate that this talk is targeted at the people using existing Unity versions.. but I'd love to see Unity aggressively seek out ways to fix these issues that are really well known.
I think the answer is that fir sine cases and some games, that would be much less effecient. The truth is that when is comes to caching, the optimal solution depends very much on the specific case, so Unity probably couldn't make something that would be properly satisfying for the general case anyway. So they leave it the programmer who should find the best solution for his code himself.
Those functions are not meant for production, they are meant for prototyping.
^ that, its a universal engine, they cant assume the optimizations your game needs. I'm not saying they can't improve a lot of stuff. But some of the stuff you just have to know for your use case because its hard to make it a universal implementation
Thank you, honest and concise.
So, then is better do public variables and drag&drop objects from the Hierarchy to the slot created on the script at the inspector instead of using findwithtag code?
Púlsar Yes! Serialized attributes are faster to assign the values then any find method.
Usually find methods are not the best for performance, although they can be very handy for some generic code.
But always keep in mind what the guy said in the beginning: profiling. I would recommend only do optimizations in general if your profiler is telling you to do. Sometimes the best optimization is to save the developer’s health and energy :)
Yes, serialization is a lot faster (it is just a reference, when re-loading the project maybe a load from hdd/ssd) as opposed to a search inside the whole scene.
Thanks man! Great work.
This video just saved my VR project. Excellent video and very valuable info!
love this guy.
GREAT TALK!! why do the calls like RaycastNonAlloc take different parameters to the originals, seems less intuitive just just swap to them if u need to rethink code etc.
Well that was bloody amazing. nice work!
But I agree with the comments. It does seem like Unity Guesses alot of things that we should know that the tutorials don't raise?
Where you buy those light bars from in the background? I could totally use a couple of those
I'd love to know what they were smoking when they designed half the things this guy is ripping on.
Making something that works as expected for tens of millions of people over hundreds of thousands of projects for dozens of different platforms from multiple different platforms.
Code magician.
This guy is my sleep paralysis demon
Thanks
7:35 what does he mean by 'APIs' when he says Beware of API's that returns arrray?
9:27 in other parts of code sometimes we might have FindObjectWithTag, why is camera.main especially pointed out here?
11:36 What does he mean by 'Overhead' , it takes more time?
If you need to split up your UI across multiple canvases how do your manage depth / layers?
If I have a static UI canvas and dynamic UI canvas, how would I have a static element in front of a dynamic element which is in front of another static element e.g. static text in front of dynamic animation in front of static background image?
If you say to split up the static elements in separate canvases then the hierarchy is going to be huge, flat and hard to manage and we're heading towards just having a canvas per element!
Those are just general guidelines, of course each project has different needs, things that work on one may probably not work on another, so it's up to you to decide the best approach for each one.
But the whole point is how the canvases are dirtied and he specifically recommends a static UI canvas for elements which will never change and that canvas will never be dirtied. This just doesn't seem possible when the entire sorting for Unity's UI is based on hierarchy order. It'd be fine if it was like NGUI where you explicitly specify depth.
can't remember so well how NGUI worked, was hardly in touch with it, but i can't see any possibility to have multiple canvases that are "interlaced" in depth and do not force draw calls and rebuilds onto each other (because of depth sorting), which would defy the meaning of a canvas.
i think you are right that he oversimplified things pretty much - you can't just separate all dynamic staff from all static stuff and render independently, that only works if all dynamic stuff is in front of all static stuff and vice versa.
still, you can try to cut away everything that changes often from that large chunk of rather static UI that you often have via subcanvases. also try to group stuff that usually changes at the same time.
some static ui elements mixed into the dynamic canvases wont hurt you too much, however, some dynamic ui in your large static canvases probably will.
Yeah exactly.
Are there any more videos like this that anyone can recommend that have solid tips and tricks like this?
Do you have a link to the Andy Touch presentation you referenced?
“This talk will be quick because there’s so much information.”... *a minute and a half later* ...”So those are some of the reasons why I won’t have time to finish.“
for UI elements, couldn't you disable the animator after the animation is done?
As I understood it: Even if you have an Animation-State without motion attached it should be already fine. (like the default empty state for example)
how about if non alloc's array is only consist of 2 or 3 of max size? will that be fine?
Where do I find the talk on the update manager pattern you mention at 12:02? Can't find it anywhere on Unite 2016 talks.
www.slideshare.net/ozlael/optimizing-mobile-applications-ian-dundore-mark-harkness
Thank you very much! Thing is I watched the presentation itself and they didn't talk about it. So it's only in the slides then, right?
Slide 74-78. Unfortunately I did not find the video.
Thank you for the information. Where can I find a copy of the powerpoint slides?
in the link above
Does anyone know where I can find the Andy Touch UI talk from Unite Asia he references?
just started with coding and didnt understand a word... maybe one time, i put it on "watch later"...
Whats a good way to handle garbage of classes like event args (or any classes that are used to pass data around)? In a normal C# app/program if you need event args for a event you just create a new instace of the args and pass it to the event, but that would cause a lot of garbage. Is that fine in Unity to create new args instance (garbage) for every event call or should we recycle them somehow?
Depends on the amount and frequency used. Maybe you wont even notice it if you are doing it like once a minute or something. But object pooling is always a good idea as long as it does not add a lot of overhead.
How can I get in touch with Ian Dundore, got some suggestions on UI optimization.
Don't use Animation for UI instead use Tweening or your custom code! is This still valid? Unity 2019/20
Is this still relevant in 2021?
This guy's voice sounds super familiar. Ian, are you a secret anime voice actor?
Is there a GetParticles that does not allocate memory?
GetParticles() doesn't allocate memory. It uses a preallocated array.
Please, share presentation
Nice
3:37 Happy Dani noises
23:51 How does Unity UI work?
Answer: poorly and buggy, that's when it does work of course...
Here's a tip to Unity: Learn MVC!
f**k me, 347 likes to 0 dislikes. is that a youtube record???
basically he says to not use their UI
Cff
Can't understand most of it... :'(
But impressive how he seems to be shitting on the Unity Devs for having stupid implementation ideas. :P
That's more of "We did not have any other choice" mixed with "The guy was too lazy" shitting.
The Unity UI is a hot mess. I hate every second I have to work with it.
Allah الله
This video is a laugh, uploaded by unity makes it more of a laugh.
The guy is telling you for about an hour not to use unity or any of its features.
What do you expect from the company that made C sharp their scripting API, in the brain's dept , they are lacking.
*But hey, at least it works on mobile, sometimes, depends, don't know, maybe, what an idiotic engine by idiotic people.
You guys should see all the billion videos they made on how to cheat their own "Monobehaviour" that they don't know how to get rid of, or how to never search for a geme object.
Good luck using plugins as well, that is, if they won't crash as soon as you try to load the .DLL (Not actually accessing it, just loading it), and ask them about their IPC support (Only works on x86 sometimes).
a horrible talk, they practically admit what terrible engineering unity is and dont do anything about it