Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Copyright (c) 2021 Kai Clavier [kaiclavier.com] Do Not Distribute
- using UnityEngine;
- /*
- Destroys the gameObject this script is attached to if it's not meant to appear on it.
- Remember that switching target platform in unity will effect this check.
- */
- public class DestroyOnPlatforms : MonoBehaviour
- {
- public bool editor = true;
- [Header("Show on these platforms:")]
- public bool win = true;
- public bool mac = true;
- public bool linux = true;
- public bool web = true;
- public bool android = true;
- public bool ios = true;
- void Awake()
- {
- #if UNITY_EDITOR
- if(!editor)
- {
- DestroyImmediate(this.gameObject);
- return;
- }
- #endif
- #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
- if(!mac) DestroyImmediate(this.gameObject);
- #elif UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
- if(!win) DestroyImmediate(this.gameObject);
- #elif UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX
- if(!linux) DestroyImmediate(this.gameObject);
- #elif UNITY_WEBGL
- if(!web) DestroyImmediate(this.gameObject);
- #elif UNITY_ANDROID
- if(!android) DestroyImmediate(this.gameObject);
- #elif UNITY_IOS
- if(!ios) DestroyImmediate(this.gameObject);
- #endif
- }
- }
Add Comment
Please, Sign In to add comment