Last active
November 29, 2015 20:28
-
-
Save teessider/21afd71bd93f53964695 to your computer and use it in GitHub Desktop.
Unity C# Attributes Example. Attach this to a gameobject in your hierarchy to see what the built-in Unity attributes do
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class AttributeExample : MonoBehaviour | |
{ | |
// The Header attribute takes a string as the header makes it bold. | |
[Header("Variables")] | |
public int exampleInteger = 3; | |
public float exampleFloat = 3.5f; | |
public string exampleString = "I'm a string!"; | |
// You can have multiple attributes on one line | |
// The Space attribute adds a space (in pixels) before the script. | |
[Space(10), Header("More Variables with a space!"), Range(-15.5f, 15.5f)] | |
public float clampedExampleFloat = 5.5f; | |
// The Range attribute specifies a range of values to experiment with. | |
[Range(0, 10)] | |
public int clampedExampleInteger = 5; | |
// The Multi-Line attribute specifies a multi-line text field using an integer to specify the amount of rows | |
[Multiline(5)] | |
public string exampleMultiLineString = "I'm a multi-line text field\n" + "using the MulitlineAttribute!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment