I want to use a script to creates a new game object that contains only the clone a gameobject's renderer.
Ideally this would be something simple along the lines of:
GameObject RenderClone = new GameObject("CloneOf" + origionalObject.name);
RenderClone.renderer = Instantiate(origionalObject.renderer) as Renderer;
only [GameObject].renderer is read only so it's not this simple.
Another option would be clone the entire object:
GameObject RenderClone = Instantiate(origionalObject) as GameObject;
But then you need to first go through all the child GameObjects on the clone and destroy them followed by going through all the components on the clone and destroy them unless they are a renderer.
Duplicating huge amounts of data and then throwing most of it away like this seems like a horrendously inefficient way to do things.
I can't help thinking that there has to be a cleaner way to do something like this.
↧