I have a component called “Projectile.cs” and I would like to edit all the objects (both the prefabs and scene objects) that have this script attached to them.
For example, I would like to run this code on all these objects:
var rb = GetComponent<Rigidbody>();
if (rb != null)
{
rb.useGravity = false;
}
I have been using OnValidate() before to do this kind of operations.
But it’s unclear to me why sometimes it doesn’t work on all my objects.
So… what’s a good way to edit: prefabs and scene objects? How do you do it? Or is it a bad idea to even do so, considering it might create changes on prefabs instances and make your prefab instance not update along with your prefab?
I’m open to learning anything about this subject, so let me know