GetComponents() public method

public GetComponents ( Type type ) : UnityEngine.Component[]
type Type
return UnityEngine.Component[]
コード例 #1
0
    static int GetComponents(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Component.Register");
#endif
        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.GetComponents(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);
                System.Collections.Generic.List <UnityEngine.Component> arg1 = (System.Collections.Generic.List <UnityEngine.Component>)ToLua.CheckObject(L, 3, typeof(System.Collections.Generic.List <UnityEngine.Component>));
                obj.GetComponents(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Component.GetComponents"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #2
0
 static int QPYX_GetComponents_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.GetComponents(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);
             System.Collections.Generic.List <UnityEngine.Component> QPYX_arg1_YXQP = (System.Collections.Generic.List <UnityEngine.Component>)ToLua.CheckObject(L_YXQP, 3, typeof(System.Collections.Generic.List <UnityEngine.Component>));
             QPYX_obj_YXQP.GetComponents(QPYX_arg0_YXQP, QPYX_arg1_YXQP);
             return(0);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.Component.GetComponents"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
コード例 #3
0
    static int GetComponents(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.GetComponents(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);
                System.Collections.Generic.List <UnityEngine.Component> arg1 = (System.Collections.Generic.List <UnityEngine.Component>)ToLua.CheckObject(L, 3, TypeTraits <System.Collections.Generic.List <UnityEngine.Component> > .type);
                obj.GetComponents(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Component.GetComponents"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #4
0
 static public int GetComponents(IntPtr l)
 {
     try {
         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.GetComponents(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.Type           a1;
             checkType(l, 2, out a1);
             System.Collections.Generic.List <UnityEngine.Component> a2;
             checkType(l, 3, out a2);
             self.GetComponents(a1, a2);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            float w = position.width;

            position.width = w * .6f;
            EditorGUI.ObjectField(position, property, typeof(UnityEngine.Component), label);
            UnityEngine.Component content = null;//(UnityEngine.Component)property.objectReferenceValue;
            var obj = property.objectReferenceValue;

            if (obj != null && obj is UnityEngine.Component)
            {
                content = (UnityEngine.Component)obj;
                var comps = content.GetComponents <Component>();
                m_AllComponents.Clear();
                int selectIndex = 0;
                int i           = 0;
                foreach (var comp in comps)
                {
                    m_AllComponents.Add(comp.GetType().Name);
                    if (comp == content)
                    {
                        selectIndex = i;
                    }
                    i++;
                }
                position.x     = position.xMax;
                position.width = w - position.width;
                selectIndex    = EditorGUI.Popup(position, selectIndex, m_AllComponents.ToArray());
                content        = comps[selectIndex];
            }
            property.objectReferenceValue = content;
        }
コード例 #6
0
    static int GetComponents(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.GetComponents(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Component), typeof(System.Type), typeof(System.Collections.Generic.List <UnityEngine.Component>)))
            {
                UnityEngine.Component obj  = (UnityEngine.Component)ToLua.ToObject(L, 1);
                System.Type           arg0 = (System.Type)ToLua.ToObject(L, 2);
                System.Collections.Generic.List <UnityEngine.Component> arg1 = (System.Collections.Generic.List <UnityEngine.Component>)ToLua.ToObject(L, 3);
                obj.GetComponents(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Component.GetComponents"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #7
0
        public void AddbindableObjects(BindableContainer refer, UnityEngine.Component obj)
        {
            if (refer.children == null) //需要新增加
            {
                List <Binding> bindings = new List <Binding>();
                refer.children = new List <BindableObject>(); // bindings.ToArray ();
            }

            var            children = refer.children;
            BindableObject bindable = null;

            if (obj is BindableObject)
            {
                bindable = obj as BindableObject;
            }
            else
            {
                if (bindable == null)
                {
                    Component[] allcomps = obj.GetComponents <Component>(); //默认绑定最后一个组件
                    Component   target   = null;
                    int         index    = 0;
                    int         tpId     = -1;
                    foreach (var comp in allcomps)
                    {
                        if (comp is BindableObject)
                        {
                            bindable = (BindableObject)comp;
                            break;
                        }
                        else if ((index = BinderCheckTypes.IndexOf(comp.GetType())) >= 0)
                        {
                            target = comp;
                            tpId   = index;
                        }
                    }

                    if (bindable == null)
                    {
                        Type createBinderType = typeof(Hugula.Databinding.BindableObject);
                        if (tpId >= 0)
                        {
                            createBinderType = BinderCreateTypes[tpId];
                        }

                        bindable = (BindableObject)obj.gameObject.AddComponent(createBinderType);
                    }
                }
            }

            if (children.IndexOf(bindable) < 0)
            {
                refer.AddChild(bindable);
            }
        }
コード例 #8
0
 static public int GetComponents(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.GetComponents(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.Collections.Generic.List <UnityEngine.Component> a2;
             checkType(l, 3, out a2);
             self.GetComponents(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function GetComponents 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
 }
コード例 #9
0
        public void AddbindableObjects(BindableContainer refer, UnityEngine.Component obj)
        {
            if (refer.children == null) //需要新增加
            {
                List <Binding> bindings = new List <Binding>();
                refer.children = new List <BindableObject>(); // bindings.ToArray ();
            }

            var            children = refer.children;
            BindableObject bindable = null;

            if (obj is BindableObject)
            {
                bindable = obj as BindableObject;
            }
            else
            {
                if (bindable == null)
                {
                    Component[] allcomps = obj.GetComponents <Component>(); //默认绑定最后一个组件
                    Component   target   = null;
                    Type        addType  = typeof(Hugula.Databinding.BindableObject);
                    Type        findType;
                    foreach (var comp in allcomps)
                    {
                        if (comp is BindableObject)
                        {
                            bindable = (BindableObject)comp;
                            break;
                        }
                        else if ((findType = BindalbeObjectUtilty.FindBinderType(comp.GetType())) != null)
                        {
                            target  = comp;
                            addType = findType;
                        }
                    }

                    if (bindable == null)
                    {
                        bindable = (BindableObject)obj.gameObject.AddComponent(addType);
                    }
                }
            }

            if (bindable != null && children.IndexOf(bindable) < 0)
            {
                refer.AddChild(bindable);
            }
        }
コード例 #10
0
 static public int GetComponents__Type(IntPtr l)
 {
     try {
         UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
         System.Type           a1;
         checkType(l, 2, out a1);
         var ret = self.GetComponents(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #11
0
        public static IList <T> GetInterfaceComponents <T>(this Component component, bool firstOnly = false) where T : class
        {
            var types = _interfaceToComponentMapping[typeof(T)];

            if (null == types || types.Count <= 0)
            {
                Debug.LogError("No descendants found for type " + typeof(T));
                return(null);
            }

            var resList = new List <T>();

            foreach (var curType in types)
            {
                Component[] components = firstOnly ?
                                         new [] { component.GetComponent(curType) }
                        : component.GetComponents(curType);

                if (null == components || components.Length <= 0)
                {
                    continue;
                }

                var tList = new List <T>();

                foreach (var curComp in components)
                {
                    if (curComp == null)
                    {
                        continue;
                    }

                    var curCompAsT = curComp as T;

                    if (null == curCompAsT)
                    {
                        Debug.LogError("Unable to cast '" + curComp.GetType() + "' to '" + typeof(T) + "'");
                        continue;
                    }

                    tList.Add(curCompAsT);
                }

                resList.AddRange(tList);
            }

            return(resList);
        }
コード例 #12
0
 static public int GetComponents__Type__List_1_Component(IntPtr l)
 {
     try {
         UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
         System.Type           a1;
         checkType(l, 2, out a1);
         System.Collections.Generic.List <UnityEngine.Component> a2;
         checkType(l, 3, out a2);
         self.GetComponents(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #13
0
 public static int GetComponents_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.GetComponents(arg0);
         long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         FCCustomParam.ReturnArray(ret, ret_ptr);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
コード例 #14
0
 public static int GetComponents1_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));
         List <UnityEngine.Component> arg1 = null;
         arg1 = FCCustomParam.GetList(ref arg1, L, 1);
         obj.GetComponents(arg0, arg1);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
コード例 #15
0
    public static T GetComponentInterface <T>(this UnityEngine.Component o)
    {
        var targetType = typeof(T);
        var components = o.GetComponents <Component>();

        foreach (var component in components)
        {
            foreach (var objectInterface in component.GetType().GetInterfaces())
            {
                if (objectInterface == targetType)
                {
                    return(component.To <T>());
                }
            }
        }

        return(default(T));
    }
コード例 #16
0
    public static List <T> GetComponentInterfaces <T>(this UnityEngine.Component o)
    {
        var result     = new List <T>();
        var targetType = typeof(T);
        var components = o.GetComponents <Component>();

        foreach (var component in components)
        {
            foreach (var objectInterface in component.GetType().GetInterfaces())
            {
                if (objectInterface == targetType)
                {
                    result.Add(component.To <T>());
                }
            }
        }

        return(result);
    }
コード例 #17
0
 static public int GetComponents(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(System.Type)))
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.Type           a1;
             checkType(l, 2, out a1);
             UnityEngine.Component[] ret = self.GetComponents(a1);
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #18
0
ファイル: SpriteMask.cs プロジェクト: ChubbRck/SFB
	private static bool hasSkipMasking (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <SkipMasking> () != null;
#else
		t.GetComponents <SkipMasking> (skipMaskingComponents);
		bool b = skipMaskingComponents.Count > 0;
		skipMaskingComponents.Clear ();
		return b;
#endif
	}
コード例 #19
0
ファイル: Attributes.cs プロジェクト: paulmoore/UnJect
 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);
 }
コード例 #20
0
ファイル: SpriteMask.cs プロジェクト: masyl/bolt
	private static Renderer getRenderer (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <Renderer> ();
#else
		t.GetComponents <Renderer> (rendererComponents);
		Renderer r = rendererComponents.Count > 0 ? rendererComponents [0] : null;
		rendererComponents.Clear ();
		return r;
#endif
	}
コード例 #21
0
ファイル: SpriteMask.cs プロジェクト: ChubbRck/SFB
	private static SpriteMaskingComponent getMaskingComponent (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <SpriteMaskingComponent> ();
#else
		t.GetComponents <SpriteMaskingComponent> (maskingComponents);
		SpriteMaskingComponent smc = maskingComponents.Count == 1 ? maskingComponents [0] : null;
		maskingComponents.Clear ();
		return smc;
#endif
	}
コード例 #22
0
ファイル: NetworkManager.cs プロジェクト: Greigy/TheGame
    /// <summary>
    /// Helper function that returns the observer for the specified component.
    /// </summary>
    public static NetworkView GetObserver(Component comp)
    {
        NetworkView[] views = comp.GetComponents<NetworkView>();

        foreach (NetworkView view in views)
        {
            if (view.observed == comp && view.stateSynchronization != NetworkStateSynchronization.Off)
            {
                return view;
            }
        }
        return null;
    }
コード例 #23
0
ファイル: SpriteMask.cs プロジェクト: masyl/bolt
	private static SpriteMask getSpriteMask (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <SpriteMask> ();
#else
		t.GetComponents <SpriteMask> (maskComponents);
		SpriteMask sm = maskComponents.Count == 1 ? maskComponents [0] : null;
		maskComponents.Clear ();
		return sm;
#endif
	}
コード例 #24
0
ファイル: ModuleList.cs プロジェクト: bsimser/general2
 public void UpdateList()
 {
     list = target.GetComponents <T>().ToList();
     SetVisibility();
 }
コード例 #25
0
        public void AddbindableObjects(BindableContainer refer, UnityEngine.Component obj)
        {
            if (refer.children == null) //需要新增加
            {
                List <Binding> bindings = new List <Binding> ();
                // if (refer.bindableObjects != null) bindings.AddRange (refer.bindableObjects);
                // if (i == -1) i = bindings.Count;
                // while (bindings.Count <= i)
                //     bindings.Add (new Binding () { expression = @"{}" });

                refer.children = new List <BindableObject> (); // bindings.ToArray ();
                // Debug.Log (bindings.Count);
            }

            var            children = refer.children;
            BindableObject bindable = null;

            if (obj is BindableObject)
            {
                bindable = obj as BindableObject;
                // bindable.target = obj;
            }
            else
            {
                // BindableObject bindable = obj.<BindableObject> ();

                if (bindable == null)
                {
                    Component[] allcomps = obj.GetComponents <Component> (); //默认绑定最后一个组件
                    Component   target   = null;
                    int         index    = 0;
                    int         tpId     = -1;
                    foreach (var comp in allcomps)
                    {
                        if (comp is BindableObject)
                        {
                            bindable = (BindableObject)comp;
                            break;
                        }
                        else if ((index = BinderCheckTypes.IndexOf(comp.GetType())) >= 0)
                        {
                            target = comp;
                            tpId   = index;
                        }
                    }

                    if (bindable == null)
                    {
                        Type createBinderType = typeof(Hugula.Databinding.Binder.UIBehaviourBinder);
                        if (tpId >= 0)
                        {
                            createBinderType = BinderCreateTypes[tpId];
                        }

                        bindable        = (BindableObject)obj.gameObject.AddComponent(createBinderType);
                        bindable.target = target;
                    }
                }
            }

            bindable.targetName = obj.name;
            // bindable.binderType = GetBinderType (bindable.target.GetType ());
            if (children.IndexOf(bindable) < 0)
            {
                refer.AddChild(bindable);
            }

            // Binding binditem = bindableObjects[i];
            // binditem.target = obj;
            // if (obj) {
            //     binditem.binderType = GetBinderType (obj.GetType ());
            //     binditem.targetName = obj.name.Trim ();
            // }
        }
コード例 #26
0
ファイル: SpriteMask.cs プロジェクト: ChubbRck/SFB
	private static bool hasMaskingPart (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <SpriteMaskingPart> () != null;
#else
		t.GetComponents <SpriteMaskingPart> (maskingPartComponents);
		bool b = maskingPartComponents.Count > 0;
		maskingPartComponents.Clear ();
		return b;
#endif
	}
コード例 #27
0
 public static t GetEnabledComponent <t>(this Component comp) where t : MonoBehaviour
 {
     return(comp.GetComponents <t>().FirstOrDefault(p => p.enabled));
 }
コード例 #28
0
 public static Component[] GetComponents0T(this UnityEngine.Component self, System.Type T)
 {
     return(self.GetComponents(T));
 }