Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting MissingReferenceException from the component pool when I destroy a spline
#1
I'm creating & destroying splines at runtime using the following code:


Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FluffyUnderware.Curvy;

public class BranchMesh : MonoBehaviour
{
    public CurvySpline spline;

    public Branch branch;

    void Start()
    {
        branch = GetComponent<Branch>();
        spline = CurvySpline.Create();
        spline.transform.parent = transform;

        spline.UsePooling = true;
        spline.Interpolation = CurvyInterpolation.CatmullRom;
    }

    public void PopulateSpline()
    {
        foreach (BranchSegment bs in branch.Segments)
        {
            CurvySplineSegment tempspl = spline.Add(bs.Position, Space.World);
        }

        spline.Add(branch.LastSegment.EndPoint, Space.World);
    }

}

This is part of a much larger codebase, where PopulateSpline() is called.  When the objects, including the spline objects, are destroyed, I get a bunch of these errors:

Code:
MissingReferenceException: The object of type 'CurvySplineSegment' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
FluffyUnderware.DevTools.ComponentPool.sendBeforePush (UnityEngine.Component item) (at Assets/Plugins/DevTools/Components/ComponentPool.cs:318)
FluffyUnderware.DevTools.ComponentPool.Push (UnityEngine.Component item) (at Assets/Plugins/DevTools/Components/ComponentPool.cs:217)
FluffyUnderware.Curvy.CurvySpline.OnDestroy () (at Assets/Plugins/Curvy/Base/CurvySpline_private.cs:331)

The workaround for the moment is to change the UsePooling line in the above code to set it to false.  This prevents the error, but I assume it's going to harm performance if I do that.  I'm generating many thousands of spline points.

So is there a graceful way to destroy the splines without generating these errors from the component pool?

Another thing I want to do is to add a shape to each point along the line.  What's the best way to do that from this code?  At the moment they'll just be circles, but I'll be making them more detailed later.
Reply


Messages In This Thread
Getting MissingReferenceException from the component pool when I destroy a spline - by Excrubulent - 11-21-2020, 05:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Best way to duplicate a spline with an offset Kapistijn 8 1,349 04-12-2026, 03:18 PM
Last Post: _Aka_
Smile Constant speed along a spline? tfishell 1 654 11-13-2025, 11:32 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 4,452 07-29-2025, 09:15 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 7 6,203 07-13-2025, 07:11 PM
Last Post: _Aka_

Forum Jump: