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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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: 2)
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#7
Thank you for your help!
Reply
#8
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
  Using Prefabs with transformations reset to original state when using Deform mesh danne_lindwall 3 6 04-28-2023, 01:35 PM
Last Post: _Aka_
Photo How to check if a point is inside of a polygon? XtroTheArctic 1 2 03-20-2023, 08:53 AM
Last Post: _Aka_
  Input Spline Shapes from Prefabs destroys graph tairoark 5 7 11-24-2022, 05:08 PM
Last Post: _Aka_
Bug Severe bug with some types of Prefabs/meshes studentloan 17 39 07-23-2022, 11:19 AM
Last Post: _Aka_

Forum Jump: