unity get component gameobject code example
Example 1: unity create gameobject with component
GameObject go = new GameObject("Test", typeof(MeshRenderer), typeof(MeshFilter), typeof(YourScript));
Example 2: unity get all components in gameobject
GetComponents()