Unite Europe 2017 - Squeezing Unity: Tips for raising performance

Sdílet
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

Komentáře • 109

  • @dogfuntom
    @dogfuntom Před 5 lety +278

    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)

  • @nexxogen
    @nexxogen Před 6 lety +142

    Based on this video, it seems that Unity has more work to do than any of us...

  • @darkee03
    @darkee03 Před 7 lety +76

    I love how Ian's talks are always about which parts of Unity are to be avoided

  • @chasebsnow
    @chasebsnow Před 7 lety +137

    Solid information here, but I really must say that is one nice jacket man!

  • @anzo06
    @anzo06 Před 7 lety +55

    this is definitely the best talk this year, hope we can have more advice from this awesome guy soon !

  • @justinwhite2725
    @justinwhite2725 Před 3 lety +9

    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?

  • @davedogge2280
    @davedogge2280 Před 4 lety +9

    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.

  • @PopsiclesInMyCellar
    @PopsiclesInMyCellar Před 6 lety +87

    "Don't do that." - Ian

  • @TheBendixSA
    @TheBendixSA Před 4 lety +7

    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!

  • @Hoglet.Interactive
    @Hoglet.Interactive Před 4 lety +3

    Is 2020 and still the best performance tips what I usualy recommend to watch!

  • @ruchirraj5300
    @ruchirraj5300 Před 3 lety +6

    We need more talk like this instead of all the beginner's stuff they are focusing on all these days

    • @maximcherstvi9877
      @maximcherstvi9877 Před 3 lety

      Especially when this information getting outdated everyday.

  • @ModernGS
    @ModernGS Před 3 lety +7

    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.

  • @luizguilhermepelegrini8297

    one of the best talks of Unite ever

  • @hweeli6228
    @hweeli6228 Před 2 lety +5

    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.

  • @DrClementShimizu
    @DrClementShimizu Před 5 lety +3

    Amazing talk! i will need to watch this one a few times.

  • @Whitemanafro
    @Whitemanafro Před 7 lety +3

    Excellent talk with various points that are immediately actionable on multiple projects for me so thanks very much!

  • @quentinturner3753
    @quentinturner3753 Před 6 lety +1

    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!

  • @akisey1
    @akisey1 Před 7 lety

    Excellent talk. Ian's talk is a great blend of information and entertainment.

  • @salientking7336
    @salientking7336 Před 5 lety +38

    So we're now at unity2019, how much of this is still relevant?

    • @47Mortuus
      @47Mortuus Před 4 lety +13

      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.

    • @haithammahmoud6825
      @haithammahmoud6825 Před 3 lety

      @@47Mortuus good i watched this video i thought they fixed it by 2021

    • @edigunawan2991
      @edigunawan2991 Před 2 lety

      2020 LTS, animator on UI still hit profiling. Keep use dotween or whatever tween you like.

  • @gregsmith80
    @gregsmith80 Před 2 lety +1

    What an awesome talk. Hope the UI lead made it home OK.

  • @unityberserkers8351
    @unityberserkers8351 Před 7 lety +24

    [23:46] UI optimalization

  • @stephenlucerne1052
    @stephenlucerne1052 Před 5 lety +32

    "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"

    • @47Mortuus
      @47Mortuus Před 4 lety +5

      Maybe programming isn't for you

    • @davedogge2280
      @davedogge2280 Před 4 lety +1

      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.

    • @elektra81516
      @elektra81516 Před 3 lety

      Making your own solutions to problems is part of game development. Don't expect everyone to make the game for you.

  • @guitarmanzubin
    @guitarmanzubin Před 5 lety +10

    Did he just scold someone at 30:31?

  • @rickloyd8208
    @rickloyd8208 Před 4 lety

    Awesome video tutorial! So many useful information... worth of thousands of dollars.

  • @ClintonWBlackmore
    @ClintonWBlackmore Před 6 lety

    That was a fabulous presentation. Thank you so much!

  • @jamesk7416
    @jamesk7416 Před 7 lety +3

    This guy is amazing

  • @jaycelee8453
    @jaycelee8453 Před 5 lety

    best presentation of all

  • @msthalamus2172
    @msthalamus2172 Před 5 lety +2

    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.

  • @VictorAlmeidaTroo
    @VictorAlmeidaTroo Před 3 lety

    Wow, that was insane!! Love it!

  • @dax60840
    @dax60840 Před 7 lety

    Incredible talk, thank you so much !

  • @logan4179
    @logan4179 Před 2 lety +2

    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.

    • @snooksv3172
      @snooksv3172 Před rokem +1

      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.

  • @darksidegirl
    @darksidegirl Před 2 lety

    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.

  • @AlexStrook
    @AlexStrook Před 7 lety

    great speaker, and amazing tips !

  • @garrynewman
    @garrynewman Před 7 lety +5

    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.

    • @sanderhansen7036
      @sanderhansen7036 Před 6 lety +5

      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.

    • @CodingWithUnity
      @CodingWithUnity Před 6 lety +2

      ^ 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

  • @0brn0
    @0brn0 Před 7 lety

    Thank you, honest and concise.

  • @Pentazemin
    @Pentazemin Před 7 lety +6

    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?

    • @guiquadros35
      @guiquadros35 Před 6 lety +3

      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 :)

    • @armpap1
      @armpap1 Před 6 lety +1

      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.

  • @jamesk7416
    @jamesk7416 Před 7 lety

    Thanks man! Great work.

  • @TheOriginalDarkGlitch
    @TheOriginalDarkGlitch Před 6 lety

    This video just saved my VR project. Excellent video and very valuable info!

  • @aaronsonglu9137
    @aaronsonglu9137 Před 5 lety

    love this guy.

  • @TYNEPUNK
    @TYNEPUNK Před rokem

    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.

  • @D3kryption
    @D3kryption Před 3 lety

    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?

  • @Jay-dp2mg
    @Jay-dp2mg Před 6 lety +1

    Where you buy those light bars from in the background? I could totally use a couple of those

  • @sirflimflam
    @sirflimflam Před 7 lety +34

    I'd love to know what they were smoking when they designed half the things this guy is ripping on.

    • @kaldo_kaldo
      @kaldo_kaldo Před 6 lety +31

      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.

  • @VisserGoedHart
    @VisserGoedHart Před 7 lety +17

    Code magician.

  • @_g_r_m_
    @_g_r_m_ Před 3 lety +2

    This guy is my sleep paralysis demon

  • @f1rstFragged
    @f1rstFragged Před 5 lety +1

    Thanks

  • @94D33M
    @94D33M Před 5 lety

    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?

  • @TwoTwoDogs
    @TwoTwoDogs Před 7 lety +3

    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!

    • @trisibo
      @trisibo Před 7 lety

      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.

    • @TwoTwoDogs
      @TwoTwoDogs Před 7 lety +1

      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.

    • @MichaelBrunner_nur_Michi
      @MichaelBrunner_nur_Michi Před 7 lety +2

      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.

    • @TwoTwoDogs
      @TwoTwoDogs Před 7 lety

      Yeah exactly.

  • @mosth8ed
    @mosth8ed Před 6 lety

    Are there any more videos like this that anyone can recommend that have solid tips and tricks like this?

  • @zandarius100
    @zandarius100 Před 7 lety

    Do you have a link to the Andy Touch presentation you referenced?

  • @studyzen8836
    @studyzen8836 Před 4 lety

    “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.“

  • @ChillinGames
    @ChillinGames Před 3 lety

    for UI elements, couldn't you disable the animator after the animation is done?

    • @romanwache3788
      @romanwache3788 Před 2 lety

      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)

  • @boblester122
    @boblester122 Před 6 lety

    how about if non alloc's array is only consist of 2 or 3 of max size? will that be fine?

  • @JaseMourne
    @JaseMourne Před 7 lety +1

    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.

    • @vladlomakin4807
      @vladlomakin4807 Před 7 lety +1

      www.slideshare.net/ozlael/optimizing-mobile-applications-ian-dundore-mark-harkness

    • @JaseMourne
      @JaseMourne Před 7 lety

      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?

    • @vladlomakin4807
      @vladlomakin4807 Před 7 lety +1

      Slide 74-78. Unfortunately I did not find the video.

  • @Endar0
    @Endar0 Před 7 lety +1

    Thank you for the information. Where can I find a copy of the powerpoint slides?

  • @sylvaind
    @sylvaind Před 7 lety

    Does anyone know where I can find the Andy Touch UI talk from Unite Asia he references?

  • @voidling2632
    @voidling2632 Před 5 lety +1

    just started with coding and didnt understand a word... maybe one time, i put it on "watch later"...

  • @r1pfake521
    @r1pfake521 Před 6 lety

    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?

    • @armpap1
      @armpap1 Před 6 lety

      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.

  • @younghsiang2509
    @younghsiang2509 Před 6 lety

    How can I get in touch with Ian Dundore, got some suggestions on UI optimization.

  • @MohammadFaizanKhanJ
    @MohammadFaizanKhanJ Před 3 lety

    Don't use Animation for UI instead use Tweening or your custom code! is This still valid? Unity 2019/20

  • @allanmacdonald2943
    @allanmacdonald2943 Před 3 lety

    Is this still relevant in 2021?

  • @drakel5943
    @drakel5943 Před 4 lety

    This guy's voice sounds super familiar. Ian, are you a secret anime voice actor?

  • @romainpedra
    @romainpedra Před 7 lety

    Is there a GetParticles that does not allocate memory?

    • @LegatoCirion
      @LegatoCirion Před 7 lety

      GetParticles() doesn't allocate memory. It uses a preallocated array.

  • @unityplugins591
    @unityplugins591 Před 7 lety

    Please, share presentation

  • @animallovers5443
    @animallovers5443 Před 4 lety

    Nice

  • @Kitulous
    @Kitulous Před 3 lety

    3:37 Happy Dani noises

  • @VMEcycle6
    @VMEcycle6 Před rokem

    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!

  • @lancsFrogger
    @lancsFrogger Před 7 lety

    f**k me, 347 likes to 0 dislikes. is that a youtube record???

  • @victorapihtin9302
    @victorapihtin9302 Před 3 lety

    basically he says to not use their UI

  • @anmollodhi501
    @anmollodhi501 Před 3 lety

    Cff

  • @ZoidbergForPresident
    @ZoidbergForPresident Před 7 lety +22

    Can't understand most of it... :'(
    But impressive how he seems to be shitting on the Unity Devs for having stupid implementation ideas. :P

    • @armpap1
      @armpap1 Před 6 lety +3

      That's more of "We did not have any other choice" mixed with "The guy was too lazy" shitting.

  • @scotthorton3339
    @scotthorton3339 Před 3 lety

    The Unity UI is a hot mess. I hate every second I have to work with it.

  • @cgmohammed
    @cgmohammed Před 3 lety

    Allah الله

  • @Illasera
    @Illasera Před rokem

    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).

  • @victorapihtin9302
    @victorapihtin9302 Před 3 lety

    a horrible talk, they practically admit what terrible engineering unity is and dont do anything about it