UnityEssentials
Small but useful tools and features for Unity
ComponentExtensions.cs
Go to the documentation of this file.
1 namespace UnityEngine
2 {
7  public static class ComponentExtensions
8  {
14  public static T GetComponentRequired<T>(this Component self) where T : Component
15  {
16  T component = self.GetComponent<T>();
17 
18  if (component == null) Debug.LogError("Could not find " + typeof(T) + " on " + self.name);
19 
20  return component;
21  }
22  }
23 }
24 
static T GetComponentRequired< T >(this Component self)
Get a component. Log an error if it is not found.