GetComponentInChildren() public method

public GetComponentInChildren ( Type t ) : Component
t Type
return Component
Example #1
0
 static public int GetComponentInChildren(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 3)
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.Type           a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             var ret = self.GetComponentInChildren(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 2)
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.Type           a1;
             checkType(l, 2, out a1);
             var ret = self.GetComponentInChildren(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #2
0
    static int GetComponentInChildren(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Component), typeof(System.Type)))
            {
                UnityEngine.Component obj  = (UnityEngine.Component)ToLua.ToObject(L, 1);
                System.Type           arg0 = (System.Type)ToLua.ToObject(L, 2);
                UnityEngine.Component o    = obj.GetComponentInChildren(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Component), typeof(System.Type), typeof(bool)))
            {
                UnityEngine.Component obj  = (UnityEngine.Component)ToLua.ToObject(L, 1);
                System.Type           arg0 = (System.Type)ToLua.ToObject(L, 2);
                bool arg1 = LuaDLL.lua_toboolean(L, 3);
                UnityEngine.Component o = obj.GetComponentInChildren(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Component.GetComponentInChildren"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 static int QPYX_GetComponentInChildren_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 2)
         {
             UnityEngine.Component QPYX_obj_YXQP  = (UnityEngine.Component)ToLua.CheckObject <UnityEngine.Component>(L_YXQP, 1);
             System.Type           QPYX_arg0_YXQP = ToLua.CheckMonoType(L_YXQP, 2);
             UnityEngine.Component QPYX_o_YXQP    = QPYX_obj_YXQP.GetComponentInChildren(QPYX_arg0_YXQP);
             ToLua.Push(L_YXQP, QPYX_o_YXQP);
             return(1);
         }
         else if (QPYX_count_YXQP == 3)
         {
             UnityEngine.Component QPYX_obj_YXQP  = (UnityEngine.Component)ToLua.CheckObject <UnityEngine.Component>(L_YXQP, 1);
             System.Type           QPYX_arg0_YXQP = ToLua.CheckMonoType(L_YXQP, 2);
             bool QPYX_arg1_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 3);
             UnityEngine.Component QPYX_o_YXQP = QPYX_obj_YXQP.GetComponentInChildren(QPYX_arg0_YXQP, QPYX_arg1_YXQP);
             ToLua.Push(L_YXQP, QPYX_o_YXQP);
             return(1);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.Component.GetComponentInChildren"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
    static int GetComponentInChildren(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                UnityEngine.Component obj  = (UnityEngine.Component)ToLua.CheckObject <UnityEngine.Component>(L, 1);
                System.Type           arg0 = ToLua.CheckMonoType(L, 2);
                UnityEngine.Component o    = obj.GetComponentInChildren(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3)
            {
                UnityEngine.Component obj  = (UnityEngine.Component)ToLua.CheckObject <UnityEngine.Component>(L, 1);
                System.Type           arg0 = ToLua.CheckMonoType(L, 2);
                bool arg1 = LuaDLL.luaL_checkboolean(L, 3);
                UnityEngine.Component o = obj.GetComponentInChildren(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Component.GetComponentInChildren"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #5
0
        /// <summary>
        /// Find a component that is loosely related to another component.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static T FindClosest <T>(this Component obj)
            where T : class
        {
            if (obj is null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            var v = obj.GetComponent <T>();

            if (v == default)
            {
                obj.GetComponentInChildren <T>();
            }

            if (v == default)
            {
                v = obj.GetComponentInParent <T>();
            }

            if (v == default)
            {
                v = Any <T>();
            }

            return(v);
        }
Example #6
0
 // -------------------
 static public int IsThereGamepadManagerInTheScene()
 {
     UnityEngine.Component gmGo = (UnityEngine.Component)(GameObject.FindObjectOfType(typeof(ControlFreak2.GamepadManager)));
     if (gmGo == null)
     {
         return(0);
     }
     return(gmGo.GetComponentInChildren(typeof(ControlFreak2.GamepadNotifier)) ? 1 : -1);
 }
Example #7
0
 void OnTriggerEnter(Component other)
 {
     Shooting s = other.GetComponentInChildren<Shooting>();
     if (s != null) {
         string name = this.gameObject.name;
         name = name.Substring(0,name.IndexOf("Pickup"));
         s.changeWeapon (WeaponLibrary.weapons [name]);
         print (s.weapon.name);
     }
 }
Example #8
0
        ///<summary> Returns true if the component existsed and was removed </summary>
        public static bool RemoveComponentInChildren <T>(this Component co) where T : Component
        {
            T component = co.GetComponentInChildren <T>();

            if (component != null)
            {
                Object.Destroy(component);
                return(true);
            }
            return(false);
        }
Example #9
0
 public override void OnTriggerEnter(Component other)
 {
     try{
         shooting = other.GetComponentInChildren<Shooting>();
     } catch(UnityException e){
     }
     string name = this.gameObject.name;
     name = name.Substring(0,name.IndexOf("Item"));
     shooting.addWeaponItem (ItemLibrary.weaponItems [name]);
     destroyObject ();
 }
Example #10
0
 public override void OnTriggerEnter(Component other)
 {
     try{
         player = other.GetComponentInChildren<Player>();
     }catch(UnityException e){
     }
     string name = this.gameObject.name;
     name = name.Substring(0,name.IndexOf("Item"));
     player.addPlayerItem (ItemLibrary.playerItems [name]);
     destroyObject ();
 }
Example #11
0
        /// <summary>Gets the component, including checking children if specified</summary>
        /// <typeparam name="TComponent">Component type</typeparam>
        /// <param name="this">The UnityEngine Component</param>
        /// <param name="includeChildren">Whether to check children if the component is not found on the Component</param>
        /// <returns>The component, if found; otherwise, null.</returns>
        public static TComponent GetComponent <TComponent>(this UnityEngine.Component @this, bool includeChildren)
            where TComponent : UnityEngine.Component
        {
            var component = @this.GetComponent <TComponent>();

            if (component == null)
            {
                component = @this.GetComponentInChildren <TComponent>();
            }

            return(component);
        }
Example #12
0
 static public int GetComponentInChildren(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.Type           a1;
             checkType(l, 2, out a1);
             var ret = self.GetComponentInChildren(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 3)
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.Type           a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             var ret = self.GetComponentInChildren(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function GetComponentInChildren to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Example #13
0
 public override void OnTriggerEnter(Component other)
 {
     Shooting s = other.GetComponentInChildren<Shooting> ();
     bool full = true;
     if (s != null) {
         full = s.addClip();
     }
     if (full) {
         src.Play ();
         //gameObject.renderer.enabled = false;
         Destroy(gameObject, src.clip.length);
     }
 }
 static public int GetComponentInChildren(IntPtr l)
 {
     try {
         UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
         System.Type           a1;
         checkType(l, 2, out a1);
         var ret = self.GetComponentInChildren(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #15
0
 static public int GetComponentInChildren(IntPtr l)
 {
     try {
         UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
         System.Type           a1;
         checkType(l, 2, out a1);
         var ret = self.GetComponentInChildren(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #16
0
 static int GetComponentInChildren(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Component obj  = (UnityEngine.Component)ToLua.CheckObject(L, 1, typeof(UnityEngine.Component));
         System.Type           arg0 = (System.Type)ToLua.CheckObject(L, 2, typeof(System.Type));
         UnityEngine.Component o    = obj.GetComponentInChildren(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #17
0
 public static int GetComponentInChildren1_wrap(long L)
 {
     try
     {
         long nThisPtr              = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.Component obj  = get_obj(nThisPtr);
         System.Type           arg0 = FCGetObj.GetObj <System.Type>(FCLibHelper.fc_get_wrap_objptr(L, 0));
         UnityEngine.Component ret  = obj.GetComponentInChildren(arg0);
         long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         long v       = FCGetObj.PushObj(ret);
         FCLibHelper.fc_set_value_wrap_objptr(ret_ptr, v);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
 public static Component GetComponentInChildren0T(this UnityEngine.Component self, System.Type T)
 {
     return(self.GetComponentInChildren(T));
 }
 public static Component GetComponentInChildren1T(this UnityEngine.Component self, System.Boolean includeInactive, System.Type T)
 {
     return(self.GetComponentInChildren(T, includeInactive));
 }
Example #20
0
 public override object FindDependency(Component comp, FieldInfo field)
 {
     if (SearchParents) {
         comp = comp.transform.root;
     }
     if (IsContainerType(field)) {
         Type type;
         if (field.FieldType.IsArray) {
             type = field.FieldType.GetElementType();
         } else if (typeof(IList).IsAssignableFrom(field.FieldType)) {
             if (field.FieldType.GetGenericArguments().Length >= 1) {
                 type = field.FieldType.GetGenericArguments()[0];
             } else {
                 Debug.LogError(string.Format("{0} expected at least one generic argument from the type {1}, use List<T>", this, field.FieldType));
                 return null;
             }
         } else {
             Debug.LogError("Shouldn't be here");
             type = null;
         }
         if (Recursive) {
             return CreateArrayOrList(field, ConvertToGOArray(comp.GetComponentsInChildren(type, IncludeInactive)));
         }
         return CreateArrayOrList(field, ConvertToGOArray(comp.GetComponents(type)));
     }
     if (Recursive) {
         return comp.GetComponentInChildren(field.FieldType);
     }
     return comp.GetComponent(field.FieldType);
 }