mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 06:08:16 +08:00
48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
namespace UnityExplorer.Helpers
|
|
{
|
|
public static class UnityHelpers
|
|
{
|
|
private static Camera m_mainCamera;
|
|
|
|
public static Camera MainCamera
|
|
{
|
|
get
|
|
{
|
|
if (!m_mainCamera)
|
|
{
|
|
m_mainCamera = Camera.main;
|
|
}
|
|
return m_mainCamera;
|
|
}
|
|
}
|
|
|
|
public static string ActiveSceneName
|
|
{
|
|
get
|
|
{
|
|
return UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
|
|
}
|
|
}
|
|
|
|
public static string ToStringLong(this Vector3 vec)
|
|
{
|
|
return $"X: {vec.x:F3}, Y: {vec.y:F3}, Z: {vec.z:F3}";
|
|
}
|
|
|
|
public static string GetTransformPath(this Transform t, bool includeThisName = false)
|
|
{
|
|
string path = includeThisName ? t.transform.name : "";
|
|
|
|
while (t.parent != null)
|
|
{
|
|
t = t.parent;
|
|
path = $"{t.name}/{path}";
|
|
}
|
|
|
|
return path;
|
|
}
|
|
}
|
|
}
|