Created
February 22, 2025 03:32
-
-
Save Fizzyhex/b4d3775831346befb3ef1105029411db to your computer and use it in GitHub Desktop.
Non-dummy version of ObjectPathExtensions
This file contains hidden or 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 System.Collections.Generic; | |
| using JetBrains.Annotations; | |
| using UnityEngine; | |
| namespace SLZ.Marrow.Utilities | |
| { | |
| public static class ObjectPathExtensions | |
| { | |
| private static IEnumerable<string> ObjectPathComponents(this Transform tf) | |
| { | |
| return null; | |
| } | |
| [PublicAPI] | |
| public static string ObjectPath(this Transform tf) | |
| { | |
| return tf.gameObject.ObjectPath(); | |
| } | |
| [PublicAPI] | |
| public static string ObjectPath(this Component c) | |
| { | |
| return c.gameObject.ObjectPath(); | |
| } | |
| [PublicAPI] | |
| public static string ObjectPath(this GameObject go) | |
| { | |
| string path = go.name; | |
| while (go.transform.parent != null) | |
| { | |
| go = go.transform.parent.gameObject; | |
| path = $"{go.name}/{path}"; | |
| } | |
| return path; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment