/// <summary> /// This will update the map of SerializedProperties to Object ID /// </summary> private static void UpdateReferencesMap() { if ( _referenceMap != null ) return; double startTime = EditorApplication.timeSinceStartup; // Get all of the valid MonoBehaviours or ScriptableObjects var allMonoBehaviourObjs = Resources.FindObjectsOfTypeAll<MonoBehaviour>().Where( x => !EditorUtility.IsPersistent(x) ).Cast<Object>(); var allScriptableObjs = Resources.FindObjectsOfTypeAll<ScriptableObject>().Where( x => !EditorUtility.IsPersistent(x) && !typeof(EditorWindow).IsAssignableFrom(x.GetType()) ).Cast<Object>(); // We assume we're up to date for a single frame... EditorApplication.delayCall += () => { _referenceMap = null; }; _referenceMap = new List<KeyValuePair<SerializedProperty, Object>>( allMonoBehaviourObjs.Count() + allScriptableObjs.Count() ); // Figure out what they're referencing PopulateReferenceMap( _referenceMap, allMonoBehaviourObjs ); PopulateReferenceMap( _referenceMap, allScriptableObjs ); // Now we have all of the custom data processors. Note that we don't want to run over-top of what we've already processed, so let's exclude all of those... foreach ( var customType in _customCrossSceneReferenceDataProcessors.Keys ) { // Handle the cases where we've already added these objects to the list... if ( typeof(MonoBehaviour).IsAssignableFrom(customType) ) continue; if ( typeof(ScriptableObject).IsAssignableFrom(customType) ) continue; // Now grab all of the objects and add them to our reference map var sceneCustomObjects = Resources.FindObjectsOfTypeAll( customType ).Where( x => !EditorUtility.IsPersistent(x) ); PopulateReferenceMap( _referenceMap, sceneCustomObjects ); } AmsDebug.LogPerf( null, "Cross-Scene Reference Map Update: {0}", (EditorApplication.timeSinceStartup - startTime) ); }
/// <summary> /// This will update the map of SerializedProperties to Object ID /// </summary> private static void UpdateReferencesMap() { if ( _referenceMap != null ) return; double startTime = EditorApplication.timeSinceStartup; // Get all of the valid MonoBehaviours or ScriptableObjects var allMonoBehaviourObjs = Resources.FindObjectsOfTypeAll<MonoBehaviour>().Where( x => !EditorUtility.IsPersistent(x) ).Cast<Object>(); var allScriptableObjs = Resources.FindObjectsOfTypeAll<ScriptableObject>().Where( x => !EditorUtility.IsPersistent(x) && !typeof(EditorWindow).IsAssignableFrom(x.GetType()) ).Cast<Object>(); // We assume we're up to date for a single frame... EditorApplication.delayCall += () => { _referenceMap = null; }; _referenceMap = new List<KeyValuePair<SerializedProperty, Object>>( allMonoBehaviourObjs.Count() + allScriptableObjs.Count() ); // Figure out what they're referencing PopulateReferenceMap( _referenceMap, allMonoBehaviourObjs ); PopulateReferenceMap( _referenceMap, allScriptableObjs ); AmsDebug.LogPerf( null, "Cross-Scene Reference Map Update: {0}", (EditorApplication.timeSinceStartup - startTime) ); }