Skip to content

Instantly share code, notes, and snippets.

@zhaoguohao
Forked from emadkhezri/DisableOnPlatforms.cs
Created March 24, 2022 17:58
Show Gist options
  • Save zhaoguohao/a2fc661a00d87847f6c9a321ac756e81 to your computer and use it in GitHub Desktop.
Save zhaoguohao/a2fc661a00d87847f6c9a321ac756e81 to your computer and use it in GitHub Desktop.
This component disables game object on specific platforms
/// <summary>
/// Put this component on game objects that you wish to disable on specific platforms
/// </summary>
public class DisableOnPlatforms : MonoBehaviour {
[SerializeField]
[Tooltip("Selected Platforms to disable game object")]
private RuntimePlatform[] _platforms;
private void OnEnable() {
if (_platforms.Contains(Application.platform)) {
gameObject.SetActive(false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment