Search Unity

Should we use "Renderer.isVisible" to improve game performance?

Discussion in 'General Graphics' started by Asisvenia, Sep 15, 2018.

  1. Asisvenia

    Asisvenia

    Joined:
    Jun 30, 2018
    Posts:
    18
    Hello everyone,

    I've been making a 2D platform game for Android devices that's why performance is important for me. Game is completely based on pixel graphics but I still don't want excessive CPU overhead. So that I'm thinking to use that "isVisible" property.

    I have enemies on the platforms and they're moving either left or right (it's a side-scrolling game) that's why I thought cancelling those ones' movement who don't appear on the camera would be cause a performance increase.

    But also in the Update() function it'll be checked every frame is it visible or not, isn't that bad ?

    I'm very new to Unity, thanks for your answers.
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Some quick tips you may or may not know:
    • use culling groups api to cull large amounts of scripts or renderers
    • yes - disabling scripts is beneficial
    • using isVisible still means you need a script to check their visibility...
    The blog and manual have several pages on performance optimisation like this which go into further detai.

    Ultimately you want to become best friends with the Unity profiler. Don't optimise what isn't actually the bottleneck. That would be really dumb :)
     
    Asisvenia and AcidArrow like this.
  3. Asisvenia

    Asisvenia

    Joined:
    Jun 30, 2018
    Posts:
    18
    Thank you very much for your answer! :) It helped me a lot. I'll learn Unity profiler.