Created
January 18, 2022 15:30
-
-
Save ErnSur/fc450dd7beaf138ee43166a62e205147 to your computer and use it in GitHub Desktop.
Get GameObject Path
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
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