Пример #1
0
        private string[] BuildMonoAssembliesList()
        {
            filter = "";
            var result = new System.Collections.Generic.List <System.Type>();

            System.Reflection.Assembly[] AS = System.AppDomain.CurrentDomain.GetAssemblies();
            foreach (var A in AS)
            {
                System.Type[] types = A.GetTypes();
                foreach (var T in types)
                {
                    if (T.IsSubclassOf(typeof(MonoBehaviour)))
                    {
                        if (T.IsSubclassOf(typeof(UIBehaviour)))
                        {
                            continue;
                        }

                        result.Add(T);
                    }
                }
            }

            result.Sort(this.Compare);
            //result.Sort((typA, typB) => typA.Name.CompareTo(typB.Name));

            var   output      = new System.Collections.Generic.List <string>();
            float unusedCount = 0;

            foreach (var type in result)
            {
                string reportLine = type.Name + "     (" + type.FullName + ")";
                if (_monoBehaviorsInProject.ContainsKey(type))
                {
                    reportLine  = chk + reportLine;
                    reportLine += "     Used in: [";
                    foreach (GameObject gameObject in (ValueArray)_monoBehaviorsInProject[type])
                    {
                        reportLine += " " + gameObject.name;
                    }
                    reportLine += " ]";
                }
                else
                {
                    unusedCount++;
                    reportLine = exx + reportLine;
                }


                output.Add(reportLine);
            }

            output.Insert(0, "      UNUSED MONOBEHAVIOUR CLASSES = " + (100f * unusedCount / result.Count).ToString("0.0") + "%");

            return(output.ToArray());
        }
Пример #2
0
        private void RefreshMonoInScenesList()
        {
            filter = "";
            _monoBehaviorsInActiveScenes.Clear();

            var mbs = Resources.FindObjectsOfTypeAll(typeof(MonoBehaviour)) as MonoBehaviour[];

            if (mbs == null)
            {
                return;
            }

            foreach (MonoBehaviour mb in mbs)
            {
                if (string.IsNullOrEmpty(mb.gameObject.scene.name))
                {
                    continue;
                }

                if (IsUnityBehavior(mb))
                {
                    continue;
                }

                if (!_monoBehaviorsInActiveScenes.ContainsKey(mb.GetType()))
                {
                    _monoBehaviorsInActiveScenes[mb.GetType()] = new ValueArray();
                }

                ((ValueArray)_monoBehaviorsInActiveScenes[mb.GetType()]).Add(mb.gameObject);
            }
        }