Showing posts from 2018

Attributes in Unity 3D

What is an Attribute: Attributes provide a powerful method of associating metadata, or declarative information, with code (assemblies, types, methods, properties, and so forth). - Taken from .NET . The Script: I have compiled some example code to help you learn how to use C# Attributes in Unity. Below is an example of what I believe are the most useful attributes. Everything is fully commented and is ready to add to a GameObject in your Unity game. using System.Collections; using System.Collections.Generic; using UnityEngine; //[RequireComponent(typeof(OtherClass))] // This makes is so this component requires another component. (unity will auto add it for you) [DisallowMultipleComponent] // This makes it so you cannot add the same component twice. [HelpURL("")]// This will link out to a help doc through unity when clicking on the ? book in the inspector public class