コード例 #1
0
        public void Draw()
        {
            if (winbtnWinCloseIconContent == null)
            {
                winbtnWinCloseIconContent = EditorGUIUtility.IconContent("winbtn_win_close");
            }

            IsOpen = EditorLayoutTools.Header(displayManageAssetPath, IsOpen);

            if (IsOpen)
            {
                using (new ContentsScope())
                {
                    using (new DisableScope(!IsEdit))
                    {
                        var layoutWidth = 350f;

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            GUILayout.Space(5f);

                            using (new EditorGUILayout.VerticalScope())
                            {
                                GUILayout.Space(5f);

                                // このフィールドは編集不可.
                                EditorGUI.BeginDisabledGroup(true);
                                {
                                    EditorGUILayout.ObjectField(string.Empty, manageAsset, typeof(Object), false, GUILayout.Width(350f));
                                }
                                EditorGUI.EndDisabledGroup();
                            }

                            GUILayout.FlexibleSpace();

                            if (!IsEdit)
                            {
                                // Editボタンだけ常にアクティブ化させる.
                                EditorGUI.EndDisabledGroup();
                                {
                                    if (GUILayout.Button("Edit", GUILayout.Width(60f)))
                                    {
                                        IsEdit = true;
                                    }
                                }
                                EditorGUI.BeginDisabledGroup(!IsEdit);
                            }
                            else
                            {
                                if (GUILayout.Button("Delete", GUILayout.Width(60f)))
                                {
                                    if (EditorUtility.DisplayDialog("Confirm", "Remove naming rule.", "Apply", "Cancel"))
                                    {
                                        if (onDeleteManageInfo != null)
                                        {
                                            onDeleteManageInfo.OnNext(Unit.Default);
                                        }

                                        return;
                                    }
                                }

                                // 必要なパラメータが足りない時はApplyさせない.
                                var apply = true;

                                switch (ManageInfo.assetBundleNamingRule)
                                {
                                case AssetBundleNamingRule.Specified:
                                case AssetBundleNamingRule.PrefixAndChildAssetName:
                                    if (string.IsNullOrEmpty(ManageInfo.assetBundleNameStr))
                                    {
                                        apply = false;
                                    }
                                    break;
                                }

                                using (new DisableScope(!apply))
                                {
                                    if (GUILayout.Button("Apply"))
                                    {
                                        IsEdit = false;

                                        if (onUpdateManageInfo != null)
                                        {
                                            onUpdateManageInfo.OnNext(Unit.Default);
                                        }
                                    }
                                }
                            }

                            GUILayout.Space(5f);
                        }

                        GUILayout.Space(2f);

                        var originLabelWidth = EditorLayoutTools.SetLabelWidth(80f);

                        // 共有アセットはアセットバンドルのみ対応なので常にアセットバンドル.
                        if (!isShareAsset)
                        {
                            var ignoreAssetBundle = ignoreType.HasValue && ignoreType == IgnoreType.IgnoreAssetBundle;

                            if (ignoreAssetBundle)
                            {
                                if (ManageInfo.isAssetBundle)
                                {
                                    ManageInfo.isAssetBundle = false;
                                }
                            }
                            else
                            {
                                EditorGUI.BeginChangeCheck();

                                var isAssetBundle = EditorGUILayout.Toggle("AssetBundle", ManageInfo.isAssetBundle, GUILayout.Width(100f));

                                if (EditorGUI.EndChangeCheck())
                                {
                                    ManageInfo.isAssetBundle = isAssetBundle;
                                }

                                GUILayout.Space(2f);
                            }
                        }

                        if (ManageInfo.isAssetBundle)
                        {
                            EditorGUI.BeginChangeCheck();

                            var selectRuleTable = new AssetBundleNamingRule[]
                            {
                                AssetBundleNamingRule.ManageAssetName,
                                AssetBundleNamingRule.ChildAssetName,
                                AssetBundleNamingRule.PrefixAndChildAssetName,
                                AssetBundleNamingRule.Specified,
                            };

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

                            var index = selectRuleTable.IndexOf(x => x == ManageInfo.assetBundleNamingRule);

                            index = EditorGUILayout.Popup("Type", index, labels, GUILayout.Width(layoutWidth));

                            if (EditorGUI.EndChangeCheck())
                            {
                                ManageInfo.assetBundleNamingRule = index != -1 ? selectRuleTable[index] : AssetBundleNamingRule.None;
                                ManageInfo.assetBundleNameStr    = null;
                            }

                            GUILayout.Space(2f);

                            var assetBundleNameStr = ManageInfo.assetBundleNameStr;

                            switch (ManageInfo.assetBundleNamingRule)
                            {
                            case AssetBundleNamingRule.Specified:
                                assetBundleNameStr            = EditorGUILayout.DelayedTextField("Specified", assetBundleNameStr, GUILayout.Width(layoutWidth));
                                ManageInfo.assetBundleNameStr = assetBundleNameStr != null?assetBundleNameStr.ToLower() : string.Empty;

                                break;

                            case AssetBundleNamingRule.PrefixAndChildAssetName:
                                assetBundleNameStr            = EditorGUILayout.DelayedTextField("Prefix", assetBundleNameStr, GUILayout.Width(layoutWidth));
                                ManageInfo.assetBundleNameStr = assetBundleNameStr != null?assetBundleNameStr.ToLower() : string.Empty;

                                break;
                            }
                        }

                        ManageInfo.tag = EditorGUILayout.DelayedTextField("Tag", ManageInfo.tag, GUILayout.Width(layoutWidth));

                        GUILayout.Space(2f);

                        ManageInfo.comment = EditorGUILayout.DelayedTextField("Memo", ManageInfo.comment, GUILayout.Width(layoutWidth), GUILayout.Height(38f));

                        EditorLayoutTools.SetLabelWidth(originLabelWidth);
                    }

                    EditorGUILayout.Separator();

                    switch (viewMode)
                    {
                    case ViewMode.Contents:
                    {
                        EditorLayoutTools.Title("Contents", new Color(0.7f, 0.9f, 0.7f));

                        using (new ContentsScope())
                        {
                            var scrollEnable = 30 < contentsScrollView.Contents.Length;

                            var options = scrollEnable ?
                                          new GUILayoutOption[] { GUILayout.Height(250) } :
                            new GUILayoutOption[0];

                            contentsScrollView.Draw(scrollEnable, options);
                        }
                    }
                    break;

                    case ViewMode.Detail:
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorLayoutTools.Title(contentDetailName, new Color(0.3f, 0.3f, 1f));

                            if (GUILayout.Button(winbtnWinCloseIconContent, GUILayout.Width(20f), GUILayout.Height(18f)))
                            {
                                SetContentsView();
                            }
                        }

                        using (new ContentsScope())
                        {
                            var scrollEnable = 30 < contentAssetsScrollView.Contents.Length;

                            var options = scrollEnable ?
                                          new GUILayoutOption[] { GUILayout.Height(250) } :
                            new GUILayoutOption[0];

                            contentAssetsScrollView.Draw(scrollEnable, options);
                        }
                    }
                    break;
                    }
                }
            }
        }
コード例 #2
0
        public void Draw()
        {
            IsOpen = EditorLayoutTools.DrawHeader(manageAssetPath, IsOpen);

            if (IsOpen)
            {
                using (new ContentsScope())
                {
                    EditorGUI.BeginDisabledGroup(!IsEdit);
                    {
                        var layoutWidth = 350f;

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            GUILayout.Space(5f);

                            using (new EditorGUILayout.VerticalScope())
                            {
                                GUILayout.Space(5f);

                                // このフィールドは編集不可.
                                EditorGUI.BeginDisabledGroup(true);
                                {
                                    EditorGUILayout.ObjectField(string.Empty, manageInfo.assetObject, typeof(Object), false, GUILayout.Width(350f));
                                }
                                EditorGUI.EndDisabledGroup();
                            }

                            GUILayout.FlexibleSpace();

                            if (!IsEdit)
                            {
                                // Editボタンだけ常にアクティブ化させる.
                                EditorGUI.EndDisabledGroup();
                                {
                                    if (GUILayout.Button("Edit", GUILayout.Width(60f)))
                                    {
                                        IsEdit = true;
                                    }
                                }
                                EditorGUI.BeginDisabledGroup(!IsEdit);
                            }
                            else
                            {
                                if (GUILayout.Button("Delete", GUILayout.Width(60f)))
                                {
                                    if (EditorUtility.DisplayDialog("確認", "命名規則を削除します", "続行", "中止"))
                                    {
                                        if (onDeleteManageInfo != null)
                                        {
                                            onDeleteManageInfo.OnNext(Unit.Default);
                                        }

                                        return;
                                    }
                                }

                                // 必要なパラメータが足りない時はApplyさせない.
                                var apply = true;

                                switch (manageInfo.assetBundleNameType)
                                {
                                case ManageInfo.NameType.Specified:
                                case ManageInfo.NameType.PrefixAndChildAssetName:
                                    if (string.IsNullOrEmpty(manageInfo.assetBundleNameStr))
                                    {
                                        apply = false;
                                    }
                                    break;
                                }

                                EditorGUI.BeginDisabledGroup(!apply);
                                {
                                    if (GUILayout.Button("Apply"))
                                    {
                                        IsEdit = false;

                                        if (onUpdateManageInfo != null)
                                        {
                                            onUpdateManageInfo.OnNext(Unit.Default);
                                        }
                                    }
                                }
                                EditorGUI.EndDisabledGroup();
                            }

                            GUILayout.Space(5f);
                        }

                        GUILayout.Space(2f);

                        var originLabelWidth = EditorLayoutTools.SetLabelWidth(80f);

                        if (!ignoreType.HasValue || ignoreType != IgnoreType.IgnoreAssetBundle)
                        {
                            EditorGUI.BeginChangeCheck();

                            var isAssetBundle = EditorGUILayout.Toggle("AssetBundle", manageInfo.isAssetBundle, GUILayout.Width(100f));

                            if (EditorGUI.EndChangeCheck())
                            {
                                manageInfo.isAssetBundle = isAssetBundle;
                            }
                        }

                        GUILayout.Space(2f);

                        if (manageInfo.isAssetBundle)
                        {
                            EditorGUI.BeginChangeCheck();

                            var assetBundleNameType = manageInfo.assetBundleNameType;

                            assetBundleNameType = (ManageInfo.NameType)EditorGUILayout.EnumPopup("Type", assetBundleNameType, GUILayout.Width(layoutWidth));

                            if (EditorGUI.EndChangeCheck())
                            {
                                manageInfo.assetBundleNameType = assetBundleNameType;
                                manageInfo.assetBundleNameStr  = null;
                            }

                            GUILayout.Space(2f);

                            var assetBundleNameStr = manageInfo.assetBundleNameStr;

                            switch (manageInfo.assetBundleNameType)
                            {
                            case ManageInfo.NameType.Specified:
                                assetBundleNameStr            = EditorGUILayout.DelayedTextField("Specified", assetBundleNameStr, GUILayout.Width(layoutWidth));
                                manageInfo.assetBundleNameStr = assetBundleNameStr != null?assetBundleNameStr.ToLower() : string.Empty;

                                break;

                            case ManageInfo.NameType.PrefixAndChildAssetName:
                                assetBundleNameStr            = EditorGUILayout.DelayedTextField("Prefix", assetBundleNameStr, GUILayout.Width(layoutWidth));
                                manageInfo.assetBundleNameStr = assetBundleNameStr != null?assetBundleNameStr.ToLower() : string.Empty;

                                break;
                            }
                        }

                        manageInfo.comment = EditorGUILayout.DelayedTextField("Memo", manageInfo.comment, GUILayout.Width(layoutWidth), GUILayout.Height(38f));

                        EditorLayoutTools.SetLabelWidth(originLabelWidth);
                    }
                    EditorGUI.EndDisabledGroup();

                    EditorGUILayout.Separator();

                    EditorLayoutTools.DrawLabelWithBackground("Contents", new Color(0.7f, 0.9f, 0.7f));

                    using (new ContentsScope())
                    {
                        var options = scrollEnable ?
                                      new GUILayoutOption[] { GUILayout.Height(250) } :
                        new GUILayoutOption[0];

                        contentsScrollView.Draw(scrollEnable, options);
                    }
                }
            }
        }