This repository has been archived by the owner on Dec 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Components
Andrew Macdonald edited this page Jan 11, 2016
·
3 revisions
Creating an EgoCS-compatible Component Type is even simpler than creating a regular Unity3D Component.
First, create a new class deriving from MonoBehaviour, as usual:
using UnityEngine;
using System.Collections;
public class ExampleComponent : MonoBehaviour
{
}
Next, add some public
variables:
using UnityEngine;
using System.Collections;
public class ExampleComponent : MonoBehaviour
{
public float f;
public int i;
public string s;
}
EgoCS Components are just Plain Old CLR Objects: They only store public data. This means you should NEVER add MonoBehaviour Messages (Start()
, Update()
, etc.) to an EgoCS Component.
EgoCS is designed with the assumption that there cannot be multiple Components of the same type attached to a GameObject:
using UnityEngine;
using System.Collections;
[DisallowMultipleComponent]
public class ExampleComponent : MonoBehaviour
{
public float f;
public int i;
public string s;
}
Unity3D's [DisallowMultipleComponent]
attribute enforces this.