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
  Curvy Line Renderer for UI Spline? gekido 1 1 2 hours ago
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 2 2 hours ago
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_

Forum Jump: