Can I rename a gameobject by raycast reference?

Can I rename a gameobject by raycast gameObject reference obtained from OnPointerEnter or OnDrop?

What you get back is just a regular reference to the GameObject, I think in the field ‘other’ under the collider, or the collision, I forget. So yes, you should be able to do anything with that reference that you could do with any other reference.

2 Likes

Ahh ok, thanks for clearing that up for me. I want to effectively swap items after one is dropped over the other.

My spider-sense tells me that you want to rename the object so that GameObject.Find will find it. If that guess is accurate, then let’s put a stop to that nonsense right now because GameObject.Find is never the right answer to any question being asked.

1 Like