Skip to content

Instantly share code, notes, and snippets.

View emadkhezri's full-sized avatar
Learning...

Emad emadkhezri

Learning...
View GitHub Profile
@emadkhezri
emadkhezri / DisableOnPlatforms.cs
Last active March 26, 2022 11:46
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)) {
@emadkhezri
emadkhezri / ToggleFieldAttribute.cs
Created September 7, 2021 12:24
Attribute that makes a field enable/disable status controlled by a boolean condition
/// <summary>
/// Attribute that makes a field enable/disable status controlled by a boolean condition
/// </summary>
public class ToggleFieldAttribute : PropertyAttribute {
/// <summary>
/// Boolean field to control the enable/disable status
/// </summary>
public readonly string ConditionalField;
@emadkhezri
emadkhezri / NoWhiteSpaceAttribute.cs
Created September 6, 2021 11:53
Unity C# Attribute that avoid white space in the strings
//Attribute
public class NoWhiteSpaceAttribute : PropertyAttribute
{
}
//Attribute-Drawer
[CustomPropertyDrawer(typeof(NoWhiteSpaceAttribute))]
public class NoWhiteSpacePropertyDrawer : PropertyDrawer
{