- Home /
handle gameobject Component in c#
I have a problem assigning meshes in c#, and definetly need help. I have a gameobject called SetupElement which includes a Meshfilter and a Meshrenderer. The goal is to transfer these components to my second gameobject called objectchild and then destroy these elements at the first object. Now in Java this seems like an easy task but in C# it seems to work very different.
Is here someone who can explain to me how to handle components of gameobjects in C#?
Thanks for every Help.
Answer by Sundar · Aug 02, 2012 at 09:03 PM
Try this SetupElement.GetComponent().mesh = yourMesh;
After GetComponent "lessthan symbol" then "MeshFilter" then "greater than symbol" ().mesh = yourMesh;
For some reason that part disappear after I post this answere
Answer by Stöffel · Aug 03, 2012 at 12:14 PM
Thanks a lot.
That lastone really helped me to understand the handling of GameObjects in C#
meshimport = setupelement.GetComponent<MeshFilter>().mesh;
//some script
objectchild.AddComponent<MeshFilter>().mesh = meshimport
now it looks like this and works :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
destroy prefabs when they hit the player 1 Answer
How to move gameobjects using the world position? 2 Answers
More timer from same class 1 Answer