2020-09-18 18:38:11 +10:00
|
|
|
|
using UnityEngine;
|
2020-08-18 17:11:58 +10:00
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
namespace UnityExplorer.Helpers
|
2020-08-18 17:11:58 +10:00
|
|
|
|
{
|
2020-11-05 17:33:04 +11:00
|
|
|
|
public static class UnityHelpers
|
2020-08-18 17:11:58 +10:00
|
|
|
|
{
|
|
|
|
|
private static Camera m_mainCamera;
|
|
|
|
|
|
|
|
|
|
public static Camera MainCamera
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-09-08 06:21:45 +10:00
|
|
|
|
if (!m_mainCamera)
|
2020-08-18 17:11:58 +10:00
|
|
|
|
{
|
|
|
|
|
m_mainCamera = Camera.main;
|
|
|
|
|
}
|
|
|
|
|
return m_mainCamera;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string ActiveSceneName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-05 17:33:04 +11:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2020-08-18 17:11:58 +10:00
|
|
|
|
}
|
|
|
|
|
}
|