2020-08-16 15:15:36 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Utility
|
|
|
|
|
{
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public static class GOExtensions
|
|
|
|
|
{
|
|
|
|
|
public static void Show(this GameObject gameObject) => SetVisibility(gameObject, true);
|
2020-08-16 15:15:36 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public static void Hide(this GameObject gameObject) => SetVisibility(gameObject, false);
|
2020-08-16 15:15:36 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
private static void SetVisibility(GameObject gameObject, bool isVisible)
|
|
|
|
|
{
|
|
|
|
|
var renderers = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
|
|
|
|
|
foreach (var renderer in renderers)
|
|
|
|
|
{
|
|
|
|
|
renderer.enabled = isVisible;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-23 07:54:55 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public static GameObject InstantiateInactive(this GameObject original)
|
|
|
|
|
{
|
|
|
|
|
original.SetActive(false);
|
|
|
|
|
var copy = Object.Instantiate(original);
|
|
|
|
|
original.SetActive(true);
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
2020-08-23 07:54:55 +00:00
|
|
|
|
|
2020-12-14 21:20:53 +00:00
|
|
|
|
public static Transform InstantiateInactive(this Transform original) =>
|
|
|
|
|
original.gameObject.InstantiateInactive().transform;
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|