Is there a way to add a script to a parent object when the child object becomes destroyed ?
you can try this:
void OnDestroy()
{
transform.parent.gameObject.AddComponent<SCRIPTNAME> ();
//if you need to change some public variable
transform.parent.gameObject.GetComponent<SCRIPTNAME> ().variable = value;
}
void OnDestroy()
{
transform.parent.gameobject.AddComponent();
}
This creates a new script on the parent gameobject. I think you have to copy the values of members manual, but perhaps there is another way.