EditorPrefs . SetBool ( kShowIgnoredPreference , value ) ;
}
}
int noticeCount ;
int warningCount ;
int errorCount ;
enum SortMode
{
filterString = EditorGUILayout . DelayedTextField ( filterString , EditorStyles . toolbarSearchField , GUILayout . Width ( 1 8 0 ) ) ;
showIgnored = GUILayout . Toggle ( showIgnored , "Ignored" , EditorStyles . toolbarButton ) ;
showNotice = GUILayout . Toggle ( showNotice , new GUIContent ( m_Results . Where ( o = > o . result = = CheckResult . Result . Notice ) . Count ( ) . ToString ( ) , CheckResult . GetIcon ( CheckResult . Result . Notice ) ) , EditorStyles . toolbarButton ) ;
showWarning = GUILayout . Toggle ( showWarning , new GUIContent ( m_Results . Where ( o = > o . result = = CheckResult . Result . Warning ) . Count ( ) . ToString ( ) , CheckResult . GetIcon ( CheckResult . Result . Warning ) ) , EditorStyles . toolbarButton ) ;
showError = GUILayout . Toggle ( showError , new GUIContent ( m_Results . Where ( o = > o . result = = CheckResult . Result . Failed ) . Count ( ) . ToString ( ) , CheckResult . GetIcon ( CheckResult . Result . Failed ) ) , EditorStyles . toolbarButton ) ;
showNotice = GUILayout . Toggle ( showNotice , new GUIContent ( noticeCount . ToString ( ) , CheckResult . GetIcon ( CheckResult . Result . Notice ) ) , EditorStyles . toolbarButton ) ;
showWarning = GUILayout . Toggle ( showWarning , new GUIContent ( warningCount . ToString ( ) , CheckResult . GetIcon ( CheckResult . Result . Warning ) ) , EditorStyles . toolbarButton ) ;
showError = GUILayout . Toggle ( showError , new GUIContent ( errorCount . ToString ( ) , CheckResult . GetIcon ( CheckResult . Result . Failed ) ) , EditorStyles . toolbarButton ) ;
}
using ( new GUILayout . VerticalScope ( ) )
SortButton ( "Object" , SortMode . ObjectName , GUILayout . Width ( 1 2 8 ) ) ;
SortButton ( "Message" , SortMode . Message , GUILayout . ExpandWidth ( true ) ) ;
SortButton ( "Resolution" , SortMode . Resolution , GUILayout . Width ( 1 2 8 ) ) ;
if ( showIgnored )
SortButton ( "Ignored" , SortMode . Ignored , GUILayout . Width ( 6 4 ) ) ;
SortButton ( "Ignored" , SortMode . Ignored , GUILayout . Width ( 6 4 ) ) ;
GUILayout . Space ( 1 2 ) ;
}
bool odd = true ;
foreach ( var result in m_Results )
{
if ( ! showIgnored & & IsIgnored ( result ) | | result . mainObject = = null )
continue ;
EditorGUI . EndDisabledGroup ( ) ;
if ( showIgnored )
GUILayout . Space ( 1 8 ) ;
EditorGUI . BeginChangeCheck ( ) ;
var ignored = GUILayout . Toggle ( IsIgnored ( result ) , "" , EditorStyles . toggle , GUILayout . Width ( 2 4 ) ) ;
if ( EditorGUI . EndChangeCheck ( ) )
GUILayout . Space ( 1 8 ) ;
EditorGUI . BeginChangeCheck ( ) ;
var ignored = GUILayout . Toggle ( IsIgnored ( result ) , "" , EditorStyles . toggle , GUILayout . Width ( 2 4 ) ) ;
if ( EditorGUI . EndChangeCheck ( ) )
{
SetIgnored ( result , ignored ) ;
}
GUILayout . Space ( 1 8 ) ;
SetIgnored ( result , ignored ) ;
GUILayout . Space ( 1 8 ) ;
}
}
m_Results = results ;
sortMode = SortMode . None ;
noticeCount = m_Results . Where ( o = > o . result = = CheckResult . Result . Notice ) . Count ( ) ;
warningCount = m_Results . Where ( o = > o . result = = CheckResult . Result . Warning ) . Count ( ) ;
errorCount = m_Results . Where ( o = > o . result = = CheckResult . Result . Failed ) . Count ( ) ;
static class Styles
{
public class SceneObjects
{
public GameObject [ ] scene Objects;
public GameObject [ ] all Objects;
public List < GameObject > referencedGameObjects ;
public List < Component > referencedComponents ;
public List < UnityEngine . Object > referencedObjects ;
sceneObjects = GameObject . FindObjectsOfType < GameObject > ( ) ;
allObjects = Resources . FindObjectsOfTypeAll < GameObject > ( ) ;
allObjects = allObjects . Where ( o = > ! PrefabUtility . IsPartOfPrefabAsset ( o ) & & o . hideFlags = = HideFlags . None ) . ToArray ( ) ;
if ( sceneObjects = = null | | sceneObjects . Length = = 0 )
if ( allObjects = = null | | allObjects . Length = = 0 )
int count = sceneObjects . Length ;
int count = allObjects . Length ;
foreach ( var sceneObject in sceneObjects )
foreach ( var sceneObject in allObjects )
float progress = + + i / ( float ) count ;
if ( EditorUtility . DisplayCancelableProgressBar ( "Building Reference Table..." , $"{sceneObject.name}" , progress ) )
{
var components = sceneObject . GetComponents < Component > ( ) ;
foreach ( var component in components )
{
if ( ! ( component is Transform ) )
if ( component is Transform )
continue ;
else if ( component is Renderer )
{
var renderer = component as Renderer ;
if ( renderer . probeAnchor ! = null )
{
referencedComponents . Add ( renderer . probeAnchor ) ;
referencedGameObjects . Add ( renderer . probeAnchor . gameObject ) ;
}
foreach ( var sharedMat in renderer . sharedMaterials )
{
referencedObjects . Add ( sharedMat ) ;
}
}
else
{
Type t = component . GetType ( ) ;
FieldInfo [ ] fields = t . GetFields ( BindingFlags . Public
referencedGameObjects . Add ( go ) ;
}
}
else if ( f . FieldType = = typeof ( GameObject [ ] ) )
{
var golist = f . GetValue ( component ) as GameObject [ ] ;
foreach ( var go in golist )
if ( go ! = null & & go ! = component . gameObject )
{
referencedGameObjects . Add ( go ) ;
}
}
else if ( f . FieldType = = typeof ( Transform ) )
{
var tr = f . GetValue ( component ) as Transform ;
referencedComponents . Add ( tr ) ;
else if ( f . FieldType = = typeof ( Transform [ ] ) )
{
var trlist = f . GetValue ( component ) as Transform [ ] ;
foreach ( var tr in trlist )
if ( tr ! = null & & tr . gameObject ! = component . gameObject )
{
referencedGameObjects . Add ( tr . gameObject ) ;
referencedComponents . Add ( tr ) ;
}
}
referencedGameObjects . Add ( comp . gameObject ) ;
}
else if ( f . FieldType . IsSubclassOf ( typeof ( Component [ ] ) ) )
{
var complist = f . GetValue ( component ) as Component [ ] ;
foreach ( var comp in complist )
if ( comp ! = null & & comp . gameObject ! = component . gameObject )
{
referencedGameObjects . Add ( comp . gameObject ) ;
referencedComponents . Add ( comp ) ;
}
}
else if ( f . FieldType = = typeof ( UnityEvent ) )
{