feat:1、添加项目
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace DataEyeAnalytics.Editors
|
||||
{
|
||||
[CustomEditor(typeof(DataEyeAnalyticsAPI))]
|
||||
[CanEditMultipleObjects]
|
||||
public class DE_Inspectors : Editor
|
||||
{
|
||||
private ReorderableList _stringArray;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
|
||||
var appId = this.serializedObject.FindProperty("tokens");
|
||||
|
||||
_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);
|
||||
}
|
||||
|
||||
arect.y += EditorGUIUtility.singleLineHeight + spacing;
|
||||
arect.x -= xSpacing;
|
||||
|
||||
EditorGUI.LabelField(arect, "Reyun AppID", style);
|
||||
arect.x += xSpacing;
|
||||
EditorGUI.PropertyField(new Rect(arect.x, arect.y, arect.width, arect.height), serElem.FindPropertyRelative("reyunAppID"), 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4131b20258fa347c898e6e4126f5a247
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
#if UNITY_IPHONE
|
||||
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
|
||||
namespace DataEyeAnalytics.Editors
|
||||
{
|
||||
public class DE_PostProcessBuild
|
||||
{
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
|
||||
{
|
||||
if (buildTarget != BuildTarget.iOS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string projPath = PBXProject.GetPBXProjectPath(path);
|
||||
|
||||
PBXProject proj = new PBXProject();
|
||||
proj.ReadFromString(File.ReadAllText(projPath));
|
||||
|
||||
string mainTargetGuid;
|
||||
string unityFrameworkTargetGuid;
|
||||
|
||||
var unityMainTargetGuidMethod = proj.GetType().GetMethod("GetUnityMainTargetGuid");
|
||||
var unityFrameworkTargetGuidMethod = proj.GetType().GetMethod("GetUnityFrameworkTargetGuid");
|
||||
|
||||
if (unityMainTargetGuidMethod != null && unityFrameworkTargetGuidMethod != null)
|
||||
{
|
||||
mainTargetGuid = (string)unityMainTargetGuidMethod.Invoke(proj, null);
|
||||
unityFrameworkTargetGuid = (string)unityFrameworkTargetGuidMethod.Invoke(proj, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
mainTargetGuid = proj.TargetGuidByName ("Unity-iPhone");
|
||||
unityFrameworkTargetGuid = mainTargetGuid;
|
||||
}
|
||||
|
||||
proj.AddBuildProperty(unityFrameworkTargetGuid, "OTHER_LDFLAGS", "-ObjC");
|
||||
proj.AddFrameworkToProject (unityFrameworkTargetGuid, "Foundation.framework", false);
|
||||
proj.AddFrameworkToProject (unityFrameworkTargetGuid, "MobileCoreServices.framework", false);
|
||||
proj.AddFrameworkToProject (unityFrameworkTargetGuid, "WebKit.framework", false);
|
||||
proj.AddFileToBuild (unityFrameworkTargetGuid, proj.AddFile ("usr/lib/libz.tbd", "Frameworks/libz.tbd", PBXSourceTree.Sdk));
|
||||
proj.AddFileToBuild (unityFrameworkTargetGuid, proj.AddFile ("usr/lib/libsqlite3.tbd", "Frameworks/libsqlite3.tbd", PBXSourceTree.Sdk));
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if UNITY_EDITOR && UNITY_ANDROID
|
||||
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Android;
|
||||
using UnityEngine;
|
||||
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
|
||||
class DE_PostProcessBuild : IPostGenerateGradleAndroidProject
|
||||
{
|
||||
// 拷贝个性化配置文件 ta_public_config.xml
|
||||
public int callbackOrder { get { return 0; } }
|
||||
public void OnPostGenerateGradleAndroidProject(string path)
|
||||
{
|
||||
// 拷贝个性化配置文件 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
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f350415b0482442a3b0374013f3f9dbd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user