- Home /
Object.ToString <--> Object.name Which one is faster ?
I already learnded (Component.CompareTag("Tag")) is faster than (Component.tag == "Tag")
To use it like this:
function OnTriggerEnter (other : Collider) {
if (other.CompareTag ("Player")) {
Destroy (other.gameObject);
}
}
So is it the same for (other.ToString == "name) instead of (other.name == "name") ? Or is it just the same ?
Thank you!
$$anonymous$$aybe you mean : object.name.ToString().Compare( name ) ?
Answer by Eric5h5 · Nov 01, 2012 at 09:44 PM
Those are two different things that produce different results, so the question about which is faster is kind of irrelevant.
Well here http://docs.unity3d.com/Documentation/ScriptReference/Object.ToString.html it says: Object.ToString: Returns the name of the game object. So I thought it's like Object.name ?
Well - it's the name like from Object.name plus "(UnityEngine.GameObject)" so I guess you are right - it's not too useful. Sorry for inconvenience.
Your answer
Follow this Question
Related Questions
How do I use current List Object [i] as the string name? 3 Answers
Infinite loop crash System.Enum.ToString() 0 Answers
Raycast only working once 2 Answers
How to change the file name for the final build? 2 Answers
how to change name of material 1 Answer