Skip to content

Instantly share code, notes, and snippets.

@ErnSur
Created January 18, 2022 15:30
Show Gist options
  • Save ErnSur/fc450dd7beaf138ee43166a62e205147 to your computer and use it in GitHub Desktop.
Save ErnSur/fc450dd7beaf138ee43166a62e205147 to your computer and use it in GitHub Desktop.
Get GameObject Path
public static class GameObjectUtility
{
public static string GetGameObjectPath(GameObject obj)
{
var path = $"/{obj.name}";
while (obj.transform.parent != null)
{
obj = obj.transform.parent.gameObject;
path = $"/{obj.name}{path}";
}
path = $"{obj.scene.name}{path}";
return path;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment