Skip to content

Commit 6209b33

Browse files
committed
Import v4 Editor from unitypackage.
1 parent 6497394 commit 6209b33

File tree

3 files changed

+108
-1
lines changed

3 files changed

+108
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2014 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
@CustomPropertyDrawer(AdvertiserOptInAttribute)
18+
class AdvertiserOptInDrawer extends PropertyDrawer {
19+
20+
function OnGUI(position : Rect, property : SerializedProperty, label : GUIContent) {
21+
22+
// TODO: I don't like this, but guilayout was not cooperating, revisit later.
23+
var indent = 25;
24+
var row1 = position.y + 15;
25+
var row2 = row1 + 25;
26+
var row3 = row2 + 85;
27+
28+
EditorGUI.LabelField(Rect(position.x, row1, 155, 25), "Advertiser Id Support");
29+
30+
var style = new GUIStyle(EditorStyles.textArea);
31+
style.wordWrap = true;
32+
33+
EditorGUI.TextArea(Rect(position.x+indent, row2, position.width - 40, 75), "If you enable this collection, ensure that you review and adhere to the Google Analytics policies for SDKs and advertising features. Click the button below to view them in your browser.", style);
34+
EditorGUI.LabelField(Rect(position.x+indent, row3, 155, 25), "Send IDFA/AdID");
35+
EditorGUI.PropertyField(Rect(position.x+125, row3, 15, 25), property, GUIContent.none);
36+
37+
if(GUI.Button(Rect(position.x+150, row3 - 5, 115, 25), "View GA Policies")) {
38+
Application.OpenURL("https://support.google.com/analytics/answer/2700409");
39+
}
40+
}
41+
42+
function GetPropertyHeight (property : SerializedProperty, label : GUIContent) {
43+
var height = EditorGUI.GetPropertyHeight(property, label);
44+
return height + 140;
45+
}
46+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2015 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
using UnityEngine;
18+
using UnityEditor;
19+
using System.Collections;
20+
using System.IO;
21+
22+
public class GoogleAnalyticsSetup : EditorWindow {
23+
[MenuItem("Google Analytics/Setup")]
24+
public static void GoogleAnalyticsSetupMenu() {
25+
EditorWindow.GetWindow(typeof(GoogleAnalyticsSetup));
26+
}
27+
28+
void OnGUI() {
29+
GUILayout.BeginArea(new Rect(20, 20, position.width - 40, position.height - 40));
30+
GUILayout.Label("Google Analytics Android Setup", EditorStyles.boldLabel);
31+
GUILayout.TextArea("Click the button below to copy the Google Play Services lib from your Android directory into your current project.\n\nThis will delete the existing version of the library if you have already imported it.");
32+
33+
GUILayout.Space(10);
34+
if (GUILayout.Button("Install google-play-services_lib")) {
35+
InstallPlayServicesLib();
36+
}
37+
GUILayout.EndArea();
38+
}
39+
40+
private void InstallPlayServicesLib() {
41+
string src = EditorPrefs.GetString("AndroidSdkRoot") +
42+
"/extras/google/google_play_services/libproject/google-play-services_lib".Replace("//", "/").Replace("\\\\", "\\");
43+
string dest = "Assets/Plugins/Android/google-play-services_lib";
44+
45+
if (!System.IO.Directory.Exists(src)) {
46+
Debug.LogError("Could not locate google-play-services_lib in: " + src);
47+
EditorUtility.DisplayDialog("Lib not found", "Could not locate google-play-services_lib\n\nPlease ensure you have specified the correct path to your Android SDK and have downloaded the Google Play Services library.", "OK");
48+
return;
49+
}
50+
51+
System.IO.Directory.CreateDirectory("Assets/Plugins/Android");
52+
53+
if (System.IO.Directory.Exists(dest)) {
54+
System.IO.Directory.Delete(dest, true);
55+
}
56+
57+
FileUtil.CopyFileOrDirectory(src, dest);
58+
AssetDatabase.Refresh();
59+
EditorUtility.DisplayDialog("Congrats", "Google Play Services has been copied into your project.", "OK");
60+
}
61+
}

source/Plugins/Editor/TooltipDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
103103
}
104104

105105
#endif
106-
}
106+
}

0 commit comments

Comments
 (0)