/// <summary>
        /// Returns proxies to all the components of specified type attached to the game object or any of its parents.
        /// </summary>
        /// <param name="gameObject">The game object from which to retrieve the components.</param>
        /// <param name="includeInactive">A value indicating if components on inactive game objects be included.</param>
        /// <returns>Proxies to all the components of specified type attached to the game object or any of its parents.</returns>
        public static T[] GetComponentsInParent(GameObject gameObject, bool includeInactive)
        {
            var components = gameObject.GetComponentsInParent(ProxyTypeBase <T, MonoBehaviour> .RealType, includeInactive);
            var results    = new T[components.Length];

            for (int i = 0; i < results.Length; i++)
            {
                results[i] = ProxyTypeBase <T, MonoBehaviour> .Wrap(components[i]);
            }

            return(results);
        }
        /// <summary>
        /// Returns proxies to all the components of specified type attached to the component object or any of its children.
        /// </summary>
        /// <param name="component">The component object from which to retrieve the components.</param>
        /// <returns>Proxies to all the components of specified type attached to the component object or any of its children.</returns>
        public static T[] GetComponentsInChildren(Component component)
        {
            var components = component.GetComponentsInChildren(ProxyTypeBase <T, MonoBehaviour> .RealType);
            var results    = new T[components.Length];

            for (int i = 0; i < results.Length; i++)
            {
                results[i] = ProxyTypeBase <T, MonoBehaviour> .Wrap(components[i]);
            }

            return(results);
        }
        /// <summary>
        /// Returns proxies to all the components of specified type attached to the game object.
        /// </summary>
        /// <param name="gameObject">The game object from which to retrieve the components.</param>
        /// <returns>Proxies to all the components of specified type attached to the game object.</returns>
        public static T[] GetComponents(GameObject gameObject)
        {
            var components = gameObject.GetComponents(ProxyTypeBase <T, MonoBehaviour> .RealType);
            var results    = new T[components.Length];

            for (int i = 0; i < results.Length; i++)
            {
                results[i] = ProxyTypeBase <T, MonoBehaviour> .Wrap(components[i]);
            }

            return(results);
        }
示例#4
0
 /// <summary>
 /// Creates an instance of the wrapped type, returning the proxy to that type.
 /// </summary>
 /// <param name="constructorParameters">The constructor parameters.</param>
 /// <returns>A proxy object wrapping the newly created instance of the real type.</returns>
 public static T Create(params object[] constructorParameters)
 {
     return(ProxyTypeBase <T, object> .Wrap(Activator.CreateInstance(ProxyTypeBase <T, object> .RealType, constructorParameters)));
 }
示例#5
0
 /// <summary>
 /// Creates an instance of the wrapped type, returning the proxy to that type.
 /// </summary>
 /// <returns>A proxy object wrapping the newly created instance of the real type.</returns>
 public static T Create()
 {
     return(ProxyTypeBase <T, object> .Wrap(Activator.CreateInstance(ProxyTypeBase <T, object> .RealType, true)));
 }
 /// <summary>
 /// Creates an instance of the wrapped type, returning the proxy to that type.
 /// </summary>
 /// <returns>A proxy object wrapping the newly created instance of the real type.</returns>
 public static TProxy Create()
 {
     return(ProxyTypeBase <TProxy, TRealObject> .Wrap(Activator.CreateInstance <TRealObject>()));
 }
        /// <summary>
        /// Returns a proxy to the component of specified type attached to the component object or any of its children. <c>null</c> if the component could not be found.
        /// </summary>
        /// <param name="component">The component object from which to retrieve the component.</param>
        /// <param name="includeInactive">A value indicating if components on inactive game objects be included.</param>
        /// <returns>A proxy to the component of specified type attached to the component object or any of its children. <c>null</c> if the component could not be found.</returns>
        public static T GetComponentInChild(Component component, bool includeInactive)
        {
            var obj = component.GetComponentInChildren(ProxyTypeBase <T, MonoBehaviour> .RealType, includeInactive) as MonoBehaviour;

            return(obj == null ? null : ProxyTypeBase <T, MonoBehaviour> .Wrap(obj));
        }
        /// <summary>
        /// Returns a proxy to the component of specified type attached to the game object or any of its children. <c>null</c> if the component could not be found.
        /// </summary>
        /// <param name="gameObject">The game object from which to retrieve the component.</param>
        /// <returns>A proxy to the component of specified type attached to the game object or any of its children. <c>null</c> if the component could not be found.</returns>
        public static T GetComponentInChild(GameObject gameObject)
        {
            var obj = gameObject.GetComponentInChildren(ProxyTypeBase <T, MonoBehaviour> .RealType) as MonoBehaviour;

            return(obj == null ? null : ProxyTypeBase <T, MonoBehaviour> .Wrap(obj));
        }
        /// <summary>
        /// Returns a proxy to the component of specified type if the component object has one attached, <c>null</c> if it doesn't.
        /// </summary>
        /// <param name="component">The component object from which to retrieve the component.</param>
        /// <returns>A proxy to the component of specified type if the component object has one attached, <c>null</c> if it doesn't.</returns>
        public static T GetComponent(Component component)
        {
            var obj = component.GetComponent(ProxyTypeBase <T, MonoBehaviour> .RealType) as MonoBehaviour;

            return(obj == null ? null : ProxyTypeBase <T, MonoBehaviour> .Wrap(obj));
        }
 /// <summary>
 /// Adds the wrapped monobehaviour type as a component to the specified game object.
 /// </summary>
 /// <param name="gameObject">The game object to which to add the component.</param>
 /// <returns>The proxy wrapping the added component.</returns>
 public static T AddComponent(GameObject gameObject)
 {
     return(ProxyTypeBase <T, MonoBehaviour> .Wrap(gameObject.AddComponent(ProxyTypeBase <T, MonoBehaviour> .RealType)));
 }