Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CurvyConnections inside prefabs
#1
Hello,

First, thanks for the plugin, it's really good at what it does, simple to use, and easily editable.
Now, to the core of the issue...

I am trying to spawn sets of splines using prefabs.
I noticed that CurvyConnections are always contained within the CurvyGlobalManager.
My issue is that I do not have access to it in prefab mode.
This means that any CurvyConnection I create while inside my prefab will be lost the second I exit it.

Is there any way to make this work?

Thanks in advance!
Reply
#2
Connections are stored in objects children to the _CurvyGlobal_ gameObject. That gameObject is automatically created by some Curvy scripts, and stores data shared between various scripts, like pools. So to store connections in a prefab, you need to have in the same prefab both your splines and the _CurvyGlobal_. The issue with that is that, supposing that you want to instantiate the prefab twice, you will end up with two _CurvyGlobal_ objects, and that's bad. Curvy, when detecting that multiple _CurvyGlobal_ objects are on the same scene, will merge them into only one. That process means deleting the other _CurvyGlobal_ objects. The problem with recent Unity versions is that scripts can't delete objets in prefabs without a user input. So you will end up having error messages like "InvalidOperationException: Destroying a GameObject inside a Prefab instance is not allowed". You will then have to manually get rid of all the _CurvyGlobal_objects except one.

What I described here is far from perfect, I agree. I will work at some point on getting connections out of _CurvyGlobal_ to solve this issue. It is on my todo list.

Is my solution ok for you as a workaround?
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#3
Hey, thanks for the quick reply.

Happy to hear that's on the todo list.

Problem is, I am unable to place a CurvyGlobalManager onto a gameobject inside my prefab, it simply deletes itself instantly.
Or maybe it becomes HideInHierarchy? I'm not too sure.

Thanks
Reply
#4
Keep in mind that only one CurvyGlobalManager is allowed in a scene. So if you are trying to add a second one it will get deleted.
I attached a prefab that contains 2 connected splines. Use it in an empty scene to see how it is made.


Attached Files
.zip   Root.zip (Size: 2.69 KB / Downloads: 4)
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#5
Yes, I understand that only one is allowed in a scene.
I was talking about adding one directly into a prefab.

Seems like your gameobject has one inside, I just can't see it unless I put the prefab in a scene.
I suppose it has to do with HideInHierarchy.

I do understand what you're getting at about deleting the manager from prefabs in scene mode though, the errors make sense.

Would be sweet to see a version independent from the global manager down the line.
For now I decided to make my own hooks inside the Add and Remove methods in Connection.

That way I can create my connections when the game starts (From metadata I saved with my hooks), since the ones I use are always the same.
Reply
#6
(06-12-2020, 08:31 AM)CoolUser Wrote: Seems like your gameobject has one inside, I just can't see it unless I put the prefab in a scene.
You are indeed right. Wasn't aware of that

(06-12-2020, 08:31 AM)CoolUser Wrote: I suppose it has to do with HideInHierarchy.
I doubt that, but I have to investigate to be sure

(06-12-2020, 08:31 AM)CoolUser Wrote: Would sweet to see a version independent from the global manager down the line.
I hope not too far in the future
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#7
Thank you for your help!
Reply
#8
You are welcome
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#9
I am not sure if this is the right thread for this but I am facing a very similar issue - all the connections in the prefab throw the "Destroying a Prefab" error as mentioned earlier. If it is, has there been any updates since that would help me with this?

Thanks in advance!
Reply
#10
Hi,

Changes were made since, which allows for easier workarounds:
  • Create in a scene your splines and connect them
  • Create an empty gameobject
  • Move to it all your splines and the related connections
  • Make a prefab from it.

By "the related connections" I mean the gameobjects named "Connection" that are children of _CurvyGlobal_ . They store the connection information regarding your splines.

With this solution, you can create prefabs and use them without issues.

I attached an example prefab.

Have a nice day


Attached Files
.prefab   Connected splines.prefab (Size: 22.09 KB / Downloads: 1)
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Deforming prefabs with LODs along a spine LiveWire 6 27 05-29-2024, 08:25 AM
Last Post: _Aka_
Bug Issues when working with in-place prefabs Sacryn 4 7 02-27-2024, 04:08 PM
Last Post: _Aka_
  Custom CurvySplineSegment prefabs Lupos 1 10 10-02-2023, 09:36 AM
Last Post: _Aka_
  Using Prefabs with transformations reset to original state when using Deform mesh danne_lindwall 3 7 04-28-2023, 01:35 PM
Last Post: _Aka_

Forum Jump: