I have this code:
void Start () {
Vector3 pos;
int cell = 10;
GameObject dot = new GameObject("dot");
for(int y = 0; y <= 3; y++)
for(int x = 0; x <= 3; x++)
{
pos = new Vector3 (x * cell, y * cell, 0f);
Instantiate(dot, pos, Quaternion.identity);
}
}
and a simple Sprite-prefab called “dot” and i cant see result in editor. On the left side there is objects with correct coordinates (but ob 0,0 coordinate there is original prefab AND a clone, but thats not a matter) but on the scene there is none.
If i put prefab directly on scene i can see it very clear.
I tryed to put an orb (3D with light-source) - result the same, so there is no rotational problem.
Instantiate your prefab in the editor…that produces something that looks the way you want it to, right?
Then run your game in the editor and cause the prefab to be instantiated programmatically.
In the inspector, carefully go over the object that you made using the editor and compare its properties and context (e.g., position within your hierarchy) with the properties and context of the sprite created by your code.
One at a time, start changing things on the broken sprite to be more like the settings of the working one. I’d start by changing the parent object so they both have the same parent, then iterate through each of the properties on all the scripts. Odds are, you’ll change one that will fix the problem. That will give you an hint as to what the problem is.