public void OnProcessScene(SceneManagement.Scene scene) #endif { // In addition to the build process, OnProcessScene is also called on the current scene // when entering playmode in the Editor, but without OnPreprocessBuild. // Since we only want to generate a link.xml when building with the IL2CPP scripting // backend, we need to check for both conditions. if (buildingPlayer && isIL2CPPBuild()) { foreach (var root in scene.GetRootGameObjects()) { foreach (var rs in root.GetComponentsInChildren <RemoteSettings>()) { DriveableProperty dp = rs.driveableProperty; AddTypesToHash(dp.fields, types); } } // OnPostprocessBuild is called after assemblies are already stripped // so we need to write the link.xml file immediately after the last scene // is processed. if (scene.path == lastActiveScene) { WriteLinkXml(types); types = null; // I can't tell the lifecycle of this class, so set this to false just in case. buildingPlayer = false; } } }
public void OnPreprocessBuild(BuildTarget target, string path) #endif { // OnPreprocessBuild is only called when building a player. buildingPlayer = true; if (File.Exists(k_LinkPath)) { Console.WriteLine("Deleting Remote Settings link file at " + k_LinkPath); try { File.Delete(k_LinkPath); } catch (Exception e) { Debug.LogWarning("Failed to clean up Remote Settings link.xml file due to: " + e); } } if (isIL2CPPBuild()) { var scenes = EditorBuildSettings.scenes; foreach (var scene in scenes) { if (scene.enabled) { lastActiveScene = scene.path; } } types = new Dictionary <string, HashSet <string> >(); // Collected referenced types for all prefabs var prefabs = AssetDatabase.FindAssets("t:GameObject"); foreach (var guid in prefabs) { GameObject go = (GameObject)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(GameObject)); if (go) { foreach (var rs in go.GetComponentsInChildren <RemoteSettings>()) { DriveableProperty dp = rs.driveableProperty; AddTypesToHash(dp.fields, types); } } } } }