Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Bug Asset delete - big performance overhead

Discussion in 'Scripting' started by dmaj, Feb 7, 2023.

  1. dmaj

    dmaj

    Joined:
    Feb 5, 2019
    Posts:
    3
    I have noticed that every first asset deletion in my project (which is quite big) takes around 10s, but after that it runs smoothly. I have profiled it and it says that it is because of ProjectWindowUtil.AnyTargetMaterialHasChildren method. It made me suspicious, because the asset that I have deleted wasn't a material.

    Take a look at the code in repository, lines 995-1015:
    https://github.com/Unity-Technologi...ditor/Mono/ProjectWindow/ProjectWindowUtil.cs

    Fist it checks whether any deleted asset is a material and stores it to "containsMaterial" flag.
    But after that, it makes a bitwise 'and' operation '&' while it is obvious that it should be a logical 'and' '&&'.
    containsMaterial &= AnyTargetMaterialHasChildren(paths);


    Changing it to:
    containsMaterial = containsMaterial && AnyTargetMaterialHasChildren(paths);

    Would save our team 10s every time we delete the first asset after opening editor, which would be another small step to make the editor responsive.

    delete_file_spike.png
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,455
    You could make a bug report for this with this post attatched. Make sure to upload a project with the performance issue not fixed