Is there any way I can run a piece of code, when I drag a script onto an object? For example, lets say, the first thing I want to do, is rename the object, as soon as a script is dragged onto it.
Any help would be appreciated. My language of choice is C#. Thanks and have a great Friday!
You can add the ExecuteInEditMode Attribute above your class/Component definition. And then add that what you want to do into the Start or Awake method of your script.
You then can check whether you are in editmode or playmode by using something like this: