mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-04 02:47:22 +00:00
31 lines
847 B
C#
31 lines
847 B
C#
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;
|
|
}
|
|
}
|
|
|
|
public static GameObject InstantiateInactive(this GameObject original)
|
|
{
|
|
original.SetActive(false);
|
|
var copy = Object.Instantiate(original);
|
|
original.SetActive(true);
|
|
return copy;
|
|
}
|
|
|
|
public static Transform InstantiateInactive(this Transform original) =>
|
|
original.gameObject.InstantiateInactive().transform;
|
|
}
|
|
} |