-
Notifications
You must be signed in to change notification settings - Fork 46
Copy GA DLL for Windows Build and Play Mode if it exists #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a08a6c1
7f94742
949ac29
8b402ea
7d38c42
13aba5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.IO; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Firebase.Editor { | ||
|
||
[InitializeOnLoad] | ||
internal static class AnalyticsPlayModeSetup { | ||
private const string DestinationDir = "./"; | ||
|
||
static AnalyticsPlayModeSetup() { | ||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged; | ||
} | ||
|
||
private static void OnPlayModeStateChanged(PlayModeStateChange state) { | ||
if (state == PlayModeStateChange.EnteredPlayMode) { | ||
if (Application.platform == RuntimePlatform.WindowsEditor) { | ||
Type firebaseAnalyticsType = Type.GetType("Firebase.Analytics.FirebaseAnalytics, Firebase.Analytics"); | ||
if (firebaseAnalyticsType != null) { | ||
if (File.Exists("./analytics_win.dll")) { | ||
string fullSourcePath = Path.GetFullPath("./analytics_win.dll"); | ||
// string destinationDirectory = "./"; // This is DestinationDir | ||
string fullDestinationPath = Path.GetFullPath(Path.Combine(DestinationDir, "analytics_win.dll")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing ever changes DestinationDir afaik, so this will always be ./analytics_win.dll, which will be the same as the fullSourcePath above. I'm not clear what it is trying to do here. |
||
|
||
if (fullSourcePath.Equals(fullDestinationPath, StringComparison.OrdinalIgnoreCase)) { | ||
Debug.Log("Firebase Analytics: analytics_win.dll is already in the project root. No copy needed for Play Mode."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably don't want to log if nothing is being done, cause that'll be pretty spammy. |
||
return; | ||
} | ||
|
||
try { | ||
Directory.CreateDirectory(DestinationDir); // Should be benign for "./" | ||
string destinationDllPath = Path.Combine(DestinationDir, "analytics_win.dll"); | ||
File.Copy("./analytics_win.dll", destinationDllPath, true); | ||
Debug.Log("Firebase Analytics: Copied analytics_win.dll to project root for Play Mode."); | ||
} catch (Exception e) { | ||
Debug.LogError("Firebase Analytics: Error copying analytics_win.dll for Play Mode: " + e.Message); | ||
} | ||
} else { | ||
// Optional: Log if source DLL is not found, as it might be expected if Analytics is not used. | ||
// Debug.LogWarning("Firebase Analytics: Source DLL ./analytics_win.dll not found. Skipping Play Mode setup."); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} // namespace Firebase.Editor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs to be added to the editor/app/CMakeLists.txt