-
Notifications
You must be signed in to change notification settings - Fork 47
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
Draft
jonsimantov
wants to merge
6
commits into
main
Choose a base branch
from
feature/windows-analytics-dll-copy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a08a6c1
feat: Copy analytics_win.dll for Windows Build and Play Mode
google-labs-jules[bot] 7f94742
refactor: Use shared constants and add error handling for Analytics D…
google-labs-jules[bot] 949ac29
fix: Correct Play Mode DLL copy path for analytics_win.dll
google-labs-jules[bot] 8b402ea
fix: Prevent self-copy of analytics_win.dll in Play Mode
google-labs-jules[bot] 7d38c42
fix: Add .asmdef for editor scripts to resolve Mac build error
google-labs-jules[bot] 13aba5b
Based on your feedback, I've reverted some recent changes to simplify…
google-labs-jules[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
|
||
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."); | ||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.