Compare deactivated gameObjects

Hey,

Isn’t it possible to compare two deactivated objects? Because I have a script in which I compare this

if(WaypointMasterDemoMap.streets[a].streetGameObject == streetIn.nextStreets[randomNumber] && a == WaypointMasterDemoMap.streets[a].streetNumber)

But it only works if the gameObjects are activated is kind of annoying as I would like to deactivate them for performance reasons. Would it make sense to try to compare the transforms of the gameObjects instead ?

2 Answers

2

You can use the InstanceID of the GameObjects. Something like this:

if(GameObject1.GetInstanceID() == GameObject2.GetInstanceID()){
    Debug.Log("They Match!");
    //Do things...
}

The instance IDs of GameObjects are unique int values tied to that object. They’re great for this sort of thing.

Hope that helps! = )

That’s exactly what I have been looking for thanks!!

Could somebody please make this a comment. Thanks

I don't think I can, but you can label my answer as an answer = )