Thanks for the reply RonHiler but that solution really doesn’t help since I still need to hash the tag at every comparison before I compared the hashes themselves.
So I figured this out and did some profiling with the C# StopWatch class. And the results are exactly as I assumed they would be.
To start, I created an enum with all of the different types of collisions I could have:
public enum CollidableType {
PlayerEntity,
StaticNeutral_1,
StaticNeutral_2,
StaticNeutral_3,
StaticNeutral_4,
StaticNeutral_5,
StaticNegative_1,
StaticNegative_2,
StaticNegative_3,
StaticNegative_4,
StaticNegative_5,
StaticPositive_1,
StaticPositive_2,
StaticPositive_3,
StaticPositive_4,
StaticPositive_5
}
Then I created a class that extended Unity’s MonoBehavior class for each of the possible collision types and initialized them with their respective enum value. I then attached the “StaticNegative_1” script (class) as a component to the GameObject’s that would be colliding.
Inside my collision OnTriggerStay() method I performed the BEST case scenario for comparing the string “tag” of an object (meaning it would always be the first one I compared) versus the WORST case scenario of snagging my component off of the Collider.GameObject and then using a switch to determine which one this specific Collidable was (meaning I made the “known” StaticNegative_1 enum be the last switch choice). I started up the game and sat my Player object in the middle of one of the collidables. Here are the results:
As you can see for 2000 OnTriggerStay() calls, the average time in nanoseconds (or close enough) for comparing the string tag w/ the known type was 1,084,580ns (or 1.08458ms). The time for the switch call (including the retrieval of the component) took 2802.85ns (or 0.00280285ms).
Thats 386 times FASTER! And it only gets worse when you compare multiple “tags” to get what you want.
Thats huge and can be a very good look into why you should always try and compare primitives instead of strings… especially in a game 
Here is the code I used for the timings in case anyone wants to see it:
void OnTriggerStay(Collider collidedWith) {
// PROFILER
// *****************************
// *****************************
// *****************************
runs++;
// #########################################
// STRING START
Stopwatch sw = new Stopwatch();
sw.Start();
if(collidedWith.CompareTag("StaticPositiveCUBE")) {
UnityEngine.Debug.Log("PLAYER TRIGGER ENTER and hit StaticPositiveCUBE");
}
sw.Stop ();
float totalTicksString = sw.ElapsedTicks * (1000L*1000L*1000L) / Stopwatch.Frequency;
// #########################################
// STRING END
sw.Reset();
// ENUM START
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
sw.Start ();
Collidable collidableTestType = collidedWith.gameObject.GetComponent<Collidable>();
PEngineGlobals.CollidableType testType = collidableTestType.ColliderType();
switch(testType) {
case CollidableType.StaticNegative_2: {
break;
}
case CollidableType.StaticNegative_3: {
break;
}
case CollidableType.StaticNegative_4: {
break;
}
case CollidableType.StaticNegative_5: {
break;
}
case CollidableType.StaticNeutral_1: {
break;
}
case CollidableType.StaticNeutral_2: {
break;
}
case CollidableType.StaticNeutral_3: {
break;
}
case CollidableType.StaticNeutral_4: {
break;
}
case CollidableType.StaticNeutral_5: {
break;
}
case CollidableType.StaticPositive_1: {
break;
}
case CollidableType.StaticPositive_2: {
break;
}
case CollidableType.StaticPositive_3: {
break;
}
case CollidableType.StaticPositive_4: {
break;
}
case CollidableType.StaticPositive_5: {
break;
}
case CollidableType.StaticNegative_1: {
UnityEngine.Debug.Log("PLAYER TRIGGER ENTER and hit StaticPositiveCUBE");
break;
}
default: {
break;
}
}
sw.Stop ();
float totalTicksEnum = sw.ElapsedTicks * (1000L*1000L*1000L) / Stopwatch.Frequency;
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// ENUM END
totalTicksStrings += totalTicksString;
totalTicksEnums += totalTicksEnum;
float avgTicksStrings = totalTicksStrings / runs;
float avgTicksEnums = totalTicksEnums / runs;
UnityEngine.Debug.Log("RUNS: [" + runs + "]\tSTRING AVG TIME NS: [" + avgTicksStrings + "]\tENUM AVG TIME NS: [" + avgTicksEnums + "]");
// ******************************************************************
// ******************************************************************
// ******************************************************************
}
PAR