Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making long roadmesh runtime
#11
Hi,
Here is a Unity forum thread about that issue:
https://forum.unity.com/threads/loading-updatepreloading-taking-up-precious-time-for-no-reason.252578/
It's a long thread, but it seems that it's a long running issue that can be avoided by commenting calls to Resources.UnloadUnusedAssets().
Also, someone said that it might happen only in the editor, but I would advise you to make sure of that yourself by profiling a build.
Let me know if that solved the issue.
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#12
ok. im still not sure whats calling that Resources.UnloadUnusedAssets()
Reply
#13
Curvy Splines has a couple of those calls, but it can also come from other parts of your project. You can easily find out by doing a research on all files (CTRL+SHIFT+F on most code editors) of the string "Resources.UnloadUnusedAssets()"
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#14
thanks. i found one call from curvy: \Assets\Plugins\Curvy\Base\CG Modules\CreateMesh.cs at line 523. i commented that out and lag spike is gone

i hope that modification does not make any problems to my project Big Grin
Reply
#15
As you can read here:
https://docs.unity3d.com/ScriptReference/Resources.html
"Some loaded assets, most notably textures, can use up memory even when no instance exists in the Scene. To reclaim this memory when the asset is no longer needed, you can use Resources.UnloadUnusedAssets."
This is related to only assets loaded via the Resources class, and not ones assigned through the inspector.

Assets loaded by Curvy Splines via the Resources.Load method are not numerous. It loads the CurvyDefaultMaterial material, and the icons for the UI. That's it. So Resources.UnloadUnusedAssets does not do much, since the icons for the UI are referenced for the life time of the Unity session, only CurvyDefaultMaterial is unloaded if not used anymore.

To sum up, I don't believe that commenting that line would be an issue. If it happens to be, please let me know.
Also, do you have a huge number of assets? This is the only explanation I find for Resources.UnloadUnusedAssets to take so much time.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#16
thanks. this is new informantion for me. i have many assets in my game. it feels like i should call "Resources.UnloadUnusedAssets()" in save and loadgame.. or anywhere where i can put some kind of loading screen Big Grin
Reply
#17
Maybe it's a good idea. I don't have enough experience using that method to say for sure. Just make sure it is worth it by profiling what's happening cpu and memory wise.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#18
hi again. how do i destroy the road safely? i used to do this by manually destroying child of "Create Mesh" which is named "Create Mesh_5_Mesh000" which is holding the mesh, but i got somekind of pooling errors from it. i guess that is not the right way
Reply
#19
Could you send me the error message, and if possible a reproduction case?
As far as I know, and in my tests, calling Destroy(yourMeshGameObject) works. You could also call yourCreateMeshModule.Clear()
Let me know if that works for you.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#20
in my case sometimes i want to destroy road before i save it to scene. CreateMesh.Clear() is working fine. no errors

here is the error that popped up sometimes when i deleted the road under Create Mesh object:
InvalidOperationException: [Curvy] Could not create managed resource of type 'Mesh'. In some cases this is due to not enough elements in a resources Pool
FluffyUnderware.Curvy.Generator.CGModule.AddManagedResource (System.String resourceName, System.String context, System.Int32 index) (at Assets/Plugins/Curvy/Base/CG/CGModule.cs:609)
FluffyUnderware.Curvy.Generator.Modules.CreateMesh.getNewMesh () (at Assets/Plugins/Curvy/Base/CG Modules/CreateMesh.cs:819)
FluffyUnderware.Curvy.Generator.Modules.CreateMesh.writeVMeshToMesh (FluffyUnderware.Curvy.Generator.CGVMesh& vmesh) (at Assets/Plugins/Curvy/Base/CG Modules/CreateMesh.cs:762)
FluffyUnderware.Curvy.Generator.Modules.CreateMesh.createMeshes (System.Collections.Generic.List`1[FluffyUnderware.Curvy.Generator.CGVMesh]& vMeshes, System.Boolean combine) (at Assets/Plugins/Curvy/Base/CG Modules/CreateMesh.cs:678)
FluffyUnderware.Curvy.Generator.Modules.CreateMesh.Refresh () (at Assets/Plugins/Curvy/Base/CG Modules/CreateMesh.cs:565)
FluffyUnderware.Curvy.Generator.CGModule.doRefresh () (at Assets/Plugins/Curvy/Base/CG/CGModule.cs:833)
FluffyUnderware.Curvy.Generator.CurvyGenerator.Refresh (System.Boolean forceUpdate) (at Assets/Plugins/Curvy/Base/CG/CurvyGenerator.cs:600)
FluffyUnderware.Curvy.Generator.CurvyGenerator.TryAutoRefresh () (at Assets/Plugins/Curvy/Base/CG/CurvyGenerator.cs:627)
FluffyUnderware.Curvy.Generator.CurvyGenerator.Update () (at Assets/Plugins/Curvy/Base/CG/CurvyGenerator.cs:265)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
Wink Modifying Splines at Runtime artsung 1 7 01-30-2024, 09:40 AM
Last Post: _Aka_
  Is it possible to create a road texture at runtime? artsung 1 4 01-30-2024, 09:30 AM
Last Post: _Aka_
  Cant Generate Meshes At Runtime alms94 5 22 01-26-2024, 11:27 AM
Last Post: _Aka_

Forum Jump: