I have an integer on a single script that is assigned to 10 different objects, I want each object to have a ID of a different number between 1 and 10. Thanks,Hi, I am trying to assign and Id for 10 different objects that all have the same script assigned to them, I want the ID to be a number between 1 and 10 so each object has a number between 1 and 10 and none of them have the same ID. Thanks.
A static int should do the trick
public class MyClass : MonoBehaviour {
private static int _id = 0;
public int id;
void Awake(){
id = ++_id;
}
}