![]() |
Broken scripts with update 6 -> 7 - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Broken scripts with update 6 -> 7 (/thread-4428.html) Pages:
1
2
|
Broken scripts with update 6 -> 7 - hariedo - 21-12-2024 Had some issues with the update from Obi Rope 6 -> 7 in a project that used Obi Rope 6. Luckily it's a scratch project. 1. I tried upgrading on top of the old version but saw script errors so I removed all Obi files and installed fresh instead. Of course, I have scripts and prefabs that depend on the older Obi files, so all of those break in the process of installation. Even after the other issues were patched below, my existing code runs into Index Of Of Range errors on trying to load my existing rope blueprints, so now I have to see if it's a code issue or a blueprint schema change issue. [Edit: I see the forum update guide says you have to regen blueprints. I'm creating them from code, see below.] 2. The demo scenes use a resource script called FPSDisplay. It does not use a namespace, so it conflicted with another script I already had called FPSDisplay. This caused compilation errors and breaks the script references in scenes that used either one (my existing scenes, as well as your demo scenes.) Even after I added a namespace to my existing FPSDisplay, the script references were broken, so I had to add a namespace to your file and re-add it to the demo scene objects. I thought Unity demanded all assets used namespaces to avoid this sort of conflict. [Edit: Similar breakage on SlowmoToggler which does not have a namespace (I have no such script but your demo scene had a broken link to it and Unity couldn't find it until I added one).] 3. Many of your demo scenes use a built-in diffuse material for many objects. Please define your own material for these objects, so that when I update all materials to URP these objects don't remain pink. 4. There is no longer a type for ObiFixedUpdater. I had a script that expected this type to force a regeneration of ropes (as I would deactivate and reactivate ropes in proximity to the player). The CHANGELOG says all ObiUpdater types have been removed. No guidance on what to do about scripts that referenced them. Here is the code I'm trying to migrate. It generates new blueprints on the fly during Start. My prefab has four of these, and each one is spitting out Null Reference errors in your DrawGizmos in Edit mode. Quote:NullReferenceException: Object reference not set to an instance of an object Once I try running, I get Index Out Of Bounds errors in your ObiActor.LoadBlueprintParticles, when I provide the generated blueprint to ObiRope. One error per rope, with different starting index numbers. Quote:IndexOutOfRangeException: Writing to index 0 is out of range of '0' Capacity. Code: // TightRope.cs RE: Broken scripts with update 6 -> 7 - josemendez - 23-12-2024 (21-12-2024, 10:35 AM)hariedo Wrote: Had some issues with the update from Obi Rope 6 -> 7 in a project that used Obi Rope 6. Luckily it's a scratch project. Hi! You can't install Obi 7 on top of a pre-existing Obi 6 installation, doing so will cause multiple compilation errors due to missing files/newly added ones. You must delete the /Obi folder and do a fresh install as explained in the upgrade guide. Upgrading will require updating all your scripts and prefabs as warned in the manual. Several systems in Obi are now asynchronous (for instance, ObiRopeCursor) so scripting logic changes quite a bit. It's not a quick process. You should evaluate whether it's necessary for you to upgrade your project or stay on Obi 6, and maybe try 7 on upcoming projects. (21-12-2024, 10:35 AM)hariedo Wrote: Even after the other issues were patched below, my existing code runs into Index Of Of Range errors on trying to load my existing rope blueprints, so now I have to see if it's a code issue or a blueprint schema change issue. [Edit: I see the forum update guide says you have to regen blueprints. I'm creating them from code, see below.] There's been some changes to the scripting API as well, see the guide above. (21-12-2024, 10:35 AM)hariedo Wrote: 2. The demo scenes use a resource script called FPSDisplay. It does not use a namespace, so it conflicted with another script I already had called FPSDisplay. This caused compilation errors and breaks the script references in scenes that used either one (my existing scenes, as well as your demo scenes.) Even after I added a namespace to my existing FPSDisplay, the script references were broken, so I had to add a namespace to your file and re-add it to the demo scene objects. I thought Unity demanded all assets used namespaces to avoid this sort of conflict. Thanks for reporting this! FPSDisplay does not indeed have its own namespace, could find a few other sample scripts that don't either. Will fix this in the next update. (21-12-2024, 10:35 AM)hariedo Wrote: [Edit: Similar breakage on SlowmoToggler which does not have a namespace (I have no such script but your demo scene had a broken link to it and Unity couldn't find it until I added one).] This component is used in the "RopeAndJoints" scene, and it is added to the ObiSolver component. Just downloaded the asset fresh from the store but could not find any missing references/broken links to SlowmoToggler. Unity's asset verification process does not report any either. (21-12-2024, 10:35 AM)hariedo Wrote: 3. Many of your demo scenes use a built-in diffuse material for many objects. Please define your own material for these objects, so that when I update all materials to URP these objects don't remain pink. Diffuse materials should also be picked up by Unity's auto-updater. Most of the objects in the scenes just use the Standard shader. (21-12-2024, 10:35 AM)hariedo Wrote: 4. There is no longer a type for ObiFixedUpdater. I had a script that expected this type to force a regeneration of ropes (as I would deactivate and reactivate ropes in proximity to the player). The CHANGELOG says all ObiUpdater types have been removed. No guidance on what to do about scripts that referenced them. See the upgrade guide for details on what to do: Quote:In Obi 7, all ObiUpdater components have been removed. ObiSolvers now update themselves at the right time, automatically parallelizing work with other solvers in the scene. You should open up your scenes/prefabs and remove missing references to these components: Quote:Here is the code I'm trying to migrate. It generates new blueprints on the fly during Start. Will try your script and get back to you asap. At a first glance, the cursor related code acts as if the change in length is immediate - which no longer is - so it will likely break. kind regards, RE: Broken scripts with update 6 -> 7 - hariedo - 23-12-2024 Quote:In Obi 7, all ObiUpdater components have been removed. ObiSolvers now update themselves at the right time, automatically parallelizing work with other solvers in the scene. You should open up your scenes/prefabs and remove missing references to these components: Yes, I saw that. I had an editor script that would seek them out and ensure they were added to the solver, so that I could then seek out and .Generate all the dynamically created ropes at edit time. If we can fix my TightRope script above, then I think we're okay. Quote:You should evaluate whether it's necessary for you to upgrade your project or stay on Obi 6, and maybe try 7 on upcoming projects. As mentioned at the top of the thread, this IS evaluating 7 on a scratch project. That doesn't mean I want to just throw out useful mechanisms that I have set up in my library of scripts and prefabs. I also am considering buying the last Obi asset, Softbody, and am not going to attempt to have Obi 6 Rope for compatibility and Obi 7 Softbody in the same project. Quote:Diffuse materials should also be picked up by Unity's auto-updater. Most of the objects in the scenes just use the Standard shader. There are two "auto-updaters" in Unity. One goes through the whole project looking for stuff to mangle, and one just updates the selected materials in the selected folder. There's no middle ground to just update scenes in the Obi sample folder. If your demo scenes don't rely on BiRP materials, then updating materials in the Obi folder would be sufficient. Just a suggestion on how to make your asset bulletproof. RE: Broken scripts with update 6 -> 7 - hariedo - 09-01-2025 Any luck in scripting a means to create a Rope Blueprint on the fly, that won't throw IORs? RE: Broken scripts with update 6 -> 7 - josemendez - 09-01-2025 (09-01-2025, 01:20 AM)hariedo Wrote: Any luck in scripting a means to create a Rope Blueprint on the fly, that won't throw IORs? Hi, In your code you call LoadBlueprint() manually: just remove that line and the problem should be fixed. Manually calling LoadBlueprint isn't needed in most cases -unless you're doing something out of the ordinary - as it's automatically called by ObiSolver at the right time as explained in the API docs. Calling it when the solver has not been initialized yet will result in index out of bounds, as the blueprint tries to access the (yet uninitialized) solver data arrays. All you need for an actor to load a blueprint is to assign it, as the code examples in the manual show: http://obi.virtualmethodstudio.com/manual/7.0/scriptingactors.html Doing: Code: rope.ropeBlueprint = yourBlueprint; will automatically unload the previous blueprint (if any), clear internal state, and then load your new blueprint once the solver is ready. Note your script may also fail in Obi 6, as its success hinges on whether the solver's Start() is called before or after your TightRope's Start(). The order in which Unity calls events for different components is undefined by default. RE: Broken scripts with update 6 -> 7 - josemendez - 09-01-2025 Also keep in mind that ChangeLength() in Obi 7 takes a change in length as parameter, instead of an absolute value. So this: Code: cursor.ChangeLength(restLength); should be: Code: cursor.ChangeLength(restLength - rope.restLength); kind regards RE: Broken scripts with update 6 -> 7 - hariedo - 10-01-2025 Definitely making progress, the startup is clean. But still getting spammed by this shortly after first frame. InvalidOperationException: The previously scheduled job BoundsReductionJob writes to the Unity.Collections.NativeArray`1[Obi.BurstAabb] BoundsReductionJob.bounds. You must call JobHandle.Complete() on the job BoundsReductionJob, before you can read from the Unity.Collections.NativeArray`1[Obi.BurstAabb] safely. Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <f5cef381160e49118a67ea125642e36a>:0) Obi.BurstSolverImpl.GetBounds (UnityEngine.Vector3& min, UnityEngine.Vector3& max) (at Assets/Plugins/Obi/Scripts/Common/Backends/Burst/Solver/BurstSolverImpl.cs:367) Obi.ObiSolver.UpdateVisibility () (at Assets/Plugins/Obi/Scripts/Common/Solver/ObiSolver.cs:2257) Obi.ObiSolver.Render (System.Single unsimulatedTime) (at Assets/Plugins/Obi/Scripts/Common/Solver/ObiSolver.cs:1777) Obi.ObiSolver.LateUpdate () (at Assets/Plugins/Obi/Scripts/Common/Solver/ObiSolver.cs:1165) If there's more info about the prefab's setup that would help, I can list it. RE: Broken scripts with update 6 -> 7 - josemendez - 10-01-2025 (10-01-2025, 12:34 AM)hariedo Wrote: Definitely making progress, the startup is clean. I'm unable to reproduce this issue using your script. Would it be possible for you to share a scene/prefab that reproduces this, just in case the transform hierarchy setup or other factors other that the code are responsible for this? (if so, send it to support(at)virtualmethodstudio.com) kind regards RE: Broken scripts with update 6 -> 7 - hariedo - 10-01-2025 (10-01-2025, 06:24 PM)josemendez Wrote: I'm unable to reproduce this issue using your script. Would it be possible for you to share a scene/prefab that reproduces this, just in case the transform hierarchy setup or other factors other that the code are responsible for this? (if so, send it to support(at)virtualmethodstudio.com) While whittling down my test scene, I found that it occurs whenever all ropes are outside the camera's culling frustum. It stops as soon as any rope's bounds return to the camera's frustum. This doesn't happen in the Obi sample scene "Crane" so I am still digging into which part of my setup may be causing it. Yup. When the Solver's "Simulate When Invisible" is OFF, and your camera is aimed away from all ropes, the spam begins. Your "Crane" sample keeps this option ON, so by default it does not cause this issue. If you turn it OFF and rotate the main camera's Y value, your sample scene will generate the same errors. RE: Broken scripts with update 6 -> 7 - josemendez - 10-01-2025 (10-01-2025, 10:16 PM)hariedo Wrote: While whittling down my test scene, I found that it occurs whenever all ropes are outside the camera's culling frustum. It stops as soon as any rope's bounds return to the camera's frustum. Hi, Could reproduce the issue, thanks for reporting it! This is an issue with the Burst backend attempting to read solver bounds in a specific situation where they might not be ready yet. To fix it, open up ObiSolver.cs and in the first line of its UpdateVisibility() method (around line 2249 in the file) add this: Code: simulationHandle?.Complete(); Should look like this: Code: private void UpdateVisibility() This should ensure bounds are available before reading and fix the problem. Let me know how it goes! kind regards, |