Пример #1
0
        // Token: 0x06006421 RID: 25633 RVA: 0x0023CB04 File Offset: 0x0023AF04
        public static IEnumerable <Component> FindIllegalComponents(string Name, GameObject currentAvatar)
        {
            HashSet <Type>     hashSet = new HashSet <Type>();
            List <Component>   list    = new List <Component>();
            Queue <GameObject> queue   = new Queue <GameObject>();

            queue.Enqueue(currentAvatar.gameObject);
            while (queue.Count > 0)
            {
                GameObject gameObject = queue.Dequeue();
                int        childCount = gameObject.transform.childCount;
                for (int i = 0; i < gameObject.transform.childCount; i++)
                {
                    queue.Enqueue(gameObject.transform.GetChild(i).gameObject);
                }
                foreach (Component component in gameObject.transform.GetComponents <Component>())
                {
                    if (!(component == null))
                    {
                        if (!hashSet.Contains(component.GetType()))
                        {
                            hashSet.Add(component.GetType());
                        }
                        list.Add(component);
                    }
                }
            }
            IEnumerable <Type> foundTypes = AvatarValidation.FindTypes();

            return(from c in list
                   where !foundTypes.Any((Type allowedType) => c != null && (c.GetType() == allowedType || c.GetType().IsSubclassOf(allowedType)))
                   select c);
        }
Пример #2
0
        // Token: 0x06006422 RID: 25634 RVA: 0x0023CC1C File Offset: 0x0023B01C
        public static void RemoveIllegalComponents(string Name, GameObject currentAvatar, bool retry = true)
        {
            IEnumerable <Component> enumerable = AvatarValidation.FindIllegalComponents(Name, currentAvatar);
            HashSet <string>        hashSet    = new HashSet <string>();

            foreach (Component component in enumerable)
            {
                if (!hashSet.Contains(component.GetType().Name))
                {
                    hashSet.Add(component.GetType().Name);
                }
                UnityEngine.Object.DestroyImmediate(component);
            }
            if (retry && hashSet.Count > 0)
            {
                AvatarValidation.RemoveIllegalComponents(Name, currentAvatar, false);
            }
        }