JohannesMP/unity-scene-reference

Terrible Editor performance

STARasGAMES opened this issue · 4 comments

Great plugin!
But I found a performance issue in BuildUtils.GetBuildScene() :

            for (int index = 0; index < EditorBuildSettings.scenes.Length; ++index)
            {
                if (entry.assetGUID.Equals(EditorBuildSettings.scenes[index].guid))
                {
                    entry.scene = EditorBuildSettings.scenes[index];
                    entry.buildIndex = index;
                    return entry;
                }
            }

Here we have too many calls to EditorBuildSettings.scenes which cause noticeable lags and freezes. And now I have only 80 scenes in my project.

A solution would be just to cache EditorBuildSettings.scenes call:

            var scenes = EditorBuildSettings.scenes;

            for (var index = 0; index < scenes.Length; ++index)
            {
                if (!entry.assetGUID.Equals(scenes[index].guid)) continue;

                entry.scene = scenes[index];
                entry.buildIndex = index;
                return entry;
            }

Hope I helped :D

Thank you, I'll take a look at it.
The credit goes to @JohannesMP for creating this plugin.

Closed with #4

Thanks @starikcetin for maintaining this, really appreciate it!

@JohannesMP My pleasure 😊