Files
UltimateFishing2020/Assets/Scripts/Assembly-CSharp/UnityStandardAssets/Utility/PlatformSpecificContent.cs
2026-03-04 10:03:45 +08:00

73 lines
1.3 KiB
C#

using UnityEngine;
namespace UnityStandardAssets.Utility
{
public class PlatformSpecificContent : MonoBehaviour
{
private enum BuildTargetGroup
{
Standalone = 0,
Mobile = 1
}
[SerializeField]
private BuildTargetGroup m_BuildTargetGroup;
[SerializeField]
private GameObject[] m_Content = new GameObject[0];
[SerializeField]
private MonoBehaviour[] m_MonoBehaviours = new MonoBehaviour[0];
[SerializeField]
private bool m_ChildrenOfThisObject;
private void OnEnable()
{
CheckEnableContent();
}
private void CheckEnableContent()
{
if (m_BuildTargetGroup == BuildTargetGroup.Mobile)
{
EnableContent(enabled: false);
}
else
{
EnableContent(enabled: true);
}
}
private void EnableContent(bool enabled)
{
if (m_Content.Length != 0)
{
GameObject[] content = m_Content;
foreach (GameObject gameObject in content)
{
if (gameObject != null)
{
gameObject.SetActive(enabled);
}
}
}
if (m_ChildrenOfThisObject)
{
foreach (Transform item in base.transform)
{
item.gameObject.SetActive(enabled);
}
}
if (m_MonoBehaviours.Length != 0)
{
MonoBehaviour[] monoBehaviours = m_MonoBehaviours;
for (int i = 0; i < monoBehaviours.Length; i++)
{
monoBehaviours[i].enabled = enabled;
}
}
}
}
}