Copy / Paste As New not copying deep

I’ve got this class…

  [System.Serializable]   
  public class LoopConfig 
  {
     public AudioClip Clip = null;
     public AnimationCurve Envelope = new AnimationCurve();
     public float Gain = 1.0f;
  }

I’ve got this other class that contains one of those…

   public class CrossfadedLoopConfig : ScriptableObject
   {
      public LoopConfig LoopSettings = null;
      public AnimationCurve Fader = new AnimationCurve();
   }

I;ve got this MonoBehaviour…

   public class LoopCrossfader : MonoBehaviour
   {
      public float Gain = 1.0f;
      public float XFadePosition = 0.0f;
      
      public List<CrossfadedLoopConfig> LooperSettings = new List<CrossfadedLoopConfig>();

      void Start()
      {
         ... 
      }

      blah, blah, blah
   }

I’ve got a custom editor for this component, and it works great. Here is my problem…

If I right click on the component’s name and select “Copy Component”, and then right click again on the component’s name and select “Past Component as New”… I don’t get a deep copy.

The new (pasted) component’s list of looper settings “points to” the original component’s looper settings. So, here is an example…

If I have an instance of this component with 2 items in the LooperSettings list, and I copy and paste, and then I edit the first item in the original component instance’s list of looper settings, I see those changes in the pasted component instance as well.

So… is there any way for me to get the paste to do a deep copy?

Thanks,
Buzz

Maybe, you can create a new list from the original one in script.

void Awake(){
    LooperSettings = new List<CrossfadedLoopConfig>(LooperSettings);
}

Try to do that when Awake.
it’s called after the new MonoBehaviour being instantiated, just make sure the GameObject active.
Or, implement ISerializationCallbackReceiver with OnAfterDeserialize.