コード例 #1
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);
    }
コード例 #2
0
    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);
    }
コード例 #3
0
    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);
    }