01-14-2022, 02:10 PM
Hi!
I was testing Curvy Spline and noticed that there is a huge amount of time spent inside DuplicateEditorMesh.Awake when you have a scene with a lot of object (and DuplicateEditorMesh component in the scene).
For example, for 770 DuplicateEditorMesh component in a scene, you'll get ~5000 ms spent in possibly doing nothing in that method.
Just because we are consistently make use of FindObjectsOfType<DuplicateEditorMesh>() and iterating through the result to find potential identical sharedMesh.
Do you have already encountered performance issue with that compoenent?
(well with inheriting components too, like CGMeshResource in my case).
If that Awake method is onlt here to catch duplicate in Editor, why not using the OnValidate and check the Event.type to catch Paste and Duplicate commands?
Also, instead of constently calling FindObjectsOfType, will it be more efficient to maintain (only in Editor) a list of Awaken component of that type?
Thanks for your shared experience!
Here is the DuplicateEditorMesh.Awake code:
I was testing Curvy Spline and noticed that there is a huge amount of time spent inside DuplicateEditorMesh.Awake when you have a scene with a lot of object (and DuplicateEditorMesh component in the scene).
For example, for 770 DuplicateEditorMesh component in a scene, you'll get ~5000 ms spent in possibly doing nothing in that method.
Just because we are consistently make use of FindObjectsOfType<DuplicateEditorMesh>() and iterating through the result to find potential identical sharedMesh.
Do you have already encountered performance issue with that compoenent?
(well with inheriting components too, like CGMeshResource in my case).
If that Awake method is onlt here to catch duplicate in Editor, why not using the OnValidate and check the Event.type to catch Paste and Duplicate commands?
Also, instead of constently calling FindObjectsOfType, will it be more efficient to maintain (only in Editor) a list of Awaken component of that type?
Thanks for your shared experience!
Here is the DuplicateEditorMesh.Awake code:
Code:
protected virtual void Awake()
{
if (!Application.isPlaying)
{
MeshFilter meshFilter = Filter;
if (meshFilter && meshFilter.sharedMesh != null)
{
DuplicateEditorMesh[] otherWatchdogs = GameObject.FindObjectsOfType<DuplicateEditorMesh>();
foreach (DuplicateEditorMesh dog in otherWatchdogs)
{
if (dog != this)
{
MeshFilter otherMF = dog.Filter;
if (otherMF && otherMF.sharedMesh == meshFilter.sharedMesh)
{
Mesh m = new Mesh();
m.name = otherMF.sharedMesh.name;
meshFilter.mesh = m;
}
}
}
}
}
}