Created
June 15, 2016 12:54
-
-
Save marcosecchi/e8dc19f27c9ab48bc490cb444488d8e6 to your computer and use it in GitHub Desktop.
Returns the full hierarchy name of the game object in Unity3D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public static class GameObjectExtensions { | |
/// <summary> | |
/// Returns the full hierarchy name of the game object. | |
/// </summary> | |
/// <param name="go">The game object.</param> | |
public static string GetFullName (this GameObject go) { | |
string name = go.name; | |
while (go.transform.parent != null) { | |
go = go.transform.parent.gameObject; | |
name = go.name + "/" + name; | |
} | |
return name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works beautifully, thank you!