surely I’m missing something here.
You can’t add two Sprite Renderer components to the same game object, so I believe the answer to your question is a yes, you can only render one sprite per go.
Your question implies that you think that’s some kind of wrong. What makes you think that?
Jay
wait, so how does 3d meshes work, one mesh per gameObject?
so theres one whole class per rendered sprite?
GameObject gameObj_ObjectMain = new GameObject(param);
//more than 1 ways to do this, but you always get this in the end
GameObject gameObj1 = new GameObject(param);
GameObject gameObj2 = new GameObject(param);
GameObject gameObj3 = new GameObject(param);
GameObject gameObj4 = new GameObject(param);
GameObject gameObj5 = new GameObject(param);
GameObject gameObj6 = new GameObject(param);
//alot of ways to do this, but you end up with this in the end
gameObj1.transform.SetParent(gameObj_ObjectMain.transform, false)
gameObj2.transform.SetParent(gameObj_ObjectMain.transform, false)
gameObj3.transform.SetParent(gameObj_ObjectMain.transform, false)
gameObj4.transform.SetParent(gameObj_ObjectMain.transform, false)
gameObj5.transform.SetParent(gameObj_ObjectMain.transform, false)
gameObj6.transform.SetParent(gameObj_ObjectMain.transform, false)
SpriteRenderer gameObj1SpriteRend = gameObj1.AddComponent<SpriteRenderer>();
SpriteRenderer gameObj2SpriteRend = gameObj2.AddComponent<SpriteRenderer>();
SpriteRenderer gameObj3SpriteRend = gameObj3.AddComponent<SpriteRenderer>();
SpriteRenderer gameObj4SpriteRend = gameObj4.AddComponent<SpriteRenderer>();
SpriteRenderer gameObj5SpriteRend = gameObj5.AddComponent<SpriteRenderer>();
SpriteRenderer gameObj6SpriteRend = gameObj6.AddComponent<SpriteRenderer>();
//[etc]
//alot of ways to do this, but you get something like this in the end each time
gameObj1SpriteRend.sprite = SpritesArray.GetValue = (index_of_specified_spriteReference);
gameObj2SpriteRend.sprite = SpritesArray.GetValue = (index_of_specified_spriteReference);
gameObj3SpriteRend.sprite = SpritesArray.GetValue = (index_of_specified_spriteReference);
gameObj4SpriteRend.sprite = SpritesArray.GetValue = (index_of_specified_spriteReference);
gameObj5SpriteRend.sprite = SpritesArray.GetValue = (index_of_specified_spriteReference);
gameObj6SpriteRend.sprite = SpritesArray.GetValue = (index_of_specified_spriteReference);
//repeat same thing with animators per gameObj
we have a whole gameObject class that contains a transform component object per gameObject with per Sprite renderable image?
Generally speaking you wouldn’t procedurally create a hierarchy of sprites, you would assemble it in the editor and create a prefab which you would then instantiate in code.
aahhh ok, that does make more sense, so Unity, just prefab all your working game components ahead of time, including UI menus/scripts, and no worries?
Yes, there are of course exceptions and preferences but that’s the idea.
Anything that just needs to be cloned with minimal setup should be a prefab. For convenience you could setup a class with lots of named SpriteRenderer or GameObject variables that represent the different parts of your combined sprite object, which you can drag-and-drop assign the components or objects in the inspector, and then can use as an interface in code to swap parts or sprites etc.
Just for the sake of completeness, I’ll point out one alternative:
You can also have a master object in your Hierarchy (i.e. in the scene) rather than in your project, and instantiate (clone) that exactly like you would a prefab. You can have the master disabled if you want, and then just enable the clones as you make them. This is more analogous to how cloning works in Scratch, for example, and so may feel more familiar to people coming from that environment.
But even when you’re comfortable with prefabs, there are sometimes reasons to use this master-clone technique. The main one is when your object has scripts that need to reference other objects in the scene, either through public properties or UnityEvents or whatever. A prefab can’t reference anything in the scene, so you have to hook up all those references in code after you instantiate the object. But an object in the scene can, so you can hook it all up in the editor, which is sometimes darned convenient.
So, there you go… prefab in the project, or master object in the scene. Use whichever makes more sense, and then just clone to your heart’s content.
Wait, so I should make a copy of each kind of prefab, but loaded into the scene as default, and also disabled. And then, how do I clone this with references in tact, just instantiate gameobjects of that type? I’ve never seen that before. Does it do it automatically?
I’ll definately check the API, this may make more sense, pool one of every kind and disable them all, and clone the ones im working with and simply append them to tables like Working or Disabled.
if I understanding; you can add more than a single Image to a game object, in a hierarchical fashion.