ReplaceReferencesInScene() public static method

Replaces all the references in the scene (does not work with internal properties).
public static ReplaceReferencesInScene ( List spriteInfoList, SPReferenceReplacerWindow replaceMode, bool spriteRenderersOnly ) : int
spriteInfoList List Sprite info list.
replaceMode SPReferenceReplacerWindow
spriteRenderersOnly bool If set to true sprite renderers only.
return int
        protected void OnGUI()
        {
            EditorGUIUtility.labelWidth = 100f;

            GUILayout.BeginVertical();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.top);
            GUILayout.BeginHorizontal();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.left);
            GUILayout.BeginVertical();

            GUI.changed     = false;
            this.m_Instance = EditorGUILayout.ObjectField("Sprite Packer", this.m_Instance, typeof(SPInstance), false) as SPInstance;
            if (GUI.changed)
            {
                // Save the instance id
                EditorPrefs.SetInt(SPTools.Settings_SavedInstanceIDKey, (this.m_Instance == null) ? 0 : this.m_Instance.GetInstanceID());
            }

            GUILayout.Space(6f);

            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.Space(6f);

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);

            EditorGUILayout.LabelField("Replace mode", GUILayout.Width(130f));
            this.m_ReplaceMode = (ReplaceMode)EditorGUILayout.EnumPopup(this.m_ReplaceMode);

            GUILayout.Space(6f);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField("Replace references in", GUILayout.Width(130f));
            this.m_TargetMode = (TargetMode)EditorGUILayout.EnumPopup(this.m_TargetMode);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetInt(SPReferenceReplacerWindow.PrefsKey_TargetMode, (int)this.m_TargetMode);
            }

            GUILayout.Space(6f);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);
            GUI.changed = false;
            bool spriteRenderersOnly = GUILayout.Toggle(EditorPrefs.GetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly), " Replace references in Sprite Renderers only ?");

            if (GUI.changed)
            {
                EditorPrefs.SetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly, spriteRenderersOnly);
            }
            GUILayout.Space(6f);
            GUILayout.EndHorizontal();

            GUILayout.Space(6f);
            GUILayout.EndVertical();

            GUILayout.Space(6f);

            if (this.m_Instance == null)
            {
                EditorGUILayout.HelpBox("Please set the sprite packer instance reference in order to use this feature.", MessageType.Info);
            }
            else
            {
                if (GUILayout.Button("Replace"))
                {
                    int replacedCount = 0;

                    switch (this.m_TargetMode)
                    {
                    case TargetMode.CurrentScene:
                    {
                        replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        break;
                    }

                    case TargetMode.ProjectOnly:
                    {
                        replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        break;
                    }

                    case TargetMode.CurrentSceneAndProject:
                    {
                        replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        break;
                    }

                    case TargetMode.AllScenes:
                    {
                        replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly, false);
                        break;
                    }

                    case TargetMode.AllScenesAndProject:
                    {
                        replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly);
                        EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
                        replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly, true);
                        break;
                    }
                    }

                    EditorUtility.DisplayDialog("Reference Replacer", "Replaced references count: " + replacedCount.ToString(), "Okay");
                }
            }

            GUILayout.EndVertical();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.right);
            GUILayout.EndHorizontal();
            GUILayout.Space((float)SPReferenceReplacerWindow.padding.bottom);
            GUILayout.EndVertical();
        }