Skip to content

Instantly share code, notes, and snippets.

@neo-mashiro
Forked from unity3dcollege/MyClass.cs
Created November 23, 2020 05:29
Show Gist options
  • Save neo-mashiro/7e03247557874e45f3d02d76e20cc4e4 to your computer and use it in GitHub Desktop.
Save neo-mashiro/7e03247557874e45f3d02d76e20cc4e4 to your computer and use it in GitHub Desktop.
using UnityEngine;
[HelpURL("http://unity3d.college")]
[SelectionBase]
public class MyClass : MonoBehaviour
{
[Header("Text Attributes")]
[TextArea]
[Tooltip("A string using the TextArea attribute")]
[SerializeField]
private string descriptionTextArea;
[Multiline]
[Tooltip("A string using the MultiLine attribute")]
[SerializeField]
private string descriptionMultiLine;
[Header("Numeric Attributes")]
[Tooltip("A float using the Range attribute")]
[Range(-5f, 5f)]
[SerializeField]
private float rangedFloat;
[Space]
[Tooltip("An integer using the Range attribute")]
[Range(-5, 5)]
[SerializeField]
private int rangedInt;
[Header("Color Attributes")]
[SerializeField]
private Color colorNormal;
[ColorUsage(false)]
[SerializeField]
private Color colorNoAlpha;
[ColorUsage(true, true, 0.0f, 0.5f, 0.0f, 0.5f)]
[SerializeField]
private Color colorHdr;
[ContextMenu("Choose Random Values")]
private void ChooseRandomValues()
{
rangedFloat = Random.Range(-5f, 5f);
rangedInt = Random.Range(-5, 5);
}
[Header("Context Menu Items")]
[ContextMenuItem("RandomValue", "RandomizeValueFromRightClick")]
[SerializeField]
private float randomValue;
private void RandomizeValueFromRightClick()
{
randomValue = Random.Range(-5f, 5f);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment