The scripts were originally called Waypoint and WaypointDual. I need to replace all instances of those two components with my script called BoardPoint.
I wrote a small script (below) to iterate through GameObjects (sequentially numbered 0 to 104 (and #a and #b in some cases (following a WaypointDual))
When I toggle the 'destroyWP' in the inspector, it toggles back off (correctly), the 'destroyed' variable toggles to true, and my log fills with 105 entries of destroyed....
Problem: They all still have an instance of Waypoint (or WaypointDual)... any ideas?
DestroyImmediate or Destroy are static functions and you have to provide a reference to the object you want to destroy. GetComponent on the other side is not a static function. It requires an instance of a GameObject or a Component on which it searchs for the component.
If you call GetComponent within a MonoBehaviour script it will search on the GameObject this script is attached to (it's the same as
Also keep in mind that DestroyImmediate ONLY works in the editor. Never use it ingame! Same rule applies the other way round: Don't use Destroy in an editor-script.
You should actually use a true editor script like this (not tested i'm a C# guy :D):
btw if you just want to delete all Waypoint and WaypointDual scripts just do it that way:
answered Oct 05 '11 at 07:47 PM