[M] sync n3

This commit is contained in:
2024-12-09 16:54:19 +08:00
parent c90bbe86e7
commit 05331e6286
845 changed files with 6138 additions and 1307 deletions

View File

@@ -0,0 +1,17 @@
{
"name": "ThinkingAnalytics-Editor",
"references": [
"ThinkingAnalytics"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dbc881e260fba43c3b36c3da8364a4b1
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,140 @@
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
namespace ThinkingData.Analytics.Editors
{
[CustomEditor(typeof(TDAnalytics))]
[CanEditMultipleObjects]
public class TD_Inspectors : Editor
{
private ReorderableList _stringArray;
public void OnEnable()
{
var appId = this.serializedObject.FindProperty("configs");
_stringArray = new ReorderableList(appId.serializedObject, appId, true, true, true, true)
{
drawHeaderCallback = DrawListHeader,
drawElementCallback = DrawListElement,
onRemoveCallback = RemoveListElement,
onAddCallback = AddListElement
};
_stringArray.elementHeight = 5 * (EditorGUIUtility.singleLineHeight + 10);
_stringArray.serializedProperty.isExpanded = true;
}
void DrawListHeader(Rect rect)
{
var arect = rect;
arect.height = EditorGUIUtility.singleLineHeight + 10;
arect.x += 14;
arect.width = 80;
GUIStyle style = new GUIStyle();
style.fontStyle = FontStyle.Bold;
GUI.Label(arect, "Instance Configurations", style);
}
void DrawListElement(Rect rect, int index, bool isActive, bool isFocused)
{
var spacing = 5;
var xSpacing = 85;
var arect = rect;
SerializedProperty item = _stringArray.serializedProperty.GetArrayElementAtIndex(index);
var serElem = this._stringArray.serializedProperty.GetArrayElementAtIndex(index);
arect.height = EditorGUIUtility.singleLineHeight;
arect.width = 240;
if (index == 0)
{
EditorGUI.PropertyField(arect, item, new GUIContent((index + 1) + " (default)"));
}
else
{
EditorGUI.PropertyField(arect, item, new GUIContent("" + (index + 1)));
}
arect.y += EditorGUIUtility.singleLineHeight + spacing;
GUIStyle style = new GUIStyle();
style.fontStyle = FontStyle.Bold;
EditorGUI.LabelField(arect, "APP ID:", style);
arect.x += xSpacing;
EditorGUI.PropertyField(arect, serElem.FindPropertyRelative("appId"), GUIContent.none);
arect.y += EditorGUIUtility.singleLineHeight + spacing;
arect.x -= xSpacing;
EditorGUI.LabelField(arect, "SERVER URL:", style);
arect.x += xSpacing;
EditorGUI.PropertyField(new Rect(arect.x, arect.y, arect.width, arect.height), serElem.FindPropertyRelative("serverUrl"), GUIContent.none);
arect.y += EditorGUIUtility.singleLineHeight + spacing;
arect.x -= xSpacing;
EditorGUI.LabelField(arect, "MODE:", style);
arect.x += xSpacing;
EditorGUI.PropertyField(arect, serElem.FindPropertyRelative("mode"), GUIContent.none);
arect.y += EditorGUIUtility.singleLineHeight + spacing;
arect.x -= xSpacing;
EditorGUI.LabelField(arect, "TimeZone:", style);
arect.x += xSpacing;
var a = serElem.FindPropertyRelative("timeZone");
if (a.intValue == 100)
{
EditorGUI.PropertyField(new Rect(arect.x, arect.y, 115, arect.height), a, GUIContent.none);
arect.x += 125;
EditorGUI.PropertyField(new Rect(arect.x, arect.y, 115, arect.height), serElem.FindPropertyRelative("timeZoneId"), GUIContent.none);
}
else
{
EditorGUI.PropertyField(arect, a, GUIContent.none);
}
}
void AddListElement(ReorderableList list)
{
if (list.serializedProperty != null)
{
list.serializedProperty.arraySize++;
list.index = list.serializedProperty.arraySize - 1;
SerializedProperty item = list.serializedProperty.GetArrayElementAtIndex(list.index);
item.FindPropertyRelative("appId").stringValue = "";
}
else
{
ReorderableList.defaultBehaviours.DoAddButton(list);
}
}
void RemoveListElement(ReorderableList list)
{
if (EditorUtility.DisplayDialog("Warnning", "Do you want to remove this element?", "Remove", "Cancel"))
{
ReorderableList.defaultBehaviours.DoRemoveButton(list);
}
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
this.serializedObject.Update();
var property = _stringArray.serializedProperty;
property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, property.displayName);
if (property.isExpanded)
{
_stringArray.DoLayoutList();
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9e175a5169e2c4de78d15b28f2ce6520
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,104 @@
#if UNITY_EDITOR && UNITY_IOS
using System.IO;
using ThinkingData.Analytics.Utils;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;
namespace ThinkingData.Analytics.Editors
{
public class TD_PostProcessBuild
{
//Xcode Build Settings
//[PostProcessBuild]
[PostProcessBuildAttribute(88)]
public static void OnPostProcessBuild(BuildTarget target, string targetPath)
{
if (target != BuildTarget.iOS)
{
Debug.LogWarning("[ThinkingData] Warning: Target is not iOS. XCodePostProcess will not run");
return;
}
string projPath = Path.GetFullPath(targetPath) + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject proj = new PBXProject();
proj.ReadFromFile(projPath);
#if UNITY_2019_3_OR_NEWER
string targetGuid = proj.GetUnityFrameworkTargetGuid();
#else
string targetGuid = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
#endif
//Build Property
proj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");//BitCode NO
proj.SetBuildProperty(targetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");//Enable Objective-C Exceptions
proj.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-ObjC");
string[] headerSearchPathsToAdd = { "$(SRCROOT)/Libraries/Plugins/iOS/ThinkingSDK/Source/main", "$(SRCROOT)/Libraries/Plugins/iOS/ThinkingSDK/Source/common" };
proj.UpdateBuildProperty(targetGuid, "HEADER_SEARCH_PATHS", headerSearchPathsToAdd, null);// Header Search Paths
//Add Frameworks
proj.AddFrameworkToProject(targetGuid, "WebKit.framework", true);
proj.AddFrameworkToProject(targetGuid, "CoreTelephony.framework", true);
proj.AddFrameworkToProject(targetGuid, "SystemConfiguration.framework", true);
proj.AddFrameworkToProject(targetGuid, "Security.framework", true);
proj.AddFrameworkToProject(targetGuid, "UserNotifications.framework", true);
//Add Lib
proj.AddFileToBuild(targetGuid, proj.AddFile("usr/lib/libsqlite3.tbd", "libsqlite3.tbd", PBXSourceTree.Sdk));
proj.AddFileToBuild(targetGuid, proj.AddFile("usr/lib/libz.tbd", "libz.tbd", PBXSourceTree.Sdk));
proj.WriteToFile(projPath);
//Info.plist
//Disable preset properties
string plistPath = Path.Combine(targetPath, "Info.plist");
PlistDocument plist = new PlistDocument();
plist.ReadFromFile(plistPath);
plist.root.CreateArray("TDDisPresetProperties");
TDPublicConfig.GetPublicConfig();
foreach (string item in TDPublicConfig.DisPresetProperties)
{
plist.root["TDDisPresetProperties"].AsArray().AddString(item);
}
plist.WriteToFile(plistPath);
}
}
}
#endif
#if UNITY_EDITOR && UNITY_ANDROID && UNITY_2019_1_OR_NEWER
using UnityEditor;
using UnityEditor.Android;
using UnityEngine;
using System.IO;
using System.Xml;
using System.Collections.Generic;
namespace ThinkingData.Analytics.Editors
{
class TD_PostProcessBuild : IPostGenerateGradleAndroidProject
{
// Copy configuration file ta_public_config.xml
public int callbackOrder { get { return 0; } }
public void OnPostGenerateGradleAndroidProject(string path)
{
// Copy configuration file ta_public_config.xml
string desPath = path + "/../launcher/src/main/res/values/ta_public_config.xml";
if (File.Exists(desPath))
{
File.Delete(desPath);
}
TextAsset textAsset = Resources.Load<TextAsset>("ta_public_config");
if (textAsset != null && textAsset.bytes != null)
{
File.WriteAllBytes(desPath, textAsset.bytes);
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 75476b67117c64ab1a25a2b94db96dcb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: