Пример #1
0
        protected virtual void LoadContents()
        {
            buildConfig = BuildConfig.Instance;

            if (isloaded || buildConfig == null)
            {
                return;
            }

            isEditMode      = false;
            buildParamInfos = buildConfig.CustomBuildParams.ToList();

            var selectionName = Prefs.selectionName;

            if (!string.IsNullOrEmpty(selectionName))
            {
                selectionBuildParam = buildParamInfos.FirstOrDefault(x => x.ToString() == selectionName);
            }

            isloaded = true;
        }
Пример #2
0
        private void DrawCustomParameterSelect()
        {
            if (isEditMode)
            {
                // ビルドターゲット.
                selectionBuildParam.buildGroup  = (BuildTargetGroup)EditorGUILayout.EnumPopup("BuildTargetGroup", selectionBuildParam.buildGroup);
                selectionBuildParam.buildTarget = (BuildTarget)EditorGUILayout.EnumPopup("BuildTarget", selectionBuildParam.buildTarget);

                GUILayout.Space(2f);

                // 名前.
                using (new GUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("BuildName", GUILayout.Width(148f));
                    selectionBuildParam.name = EditorGUILayout.TextField(selectionBuildParam.name);
                }

                GUILayout.Space(2f);

                // パラメータ定義ファイル.
                selectionBuildParam.buildParam = EditorGUILayout.ObjectField(selectionBuildParam.buildParam, typeof(BuildParam), false) as BuildParam;

                GUILayout.Space(2f);

                using (new EditorGUILayout.HorizontalScope())
                {
                    var disable = string.IsNullOrEmpty(selectionBuildParam.name) || selectionBuildParam.buildParam == null;

                    EditorGUI.BeginDisabledGroup(disable);
                    {
                        if (GUILayout.Button("Add"))
                        {
                            if (buildParamInfos.All(x => x.ToString() != selectionBuildParam.ToString()))
                            {
                                buildParamInfos.Add(selectionBuildParam);
                                buildConfig.CustomBuildParams = buildParamInfos.ToArray();

                                UnityEditorUtility.SaveAsset(buildConfig);

                                isEditMode = false;
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("Error", "It is already the name registered.", "Confirm");
                            }
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    GUILayout.Space(2f);

                    if (GUILayout.Button("Cancel"))
                    {
                        isEditMode          = false;
                        selectionBuildParam = null;
                    }
                }
            }
            else
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    var index = 0;

                    if (selectionBuildParam != null)
                    {
                        index = buildParamInfos.IndexOf(x => x.ToString() == selectionBuildParam.ToString());
                    }

                    var labels = buildParamInfos
                                 .Select(x => x.ToString())
                                 .ToArray();

                    EditorGUI.BeginChangeCheck();

                    index = EditorGUILayout.Popup(index, labels, GUILayout.Width(300f));

                    if (EditorGUI.EndChangeCheck())
                    {
                        if (index != -1)
                        {
                            selectionBuildParam = buildParamInfos[index];
                            Prefs.selectionName = selectionBuildParam.ToString();
                        }
                        else
                        {
                            Prefs.selectionName = null;
                        }
                    }

                    if (GUILayout.Button("", new GUIStyle("OL Plus"), GUILayout.Width(18f)))
                    {
                        isEditMode          = true;
                        selectionBuildParam = new BuildParamInfo();
                    }

                    if (GUILayout.Button("", new GUIStyle("OL Minus"), GUILayout.Width(18f)))
                    {
                        buildParamInfos.Remove(selectionBuildParam);
                        buildConfig.CustomBuildParams = buildParamInfos.ToArray();

                        UnityEditorUtility.SaveAsset(buildConfig);

                        selectionBuildParam = null;
                    }
                }
            }
        }