Ejemplo n.º 1
0
        static private void TryAutoAssign(SerializedProperty inProperty, ComponentLookupDirection inLookup)
        {
            Type      componentType = inProperty.GetPropertyType();
            Component c             = (Component)inProperty.serializedObject.targetObject;

            Component val;

            switch (inLookup)
            {
            case ComponentLookupDirection.Self:
            default:
                val = c.GetComponent(componentType);
                break;

            case ComponentLookupDirection.Parent:
                val = c.GetComponentInParent(componentType);
                break;

            case ComponentLookupDirection.Children:
                val = c.GetComponentInChildren(componentType, true);
                break;
            }

            if (val)
            {
                inProperty.objectReferenceValue = val;
            }
        }
Ejemplo n.º 2
0
        static public T GetComponent <T>(this GameObject inGameObject, ComponentLookupDirection inDirection, bool inbIncludeInactive = false)
        {
            switch (inDirection)
            {
            case ComponentLookupDirection.Self:
                return(inGameObject.GetComponent <T>());

            case ComponentLookupDirection.Parent:
                return(inGameObject.GetComponentInParent <T>());

            case ComponentLookupDirection.Children:
                return(inGameObject.GetComponentInChildren <T>(inbIncludeInactive));

            default:
                throw new ArgumentOutOfRangeException("inDirection");
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the component filter.
 /// </summary>
 public void FilterByComponent <T>(ComponentLookupDirection inLookup = ComponentLookupDirection.Self)
 {
     FilterByComponent(typeof(T), inLookup);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets the component filter.
 /// </summary>
 public void FilterByComponent(Type inType, ComponentLookupDirection inLookup = ComponentLookupDirection.Self)
 {
     m_RequiredComponentType   = inType;
     m_RequiredComponentLookup = inLookup;
 }
Ejemplo n.º 5
0
 public RequiredAttribute(ComponentLookupDirection inAutoAssignDirection)
 {
     AutoAssignDirection = inAutoAssignDirection;
 }
Ejemplo n.º 6
0
 static public T GetComponent <T>(this Component inComponent, ComponentLookupDirection inDirection, bool inbIncludeInactive = false)
 {
     return(GetComponent <T>(inComponent.gameObject, inDirection, inbIncludeInactive));
 }
Ejemplo n.º 7
0
 public void Clear()
 {
     ComponentType   = null;
     LookupDirection = ComponentLookupDirection.Self;
 }
Ejemplo n.º 8
0
 public void InChildren <T>()
 {
     ComponentType   = typeof(T);
     LookupDirection = ComponentLookupDirection.Children;
 }
Ejemplo n.º 9
0
 public void InParent <T>()
 {
     ComponentType   = typeof(T);
     LookupDirection = ComponentLookupDirection.Parent;
 }
Ejemplo n.º 10
0
 public void OnObject <T>()
 {
     ComponentType   = typeof(T);
     LookupDirection = ComponentLookupDirection.Self;
 }