public static void Init() { #if PLATFORM_NONE sdkInterface = new SDKInterfaceBase(string.Empty); #elif PLATFORM_IOS_SDK sdkInterface = new SDKInterfaceIOS(); #elif PLATFORM_ANDROID_SDK sdkInterface = new SDKInterfaceAndroid(); #else ApplicationConst.bDynamicRes = false; sdkInterface = new SDKInterfaceBase(string.Empty); #endif }
int GetNameListIndex(string[] list, SDKInterfaceBase sdk) { if (sdk == null) { return(0); } for (int i = 0; i < list.Length; i++) { if (sdk.GetType().Name == list[i]) { return(i); } } return(0); }
SDKConfigData SerializeConfig(SDKInterfaceBase sdkInterface) { SDKConfigData result = new SDKConfigData(); if (sdkInterface != null) { result.SDKName = sdkInterface.GetType().Name; result.SDKContent = JsonUtility.ToJson(sdkInterface); } else { result.SDKName = "Null"; result.SDKContent = ""; } return(result); }
void LoadCurrentSchemeConfig(SchemeData data) { m_LoginScheme = AnalysisConfig(data.LoginScheme); m_ADScheme = AnalysisConfig(data.ADScheme); m_PayScheme = AnalysisConfig(data.PayScheme); m_LogScheme = new List <SDKInterfaceBase>(); for (int i = 0; i < data.LogScheme.Count; i++) { m_LogScheme.Add(AnalysisConfig(data.LogScheme[i])); } m_otherScheme = new List <SDKInterfaceBase>(); for (int i = 0; i < data.OtherScheme.Count; i++) { m_otherScheme.Add(AnalysisConfig(data.OtherScheme[i])); } }
void EditorSDKGUI() { if (currentSchemeData != null) { m_isFoldSDKGUI = EditorGUILayout.Foldout(m_isFoldSDKGUI, "配置插件类型和参数:"); if (m_isFoldSDKGUI) { EditorGUI.indentLevel++; m_pos = EditorGUILayout.BeginScrollView(m_pos); m_LoginScheme = SelectSDKInterfaceGUI(ref m_isFoldlogin, typeof(LoginInterface), m_LoginScheme, "登陆SDK"); m_ADScheme = SelectSDKInterfaceGUI(ref m_isFoldAd, typeof(ADInterface), m_ADScheme, "广告SDK"); m_PayScheme = SelectSDKInterfaceGUI(ref m_isFoldPay, typeof(PayInterface), m_PayScheme, "支付SDK"); EditorSDKListGUI(ref m_isFoldLog, m_logFoldList, typeof(LogInterface), m_LogScheme, "事件上报SDK"); EditorSDKListGUI(ref m_isFoldOther, m_OtherFoldList, typeof(OtherSDKInterface), m_otherScheme, "其他SDK"); EditorGUILayout.EndScrollView(); EditorGUI.indentLevel--; } } }
SDKInterfaceBase SelectSDKInterfaceGUI(ref bool isFold, Type SDKType, SDKInterfaceBase sdk, string title) { isFold = EditorGUILayout.Foldout(isFold, title + ":"); if (isFold) { EditorGUI.indentLevel++; EditorGUILayout.LabelField("接口类型:" + SDKType.Name); string[] mask = GetSDKNameList(SDKType); int currentIndex = GetNameListIndex(mask, sdk); int index = EditorGUILayout.Popup("当前SDK:", currentIndex, mask); if (sdk == null || mask[index] != sdk.GetType().Name) { Type type = Assembly.Load("Assembly-CSharp").GetType(mask[index]); if (type != null) { sdk = (SDKInterfaceBase)Activator.CreateInstance(type); } else { Debug.LogError("Load " + mask[index] + " Fail!"); } } //显示界面 EditorUtilGUI.DrawClassData(sdk); EditorGUI.indentLevel--; EditorGUILayout.Space(); } return(sdk); }