Macro
1
I was wondering if you can use RequireComponent or any other sort of attribute to indicate that a variable of a component requires a component.
For example I have a component like so:
public class FormationController : MonoBehaviour
{
public List<GameObject> targets;
void Update()
{
// loop round assume i is index
// get the component off the targets and set data on target component
var targetComponent = target*.GetComponent<SomeCustomComponent>();*
I’m not sure I understood you correctly, but I’d suggest to declare array of desired component type instead of just GameObject.
e.g.:
public List<SomeCustomComponent> targets;
void Update()
{
// loop round assume i is index
// get the component off the targets and set data on target component
SomeCustomComponent targetComponent = target*;*
targetComponent.SetSomeValue = 10;
}