- Home /
Show complete path on collision
When you type an Emptys name in the searchbar in the Hierarchy window, and you then select this Empty you get a new window with complete path including all "upper" Objects or Emptys. How can I get that path on collision to use for debugging in Editor to identify an GameObject?
Comment
Best Answer
Answer by Tobychappell · May 25, 2018 at 07:28 PM
I haven't tested this but I think this should work for what you are after:
public bool selectOther;
public bool enableSelection;
public bool pauseOnCollision;
private void OnCollisionEnter(Collision collision)
{
// Using preprocessor so that this wont produce erros on build
#if UNITY_EDITOR
if (enableSelection)
{
UnityEditor.Selection.activeObject = selectOther ? collision.gameObject : gameObject;
if (pauseOnCollision)
{
UnityEditor.EditorApplication.isPaused = true;
}
}
#endif
}
Thanks Toby this is a nice little script, but unfortunately I was searching a "GhostCollider"(like described in this answer) in my Background Geometry and there were a lot of Objects to collide with. I found the half answer to my problem with the HiddenObjectExplorer.cs script. Now I need to find out how the "GhostObject" became one