GetObjectsMode() private method

private GetObjectsMode ( SelectionMode mode ) : Object[]
mode SelectionMode
return Object[]
Exemplo n.º 1
0
        /// <summary>
        ///   <para>Returns the current selection filtered by type and mode.</para>
        /// </summary>
        /// <param name="type">Only objects of this type will be retrieved.</param>
        /// <param name="mode">Further options to refine the selection.</param>
        public static UnityEngine.Object[] GetFiltered(System.Type type, SelectionMode mode)
        {
            ArrayList arrayList = new ArrayList();

            if (type == typeof(Component) || type.IsSubclassOf(typeof(Component)))
            {
                foreach (Component transform in Selection.GetTransforms(mode))
                {
                    Component component = transform.GetComponent(type);
                    if ((bool)((UnityEngine.Object)component))
                    {
                        arrayList.Add((object)component);
                    }
                }
            }
            else if (type == typeof(GameObject) || type.IsSubclassOf(typeof(GameObject)))
            {
                foreach (Transform transform in Selection.GetTransforms(mode))
                {
                    arrayList.Add((object)transform.gameObject);
                }
            }
            else
            {
                foreach (UnityEngine.Object @object in Selection.GetObjectsMode(mode))
                {
                    if (@object != (UnityEngine.Object)null && (@object.GetType() == type || @object.GetType().IsSubclassOf(type)))
                    {
                        arrayList.Add((object)@object);
                    }
                }
            }
            return((UnityEngine.Object[])arrayList.ToArray(typeof(UnityEngine.Object)));
        }
Exemplo n.º 2
0
        public static UnityEngine.Object[] GetFiltered(Type type, SelectionMode mode)
        {
            ArrayList arrayList = new ArrayList();

            if (type == typeof(Component) || type.IsSubclassOf(typeof(Component)))
            {
                Transform[] transforms = Selection.GetTransforms(mode);
                Transform[] array      = transforms;
                for (int i = 0; i < array.Length; i++)
                {
                    Transform transform = array[i];
                    Component component = transform.GetComponent(type);
                    if (component)
                    {
                        arrayList.Add(component);
                    }
                }
            }
            else if (type == typeof(GameObject) || type.IsSubclassOf(typeof(GameObject)))
            {
                Transform[] transforms2 = Selection.GetTransforms(mode);
                Transform[] array2      = transforms2;
                for (int j = 0; j < array2.Length; j++)
                {
                    Transform transform2 = array2[j];
                    arrayList.Add(transform2.gameObject);
                }
            }
            else
            {
                UnityEngine.Object[] objectsMode = Selection.GetObjectsMode(mode);
                UnityEngine.Object[] array3      = objectsMode;
                for (int k = 0; k < array3.Length; k++)
                {
                    UnityEngine.Object @object = array3[k];
                    if (@object != null)
                    {
                        if (@object.GetType() == type || @object.GetType().IsSubclassOf(type))
                        {
                            arrayList.Add(@object);
                        }
                    }
                }
            }
            return((UnityEngine.Object[])arrayList.ToArray(typeof(UnityEngine.Object)));
        }
Exemplo n.º 3
0
        private static IEnumerable GetFilteredInternal(Type type, SelectionMode mode)
        {
            IEnumerable result;

            if (typeof(Component).IsAssignableFrom(type) || type.IsInterface)
            {
                result = from t in Selection.GetTransforms(mode)
                         select t.GetComponent(type) into c
                             where c != null
                         select c;
            }
            else if (typeof(GameObject).IsAssignableFrom(type))
            {
                result = from t in Selection.GetTransforms(mode)
                         select t.gameObject;
            }
            else
            {
                result = from o in Selection.GetObjectsMode(mode)
                         where o != null && type.IsAssignableFrom(o.GetType())
                         select o;
            }
            return(result);
        }