2020-08-16 15:15:36 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Utility
|
|
|
|
|
{
|
|
|
|
|
public static class GOExtensions
|
|
|
|
|
{
|
|
|
|
|
public static void Show(this GameObject gameObject) => SetVisibility(gameObject, true);
|
|
|
|
|
|
|
|
|
|
public static void Hide(this GameObject gameObject) => SetVisibility(gameObject, false);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
public static GameObject InstantiateInactive(this GameObject original)
|
|
|
|
|
{
|
|
|
|
|
original.SetActive(false);
|
|
|
|
|
var copy = Object.Instantiate(original);
|
|
|
|
|
original.SetActive(true);
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-23 08:07:43 +00:00
|
|
|
|
public static Transform InstantiateInactive(this Transform original)
|
|
|
|
|
{
|
|
|
|
|
return original.gameObject.InstantiateInactive().transform;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-16 15:15:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|