Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error when recreating splines / connections
#1
Hi again,

I dynamically create my splines and connections via API and that works fine. However, when I need to recreate the splines and connections after I have already done it once I get errors with connections.

The precise error is:

CurvyConnection.AddControlPoints called on a control point '{0}' that has already a connection. Only control points with no connection can be added.

Before recreating my splines I delete the splines by destroying the gameobjects. To also delete the connections I am calling Delete on each connection as follows:


Code:
var allConnections = FindObjectOfType<CurvyGlobalManager>().Connections;
foreach (var conn in allConnections) conn.Delete();

I have even tried also destroying the Connection gameobjects, but still get the same error.

Is there some kind of refresh or frame wait I should be doing perhaps before attempting to create my splines and connections again?

Many thanks (yet again)

John
Reply
#2
Hi
Can you tell me if the issue happens only in play mode?
To understand my question: When it comes to destroying game objects, Unity has two main destruction methods: Object.DestroyImmediate and Object.Destroy. Unfortunately, you can't simply use the one you want. You can use DestroyImmediate only in edit mode. So in play mode, you have to wait for the frame's end for the object to be effectively destroyed.
If you are curious, take a look at the implementation of conn.Delete(); It's saddening how complicated the code to destroy an object has to be Sad
I hope this helped
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
Yes only in play mode.

Thanks for the response and thorough explanation. I see what you mean and feel your pain Smile

I will just workaround this by waiting a frame as you suggest.

Thanks again

John
Reply
#4
You are welcome
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Closed splines and duplicate points jh092 3 5 07-24-2022, 01:54 PM
Last Post: _Aka_
  Splines as/in ScriptableObjects Najati 1 4 06-05-2022, 11:12 AM
Last Post: _Aka_
Question Error after upgrade: (are you missing a using directive or an assembly reference?) boriskourt 3 5 05-17-2022, 12:32 PM
Last Post: _Aka_
Exclamation Runtime error when using Curvy Generator with Game Object Deform studentloan 3 13 04-22-2022, 09:00 PM
Last Post: _Aka_

Forum Jump: