Skip to content

Instantly share code, notes, and snippets.

@Fizzyhex
Created February 22, 2025 03:32
Show Gist options
  • Select an option

  • Save Fizzyhex/b4d3775831346befb3ef1105029411db to your computer and use it in GitHub Desktop.

Select an option

Save Fizzyhex/b4d3775831346befb3ef1105029411db to your computer and use it in GitHub Desktop.
Non-dummy version of ObjectPathExtensions
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