Hi, I have a simple loop that creates instances of my prefab texture.
It works however I need it to consider the size of the texture as well. So no textures would be generated on the edge of the screen. Whole texture must be inside of the screen.
The current code example is:
for (int i = 0; i < numberOfDupes; i++)
{
Vector3 screenPosition = Camera.main.ScreenToWorldPoint(new Vector3(Random.Range(0, Screen.width), Random.Range(0, Screen.height), Camera.main.farClipPlane / 2));
Instantiate(prefab, screenPosition, Quaternion.identity);
}
Thanks for the help!