Is there a way to take a script and apply that specific script to an object through code? In pseudocode, what I'm trying to do is essentially as follows:
ObjectOne.MyScript = ObjectTwo.GetComponent<MyScript>();
The closest thing I've found to doing this is AddComponent()
, but that only takes either a string or a type and I'd assume it just finds the relavant script and instantiates a clean copy of it. That could work for what I want to do as I could just fill in the relevant information, but that would be tiresome and there should be an easier way to do this.