Beispiel #1
0
    static void InitAddJsonItemList()
    {
        bool   flag = false;
        string key  = "";

        for (int i = jsonData.Count - 1; i >= 0; i--)
        {
            foreach (string itemKey in jsonData[i].Keys)
            {
                flag = IsNotMainKey(itemKey);
                key  = itemKey;
            }
            if (flag)
            {
                string          value = jsonData[i][key].ToString();
                SetttingElement item  = new SetttingElement();
                item.Value = value;
                item.Key   = key;
                _addedJsonItemList.Add(item);
            }
        }
    }
Beispiel #2
0
    private void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        platForm = (Platform)EditorGUILayout.EnumPopup("Platform: ", platForm);
        AddJsonBuildSettingItem(GlobalBuild.CmdArgsKey.PLATFORM, GetPlatform(platForm));

        isDevelopment = EditorGUILayout.Toggle("isDevelopment", isDevelopment);
        AddJsonBuildSettingItem(GlobalBuild.CmdArgsKey.IS_DEVELOPMENT_BUILD, ToStringIsDevelopment(isDevelopment));

        GUILayout.BeginHorizontal();
        outPutPath = EditorGUILayout.TextField("OutPutPath", outPutPath);
        if (GUILayout.Button("…", EditorStyles.toolbar, GUILayout.Width(30)))
        {
            string temp = EditorUtility.OpenFolderPanel("Output Folder", outPutPath, string.Empty);
            if (!string.IsNullOrEmpty(temp))
            {
                outPutPath = temp;
            }
        }
        if (outPutPath != "" && outPutPath != null)
        {
            AddJsonBuildSettingItem(GlobalBuild.CmdArgsKey.OUTPUT_PATH, outPutPath);
        }
        GUILayout.EndHorizontal();

        packageName = EditorGUILayout.TextField("PackageName", packageName);
        if (packageName != "" && packageName != null)
        {
            AddJsonBuildSettingItem(GlobalBuild.CmdArgsKey.PACKAGE_NAME, packageName);
        }

        bundleVersion = EditorGUILayout.TextField("BundleVersion", bundleVersion);
        if (bundleVersion != "" && bundleVersion != null)
        {
            AddJsonBuildSettingItem(GlobalBuild.CmdArgsKey.BUNDLE_VERSION, bundleVersion);
        }


        for (int i = 0; i < _addedJsonItemList.Count; i++)
        {
            AddedGuiItem(ref _addedJsonItemList[i].Key, ref _addedJsonItemList[i].Value);
        }

        for (int i = 0; i < _addBuildItemList.Count; i++)
        {
            AddGuiItem(ref _addBuildItemList[i].Key, ref _addBuildItemList[i].Value);
        }

        if (GUILayout.Button("Add"))
        {
            SetttingElement item = new SetttingElement();
            _addBuildItemList.Add(item);
        }

        if (GUILayout.Button("Remove"))
        {
            if (_addBuildItemList.Count <= 0)
            {
                return;
            }
            if (_addBuildItemList[_addBuildItemList.Count - 1].Key != null && _addBuildItemList[_addBuildItemList.Count - 1].Key != "")
            {
                CommandLineArgs.Remove(_addBuildItemList[_addBuildItemList.Count - 1].Key);
                jsonData.Remove(jsonData[jsonData.Count - 1]);
            }
            _addBuildItemList.RemoveAt(_addBuildItemList.Count - 1);
        }

        if (GUILayout.Button("SaveJson"))
        {
            string       json = jsonData.ToJson();
            string       path = Application.dataPath + "/BuildSetting.json";
            StreamWriter sw   = new StreamWriter(path);
            sw.Write(json);
            sw.Close();
            jsonData = JsonMapper.ToObject(File.ReadAllText(path));
            Debug.Log("Save Json Succeed");
        }

        if (GUILayout.Button("BuildMain"))
        {
            Zeus.Build.BuildScript.BuildPlayer();
            Debug.Log("Build Succeed");
        }

        EditorGUILayout.EndVertical();
    }