Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Input Spline Shapes from Prefabs destroys graph
#1

I have been having a strange behavior in my project that I couldn't explain. Sometimes my CurvyGenerator graph would, for some reason I couldn't decern, destroy the graph. What I mean by that is that ALL of the links between ALL of the modules would disappear. No dragging of paths from one module to the other would now create any links between any more other modules. I would have to destroy the generator and create it from scratch.

It has recently prevented me for moving forward in a new architectural direction because it always happens within it.  So I have spent a couple of days trying to isolate what is its cause. It took me a while to isolate because my newer architecture had many items on top that I suspected 'might' be the cause. But is was not.

Load the attached project adding Curvy library to it. The follow these steps:

  1. First Play the project and see how it runs
  2. Press the "Instantiate" button in the Game window which creates a generator under GenTest in the hierarchy and shows the results
  3. In the Hierarchy window, click on TrackProfileGen
  4. Click on "Edit Graph' button to see that the graph. All links are in place.
  5. Select "Input Spline Shape
  6. Click on "Shape" to see that "defaultProfile" in the Hierarchy is being used
  7. Exit Play mode

  1. In the "Hierarchy" window, select "defaultProfile"
  2. Drag the "defaultProfile" down to the folder "Resources/TrackProfiles". This will create a prefab out to the "defaultProfile"
  3. In the Hierarchy window, click on TrackProfileGen/Input Spline Shape
  4. Replace the Input Spline Shape's "Shape by dragging the shape from step 9) "Resources/TrackProfiles/defaultProfile" to the Shape field
  5. Click on the "Shape" field to confirm that the Input Spline Shape is now referring to the resource

  1. Play the project
  2. Press the "Instantiate" button in the Game window
  3. Notice that nothing is shown in the Game window but the generator was still created in the hierarchy
  4. In the Hierarchy window, click on TrackProfileGen
  5. Click on "Edit Graph' button to see that the graph. All links are missing
  6. Try to dray any paths between modules. They can not be created.

Replacing an Input Spline Shape from the Hierarchy with the identical Shape from a Prefab destroys the graph!
I need to assign Shapes at runtime from prefabs.


Attached Files
.zip   Assets.zip (Size: 78.22 KB / Downloads: 2)
Reply
#2
Hi
Working on it. Will keep you updated
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
The issue comes from using a prefab asset as an input for the Input Spline Shape. To be able to use, you need first to instanciate the prefab, then use the instance.
This is because splines need to be initialized, which happens in their OnEnable and/or Start method. A prefab asset does not have those methods called.
Did this help?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#4
(11-22-2022, 08:10 PM)tairoark Wrote: Replacing an Input Spline Shape from the Hierarchy with the identical Shape from a Prefab destroys the graph!

I didn't understand this. You replaced the whole module or the shape in the module? More details 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
#5
(11-23-2022, 02:08 PM)_Aka_ Wrote: The issue comes from using a prefab asset as an input for the Input Spline Shape. To be able to use, you need first to instanciate the prefab, then use the instance.
This is because splines need to be initialized, which happens in their OnEnable and/or Start method. A prefab asset does not have those methods called.
Did this help?

You hit it correctly. The line in the code that Instantiated the loaded spline shape prefab resource was inadvertently deleted at some point. Thus I was assigning the Prefab and not the Instance to the Shape of the Input Spline Shape

I apologize for wasting your time.
Reply
#6
No worries, happens to all of us.
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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Odd behavior when drawing spline ricke 9 14 11-28-2022, 10:34 AM
Last Post: _Aka_
  Scale Deform Mesh Along Spline? / aligning colliders MamasToast 9 61 10-31-2022, 03:44 AM
Last Post: tairoark
  Gap between spline mesh segments Beaver_Boy 13 66 10-24-2022, 09:37 AM
Last Post: dromo
  Get Closest Point on Spline neppyneptune1 1 5 10-15-2022, 11:17 AM
Last Post: _Aka_

Forum Jump: