How to get a Read-Write Reference to Parent GameObject from a script component attached to it?

Posted by onguarde on Game Development See other posts from Game Development or by onguarde
Published on 2012-11-06T09:31:46Z Indexed on 2012/11/06 17:23 UTC
Read the original article Hit count: 190

Filed under:

I have a game object(object) with a script component(myscript) attached.

I have a reference to myscript component through getComponent, and I want to change the transform of the gameObject the script is attached to.

myscript.gameObject.transform = (new value);

The above code gives me error,

Property 'UnityEngine.GameObject.transform' is read only.

Is there a way to get a read-write version?

© Game Development or respective owner

Related posts about unity