public void OnGUI()
        {
            if (curRes.Dependencies.Count > 0)
            {
                drawDependencieAsset();
                GUILayoutHelper.DrawSeparator();
            }

            drawAllBundles();
        }
Example #2
0
    /// <summary>
    /// Integer vector field.
    /// </summary>

    static public Vector4 IntPadding(string prefix, Vector4 v)
    {
        int left   = Mathf.RoundToInt(v.x);
        int top    = Mathf.RoundToInt(v.y);
        int right  = Mathf.RoundToInt(v.z);
        int bottom = Mathf.RoundToInt(v.w);

        GUILayoutHelper.IntVector a = GUILayoutHelper.IntPair(prefix, "Left", "Top", left, top);
        GUILayoutHelper.IntVector b = GUILayoutHelper.IntPair(null, "Right", "Bottom", right, bottom);

        return(new Vector4(a.x, a.y, b.x, b.y));
    }
Example #3
0
    /// <summary>
    /// Integer rectangle field.
    /// </summary>

    static public Rect IntRect(string prefix, Rect rect)
    {
        int left   = Mathf.RoundToInt(rect.xMin);
        int top    = Mathf.RoundToInt(rect.yMin);
        int width  = Mathf.RoundToInt(rect.width);
        int height = Mathf.RoundToInt(rect.height);

        GUILayoutHelper.IntVector a = GUILayoutHelper.IntPair(prefix, "Left", "Top", left, top);
        GUILayoutHelper.IntVector b = GUILayoutHelper.IntPair(null, "Width", "Height", width, height);

        return(new Rect(a.x, a.y, b.x, b.y));
    }
        public new void DrawDefaultInspector()
        {
            NodePropertyIterator iterator = this.serializedNode.GetIterator();



            int indentLevel = EditorGUI.indentLevel;

            while (iterator.Next(iterator.current == null || (iterator.current.propertyType != NodePropertyType.Variable && !iterator.current.hideInInspector)))
            {
                SerializedNodeProperty current = iterator.current;


                if (!current.hideInInspector)
                {
                    if (current.path == "motionOverride" && mecanimNode != null && mecanimNode.animatorStateSelected != null &&
                        mecanimNode.animatorStateSelected.motion != null &&
                        mecanimNode.animatorStateSelected.motion is BlendTree)
                    {
                        continue;
                    }


                    if (current.path == "blendX" &&
                        mecanimNode != null && mecanimNode.animatorStateSelected != null &&
                        (mecanimNode.animatorStateSelected.motion == null ||
                         !(mecanimNode.animatorStateSelected.motion is BlendTree && !String.IsNullOrEmpty(((BlendTree)mecanimNode.animatorStateSelected.motion).blendParameter))
                        ))
                    {
                        continue;
                    }
                    if (current.path == "blendY" &&
                        mecanimNode != null && mecanimNode.animatorStateSelected != null &&
                        (mecanimNode.animatorStateSelected.motion == null ||
                         !(mecanimNode.animatorStateSelected.motion is BlendTree && !String.IsNullOrEmpty(((BlendTree)mecanimNode.animatorStateSelected.motion).blendParameterY))
                        ))
                    {
                        continue;
                    }

                    EditorGUI.indentLevel = indentLevel + iterator.depth;


                    GUILayoutHelper.DrawNodeProperty(new GUIContent(current.label, current.tooltip), current, mecanimNode, null, true);
                }
            }

            EditorGUI.indentLevel = indentLevel;


            this.serializedNode.ApplyModifiedProperties();
        }
Example #5
0
        private static Rect GetInnerToolbarArea()
        {
            Rect outerToolbarArea = GUILayoutUtility.GetRect(
                0f,
                DropdownStyle.SearchToolbarHeight,
                GUILayoutHelper.ExpandWidth(true));

            Rect innerToolbarArea = outerToolbarArea
                                    .AddHorizontalPadding(10f, 2f)
                                    .AlignMiddleVertically(DropdownStyle.LabelHeight);

            return(innerToolbarArea);
        }
Example #6
0
        public static void OnGUI(UnityModManager.ModEntry modEntry)
        {
            GUILayout.BeginVertical("Box");
            // GUILayoutHelper.Title("練功 <color=#A0A0A0>(修習、突破、研讀)</color>");
            GUILayoutHelper.GongFaSelection("<color=#80FF80>練功</color>時使用功法", ref settings.HomeSystemGongFaIndex);
            settings.HomeSystemAutoAccessories = GUILayout.Toggle(settings.HomeSystemAutoAccessories, "<color=#80FF80>練功</color>時自動裝備適合的飾品 (資質優先,悟性其次)");
            settings.AdvancedReadBookMode      = GUILayout.Toggle(settings.AdvancedReadBookMode, "進階研讀模式:難度超過 50% 則資質優先、悟性其次;否則悟性優先");
            GUILayout.EndVertical();

            GUILayout.BeginVertical("Box");
            // GUILayoutHelper.Title("製造 <color=#A0A0A0>(锻造、制木、炼药、炼毒、织锦、制石、烹飪)</color>");
            settings.MakeSystemAutoAccessories = GUILayout.Toggle(settings.MakeSystemAutoAccessories, "<color=#80FF80>製造</color>時自動裝備適合的飾品");
            GUILayout.EndVertical();

            GUILayout.BeginVertical("Box");
            settings.HealingAutoAccessories = GUILayout.Toggle(settings.HealingAutoAccessories, "<color=#80FF80>療傷</color>與<color=#80FF80>驅毒</color>自動裝備適合的飾品 <color=#FF8080>※如果不在城鎮/門派格,將不會使用倉庫裡的裝備※</color>");
            GUILayout.EndVertical();

            GUILayout.BeginVertical("Box");
            GUILayoutHelper.GongFaSelection("跨月恢復<color=#80FF80>內息</color>時使用功法", ref settings.RestGongFaIndex);
            settings.RestAutoEquip = GUILayout.Toggle(settings.RestAutoEquip, "跨月恢復<color=#80FF80>內息</color>時自動裝備適合的武器 (內息優先) <color=#FF8080>※如果不在城鎮/門派格,將不會使用倉庫裡的裝備※</color>");
            GUILayout.EndVertical();

            GUILayout.BeginVertical("Box");
            GUILayoutHelper.GongFaSelection("進入<color=#80FF80>戰鬥</color>準備畫面時,使用指定功法", ref settings.StartBattleGongFaIndex);
            GUILayoutHelper.EquipGroupSelection("進入<color=#80FF80>戰鬥</color>準備畫面時,使用指定裝備", ref settings.StartBattleEquipGroupIndex);
            GUILayout.Label("<color=#FF8080>※戰鬥後不會換回※</color>");
            GUILayout.EndVertical();

            GUILayout.BeginVertical("Box");
            GUILayoutHelper.EquipGroupSelection("進入<color=#80FF80>較藝</color>準備畫面時,使用指定裝備", ref settings.StartSkillBattleEquipGroupIndex);
            GUILayout.Label("<color=#FF8080>※較藝後不會換回※</color>");
            GUILayout.EndVertical();

            GUILayout.BeginVertical("Box");
            GUILayout.BeginHorizontal();
            settings.EnabledLog = GUILayout.Toggle(settings.EnabledLog, "輸出偵錯資訊,可於log內檢視切換歷程");
            if (GUILayout.Button("開啟UnityModManager.log"))
            {
                string logFilePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(modEntry.Path, @"../UnityModManager.log"));
                if (logFilePath != null && System.IO.File.Exists(logFilePath))
                {
                    var p = new System.Diagnostics.Process();
                    p.StartInfo.FileName  = "explorer.exe";
                    p.StartInfo.Arguments = $"\"{logFilePath}\"";
                    p.Start();
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
        private void DisplayGUI()
        {
            if (!streamingWorld.IsReady)
            {
                EditorGUILayout.HelpBox("Requires DaggerfallUnity singleton with Arena2 path set.", MessageType.Info);
                return;
            }

            if (!streamingWorld.LocalPlayerGPS)
            {
                EditorGUILayout.HelpBox("Requires player object with PlayerGPS component.", MessageType.Info);
                var propLocalPlayerGPS = Prop("LocalPlayerGPS");
                propLocalPlayerGPS.objectReferenceValue = EditorGUILayout.ObjectField(new GUIContent("", ""), propLocalPlayerGPS.objectReferenceValue, typeof(PlayerGPS), true);
                return;
            }

            DrawTravelMap();
            DrawDefaultInspector();

            EditorGUILayout.Space();
            var propFindLocationString = Prop("EditorFindLocationString");

            EditorGUILayout.LabelField(new GUIContent("Find Location", "Enter exact city name in format RegionName/CityName. Case-sensitive."));
            GUILayoutHelper.Horizontal(() =>
            {
                propFindLocationString.stringValue = EditorGUILayout.TextField(propFindLocationString.stringValue.Trim());
                if (GUILayout.Button("Find"))
                {
                    streamingWorld.__EditorFindLocation();
                }
            });

            EditorGUILayout.Space();
            GUILayoutHelper.Horizontal(() =>
            {
                if (GUILayout.Button("Get From PlayerGPS"))
                {
                    streamingWorld.__EditorGetFromPlayerGPS();
                    EditorUtility.SetDirty(streamingWorld.LocalPlayerGPS);
                }
                if (GUILayout.Button("Apply To PlayerGPS"))
                {
                    streamingWorld.__EditorApplyToPlayerGPS();
                    EditorUtility.SetDirty(streamingWorld.LocalPlayerGPS);
                }
            });
            //if (GUILayout.Button("Refresh Preview"))
            //{
            //    streamingWorld.__EditorRefreshPreview();
            //}
        }
Example #8
0
        private void drawAssetsAttribute(ResPropertyGUI[] propertyArr, string resType)
        {
            GUILayout.BeginHorizontal();
            foreach (ResPropertyGUI rpg in propertyArr)
            {
                if (rpg.GuiWidth > 0)
                {
                    GUILayout.Label(rpg.Title, GUILayout.MaxWidth(rpg.GuiWidth));
                }
                else
                {
                    GUILayout.Label(rpg.Title);
                }
            }
            GUILayout.EndHorizontal();

            GUILayoutHelper.DrawSeparator();

            scrollPos = GUILayout.BeginScrollView(scrollPos);
            int indexRow = 0;

            foreach (ResoucresBean res in curBundle.GetAllAssets())
            {
                if (res.ResourceType != resType || (!string.IsNullOrEmpty(searchFilter) && !res.Name.Contains(searchFilter)))
                {
                    continue;
                }


                indexRow++;
                GUI.backgroundColor = indexRow % 2 == 0 ? Color.white : new Color(0.8f, 0.8f, 0.8f);
                GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                GUI.backgroundColor = Color.white;

                if (res.RawRes == null)
                {
                    GUI.color = Color.red;
                    GUILayout.Label(res.Name);
                    GUI.color = Color.white;
                }
                else
                {
                    res.RawRes.SetPropertyGUI(propertyArr);
                    res.RawRes.OnGUI();
                }

                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
        }
Example #9
0
        public void OnGUI()
        {
            GUI.color = Color.yellow;
            GUILayout.Label(tipStr);
            GUI.color = Color.white;

            drawTitle();

            GUILayoutHelper.DrawHeader("详情");

            if (lastTabIndex != curTabIndex)
            {
                lastTabIndex = curTabIndex;
                searchFilter = "";
                GUIUtility.keyboardControl = 0;
            }
            //Search
            GUILayout.BeginHorizontal();
            {
                searchFilter = EditorGUILayout.TextField("", searchFilter, "SearchTextField", GUILayout.Width(Screen.width - 20f));

                if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f)))
                {
                    searchFilter = "";
                    GUIUtility.keyboardControl = 0;
                }
            }
            GUILayout.EndHorizontal();

            if (curTabIndex == 0)
            {
                drawAllAssets();
            }
            else if (curTabIndex == 1)
            {
                drawTextureAssets();
            }
            else if (curTabIndex == 2)
            {
                drawMaterialAssets();
            }
            else if (curTabIndex == 3)
            {
                drawMeshAssets();
            }
            else if (curTabIndex == 4)
            {
                drawShaderAssets();
            }
        }
        private void drawDependencieAsset()
        {
            GUILayoutHelper.DrawHeader("Dependencies");

            int column      = 3;
            int columnWidth = Mathf.Max(1, (int)(ABMainChecker.MainChecker.Width - 30) / column);

            GUILayout.BeginVertical();
            int    endIndex   = 0;
            string missingStr = "{0}(missing)";
            int    i          = 0;

            foreach (ResoucresBean depRes in curRes.Dependencies.Values)
            {
                if (i % column == 0)
                {
                    endIndex = i + column - 1;
                    GUILayout.BeginHorizontal();
                }

                if (depRes.IsMissing)
                {
                    GUI.backgroundColor = Color.red;
                    GUILayout.Button(string.Format(missingStr, depRes.Name), GUILayout.Width(columnWidth));
                    GUI.backgroundColor = Color.white;
                }
                else
                {
                    if (GUILayout.Button(depRes.Name, GUILayout.Width(columnWidth)))
                    {
                        ABMainChecker.MainChecker.AssetView.SetResoucre(depRes);
                    }
                }

                GUILayout.Space(5);

                if (i == endIndex)
                {
                    endIndex = 0;
                    GUILayout.EndHorizontal();
                }
                i++;
            }
            if (endIndex != 0)
            {
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Example #11
0
        public void OnGUI()
        {
            GUILayoutHelper.DrawHeader("检测AssetBundle");
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Asset Bundles", "DropDown", GUILayout.Width(120)))
            {
                string path = EditorUtility.OpenFolderPanel("Select", CurFolderRoot, "");
                CurFolderRoot = path;
                curFolder     = path;
            }

            if (curFolder.StartsWith(Application.dataPath))
            {
                curFolder = curFolder.Replace(Application.dataPath, "Assets");
            }
            GUILayout.TextField(curFolder);

            GUILayout.Space(10);
            GUILayout.EndHorizontal();

            GUI.backgroundColor = Color.green;
            if (GUILayout.Button("Go Check", GUILayout.Height(25)))
            {
                bundleArr = null;
                this.FindAllBundles();
            }
            GUI.backgroundColor = Color.white;

            //Overview
            GUILayoutHelper.DrawSeparator();
            drawOverview();

            switch (curView)
            {
            case EView.ALLAsset:
                drawAllAssetBundle();
                break;

            case EView.RedundancyAssets:
                drawAllRedundancyAsset();
                break;

            case EView.MissingAsset:
                drawMissingAsset();
                break;
            }
        }
Example #12
0
        /// <summary>
        /// 冗余的资源
        /// </summary>
        private void drawAllRedundancyAsset()
        {
            //all assets
            GUILayoutHelper.DrawHeader("All Redundancy AssetBundle");


            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle(false, "AssetBundle 名称", "ButtonLeft", GUILayout.MinWidth(300)))
            {
                sortToggle *= -1;
                redundancyList.Sort((x, y) => (new CaseInsensitiveComparer()).Compare(x.BundleName, y.BundleName) * sortToggle);
            }
            if (GUILayout.Toggle(false, "Mesh", "ButtonMid", GUILayout.MinWidth(100)))
            {
                sortToggle *= -1;
                redundancyList.Sort((x, y) => comparerAssetCount(x, y, EResoucresTypes.MeshType));
            }
            if (GUILayout.Toggle(false, "Material", "ButtonMid", GUILayout.MinWidth(100)))
            {
                sortToggle *= -1;
                redundancyList.Sort((x, y) => comparerAssetCount(x, y, EResoucresTypes.MatrialType));
            }
            if (GUILayout.Toggle(false, "Texture", "ButtonMid", GUILayout.MinWidth(100)))
            {
                sortToggle *= -1;
                redundancyList.Sort((x, y) => comparerAssetCount(x, y, EResoucresTypes.TextureType));
            }
            if (GUILayout.Toggle(false, "Shader", "ButtonMid", GUILayout.MinWidth(100)))
            {
                sortToggle *= -1;
                redundancyList.Sort((x, y) => comparerAssetCount(x, y, EResoucresTypes.ShaderType));
            }
            GUILayout.Toggle(false, "详细", "ButtonRight", GUILayout.Width(100));
            GUILayout.EndHorizontal();

            scrollPos = GUILayout.BeginScrollView(scrollPos);
            indexRow  = 0;

            foreach (EditorBundleBean bundle in redundancyList)
            {
                if (string.IsNullOrEmpty(searchFilter) || bundle.BundleName.Contains(searchFilter))
                {
                    drawRowRedundancyAsset(bundle);
                }
            }
            GUILayout.EndScrollView();
        }
Example #13
0
        private void drawMissingAsset()
        {
            //all assets
            GUILayoutHelper.DrawHeader("All Missing AssetBundle");

            List <ResoucresBean> missingResList = ABMainChecker.MainChecker.MissingRes;

            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle(false, "Asset 名称", "ButtonLeft", GUILayout.Width(200)))
            {
                missingResList.Sort((x, y) => (new CaseInsensitiveComparer()).Compare(x.Name, y.Name));
            }
            if (GUILayout.Toggle(false, "类型", "ButtonMid", GUILayout.Width(100)))
            {
                missingResList.Sort((x, y) => (new CaseInsensitiveComparer()).Compare(x.ResourceType, y.ResourceType));
            }
            GUILayout.Toggle(false, "路径", "ButtonRight");
            GUILayout.EndHorizontal();

            scrollPos = GUILayout.BeginScrollView(scrollPos);
            indexRow  = 0;

            foreach (ResoucresBean res in missingResList)
            {
                indexRow++;
                GUI.backgroundColor = indexRow % 2 == 0 ? Color.white : new Color(0.8f, 0.8f, 0.8f);
                GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                GUI.backgroundColor = Color.white;

                bool isCheck = false;
                //名称
                GUI.color = selectAsset == res.Name ? Color.green : Color.white;
                isCheck   = GUILayout.Button(res.Name, EditorStyles.label, GUILayout.Width(200));
                //type
                GUILayout.Label(res.ResourceType, GUILayout.Width(100));
                //Path
                isCheck   = (GUILayout.Button(res.AssetPath, EditorStyles.label) ? true : isCheck);
                GUI.color = Color.white;
                if (isCheck)
                {
                    selectAsset            = res.Name;
                    Selection.activeObject = AssetDatabase.LoadAssetAtPath <Object>(res.AssetPath);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
        }
Example #14
0
        private void onAddRuleGUI()
        {
            AssetImporterWindow aiw = AssetImporterWindow.Instance;

            string[] rules = aiw.GetRuleKeys <T>();

            defaultRuleIndex = EditorGUILayout.Popup("Rules", defaultRuleIndex, rules);

            if (defaultRuleIndex != 0)
            {
                curRule = aiw.GetRule <T>(rules[defaultRuleIndex]);
                GUILayoutHelper.DrawSeparator();

                EditorGUILayout.BeginVertical("Box");
                this.OnRuleGUI(curRule);
                EditorGUILayout.EndVertical();

                GUILayout.FlexibleSpace();
                GUILayoutHelper.DrawSeparator();

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(ImportPreferences.BtnApply, GUILayout.MaxWidth(80)))
                {
                    ruleTabs.Add(curRule.RuleKey);
                    curRuleTab           = curRule.RuleKey;
                    keyRules[curRuleTab] = curRule;

                    string   relativePath = this.curSelectFolder.RelativePath;
                    string[] sfr          = new string[curRule.Folders.Length + 1];
                    Array.Copy(curRule.Folders, sfr, curRule.Folders.Length);
                    sfr[sfr.Length - 1] = relativePath;
                    curRule.Folders     = sfr;

                    AssetImporterWindow.Instance.AddFolderRule(relativePath, curRule);

                    ApplyFolder(curRule, relativePath);

                    EditorUtility.SetDirty(curRule);
                }
                EditorGUILayout.EndHorizontal();
            }
        }
        private void Keys_DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused)
        {
            int line = 0;

            Section section = data.Sections[currentSection];
            Key     key     = section[index];

            if (!sectionExpanded[currentSection])
            {
                EditorGUI.LabelField(LineRect(rect), ModSettingsData.FormattedName(key.Name));
                SetKeySize(currentSection, index, lineHeight);
                return;
            }

            if (IsPreset)
            {
                using (new EditorGUI.DisabledScope(!CurrentPreset[section.Name]))
                {
                    CurrentPreset[section.Name, key.Name] = EditorGUI.ToggleLeft(LineRect(rect, line++), key.Name, CurrentPreset[section.Name, key.Name]);
                    EditorGUI.LabelField(LineRect(rect, line++), key.Description);
                }
            }
            else
            {
                key.Name        = EditorGUI.TextField(LineRect(rect, line++), "Name", key.Name);
                key.Description = EditorGUI.TextField(LineRect(rect, line++), "Description", key.Description);
            }

            using (new EditorGUI.DisabledScope(IsPreset))
                data.SetType(currentSection, index, ref key, (KeyType)EditorGUI.EnumPopup(LineRect(rect, line++), "UI Control", key.KeyType));

            using (new EditorGUI.DisabledScope(IsPreset && !CurrentPreset[section.Name]))
            {
                rect.y += lineHeight * 3;
                int lines = key.OnEditorWindow(
                    rect,
                    (subrect, label, rects) => GUILayoutHelper.Horizontal(subrect, label, rects),
                    (subrect, linesPerItem, rects) => GUILayoutHelper.Vertical(subrect, linesPerItem, rects),
                    cache);

                SetKeySize(currentSection, index, (lines + 4) * lineHeight);
            }
        }
Example #16
0
        public virtual void OnGUI()
        {
            EditorGUILayout.BeginHorizontal();

            Rect windowRect = AssetImporterWindow.Instance.position;

            EditorGUILayout.BeginVertical(GUILayout.Width(windowRect.width * 0.5f), GUILayout.ExpandHeight(true));
            GUILayoutHelper.DrawHeader(typeof(T).Name);
            //            dirScrollPos = GUILayout.BeginScrollView(dirScrollPos);
            //            this.OnFolderGUI();
            //            GUILayout.EndScrollView();
            this.folderTree.OnGUI(multiColumnTreeViewRect(ref windowRect));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical();
            onParamsGUI();
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();
        }
        private void Sections_DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused)
        {
            Section section = data.Sections[currentSection = index];

            if (sectionsExpanded)
            {
                keys[index].DoList(rect);
            }
            else if (IsPreset)
            {
                CurrentPreset[section.Name] = EditorGUI.ToggleLeft(LineRect(rect), section.Name, CurrentPreset[section.Name]);
            }
            else
            {
                GUILayoutHelper.Vertical(rect, 1,
                                         (line) => GUILayoutHelper.Horizontal(line, null,
                                                                              (r) => section.Name       = EditorGUI.TextField(r, "Name", section.Name),
                                                                              (r) => section.IsAdvanced = EditorGUI.ToggleLeft(r, "Is Advanced or experimental", section.IsAdvanced)),
                                         (line) => section.Description = EditorGUI.TextField(line, "Description", section.Description));
            }
        }
Example #18
0
        private void OnGUI()
        {
            GUILayoutHelper.DrawHeader("Import");

            this.importFoldersGUI();

            GUILayoutHelper.DrawHeader("Option");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("翻译:", GUILayout.Width(80));

            targetLanguage = (Language)EditorGUILayout.EnumPopup("", targetLanguage);

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Export")) //, GUILayout.Width(80)
            {
                this.exportSourcesLanguage();
            }

            if (GUILayout.Button("Export + Online")) //, GUILayout.Width(80)
            {
                this.exportSourcesAndOnlineLanguage();
            }
            //            GUILayoutHelper.DrawHeader("Translater");

            EditorGUILayout.EndHorizontal();

            GUI.backgroundColor = Color.green;
            if (GUILayout.Button("Translater", GUILayout.Height(30)))
            {
                this.onTranlateAssets();
            }
            GUI.backgroundColor = Color.white;
            GUILayout.Space(10);
        }
Example #19
0
        private void OnGUI()
        {
            switch (curView)
            {
            case EView.OverView:
                overview.OnGUI();
                break;

            default:
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("< Back", GUILayout.Width(100), GUILayout.Height(30)))
                {
                    curView = EView.OverView;
                }

                GUILayout.Label(subPageTitle, titleLabStyle);
                GUILayout.Space(100);
                GUILayout.EndHorizontal();

                GUILayout.Space(10);
                GUILayoutHelper.DrawSeparator();
                break;
            }

            switch (curView)
            {
            case EView.BundleDetailView:
                bundleDetailView.OnGUI();
                break;

            case EView.AssetDistributeView:
                assetView.OnGUI();
                break;
            }
            GUILayout.Space(10);
        }
Example #20
0
        private void drawShaderAssets()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Shader名称", GUILayout.Width(200));
            GUILayout.Label("AB数量", GUILayout.Width(80));
            GUILayout.Label("所属AssetBundle");
            GUILayout.Label("详情", GUILayout.Width(100));
            GUILayout.EndHorizontal();

            GUILayoutHelper.DrawSeparator();

            scrollPos = GUILayout.BeginScrollView(scrollPos);
            List <ResoucresBean> resList = curBundle.GetAllAssets(EResoucresTypes.ShaderType);
            int index = 0;

            foreach (ResoucresBean res in resList)
            {
                if (string.IsNullOrEmpty(searchFilter) || res.Name.Contains(searchFilter))
                {
                    drawShaderRowAsset(res, index++);
                }
            }
            GUILayout.EndScrollView();
        }
Example #21
0
        private void drawSetting(ParticleEffectSettingBean modelSetting)
        {
            GUILayout.BeginVertical();
            {
                bool isFoldOut = true;
                GUILayout.BeginHorizontal();
                if (isFolderOut.ContainsKey(modelSetting))
                {
                    isFoldOut = isFolderOut[modelSetting];
                }
                isFolderOut[modelSetting] = EditorGUILayout.Foldout(isFoldOut, modelSetting.AssetDesc);

                GUILayout.FlexibleSpace();
                if (GUILayout.Button("X", GUILayout.Width(30)))
                {
                    removeSettings.Add(modelSetting);
                }
                GUILayout.EndHorizontal();

                if (isFoldOut)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(30);
                    GUILayout.Label("文件类型描述", GUILayout.Width(100F));
                    modelSetting.AssetDesc = GUILayout.TextField(modelSetting.AssetDesc);
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(30);
                        if (GUILayout.Button("文件目录", GUILayout.Width(100F)))
                        {
                            modelSetting.Folder.Add(string.Empty);
                        }

                        GUILayout.BeginVertical();
                        for (int i = modelSetting.Folder.Count - 1; i >= 0; i--)
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.TextField(modelSetting.Folder[i]);
                            if (GUILayout.Button("...", GUILayout.Width(30f)))
                            {
                                string path = EditorUtility.OpenFolderPanel("选择文件夹", Application.dataPath, "");
                                modelSetting.Folder[i] = path.Replace(Application.dataPath, "Assets");
                            }
                            if (GUILayout.Button("X", GUILayout.Width(30f)))
                            {
                                modelSetting.Folder.RemoveAt(i);
                            }
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(30);
                    GUILayoutHelper.SetLabelWidth(120F);
                    modelSetting.MaxMatrials = EditorGUILayout.IntSlider(new GUIContent("最大材质数"), modelSetting.MaxMatrials,
                                                                         0, MaxMatrials);
                    GUILayout.FlexibleSpace();
                    modelSetting.MaxParticels = EditorGUILayout.IntSlider(new GUIContent("最大粒子数"), modelSetting.MaxParticels,
                                                                          0, MaxParticles);
                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.EndVertical();
        }
        private void OnGUI()
        {
            lineHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            GUILayoutHelper.Vertical(() =>
            {
                GUILayoutHelper.Area(new Rect(0, 0, 3 * position.width / 8, position.height), () =>
                {
                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        GUILayout.Box((Texture2D)EditorGUIUtility.Load("Assets/Resources/AppIcon1.png"), GUILayout.Width(50), GUILayout.Height(50));
                        var titleStyle      = new GUIStyle(EditorStyles.largeLabel);
                        titleStyle.font     = EditorGUIUtility.Load("Assets/Resources/Fonts/TESFonts/Kingthings Petrock.ttf") as Font;
                        titleStyle.fontSize = 50;
                        GUILayout.Label(modName, titleStyle);
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        GUILayout.Label(localPath);

                        if (IconButton("d_editicon.sml", "Select target path"))
                        {
                            if (!string.IsNullOrEmpty(targetPath = EditorUtility.OpenFolderPanel("Select mod folder", rootPath, "Mod")))
                            {
                                Load();
                            }
                        }
                        if (IconButton("d_Refresh", "Reload and discharge unsaved changes"))
                        {
                            Load();
                        }
                        using (new EditorGUI.DisabledScope(modName == "None" || duplicateSections || duplicateKeys))
                            if (IconButton("d_P4_CheckOutLocal", "Save settings to disk"))
                            {
                                Save();
                            }
                    });

                    saveOnExit = EditorGUILayout.ToggleLeft(new GUIContent("Save on Exit", "Save automatically when window is closed."), saveOnExit);

                    if (data == null)
                    {
                        EditorGUILayout.HelpBox("Select a folder to store settings.", MessageType.Info);
                        return;
                    }

                    if (duplicateSections)
                    {
                        EditorGUILayout.HelpBox("Multiple sections with the same name detected!", MessageType.Error);
                    }
                    if (duplicateKeys)
                    {
                        EditorGUILayout.HelpBox("Multiple keys with the same name in a section detected!", MessageType.Error);
                    }

                    DrawHeader("Header");
                    EditorGUILayout.HelpBox("Version of settings checked against local values and presets.", MessageType.None);
                    data.Version = EditorGUILayout.TextField("Version", data.Version);

                    DrawHeader("Presets");
                    EditorGUILayout.HelpBox("Pre-defined values for all or a set of settings. Author is an optional field.", MessageType.None);
                    presetsScrollPosition = GUILayoutHelper.ScrollView(presetsScrollPosition, () => presets.DoLayoutList());
                    EditorGUILayout.Space();
                    if (presets.index != -1)
                    {
                        var preset    = data.Presets[presets.index];
                        preset.Author = EditorGUILayout.TextField("Author", preset.Author);
                        EditorGUILayout.PrefixLabel("Description");
                        preset.Description = EditorGUILayout.TextArea(preset.Description);
                    }

                    GUILayout.FlexibleSpace();

                    DrawHeader("Tools");
                    if (GUILayout.Button("Import Legacy INI"))
                    {
                        string iniPath;
                        if (!string.IsNullOrEmpty(iniPath = EditorUtility.OpenFilePanel("Select ini file", rootPath, "ini")))
                        {
                            data.ImportLegacyIni(new IniParser.FileIniDataParser().ReadFile(iniPath));
                        }
                    }
                    else if (GUILayout.Button("Merge presets"))
                    {
                        string path;
                        if (!string.IsNullOrEmpty(path = EditorUtility.OpenFilePanel("Select preset file", rootPath, "json")))
                        {
                            data.LoadPresets(path, true);
                        }
                    }
                    else if (GUILayout.Button("Export localization table"))
                    {
                        string path;
                        if (!string.IsNullOrEmpty(path = EditorUtility.OpenFolderPanel("Select a folder", textPath, "")))
                        {
                            MakeTextDatabase(Path.Combine(path, string.Format("mod_{0}.txt", modName)));
                        }
                    }

                    EditorGUILayout.Space();
                });

                if (data == null)
                {
                    return;
                }

                float areaWidth = 5 * position.width / 8;
                GUILayoutHelper.Area(new Rect(position.width - areaWidth, 0, areaWidth, position.height), () =>
                {
                    EditorGUILayout.Space();

                    if (data.Presets.Count > 0 && presets.index != -1)
                    {
                        if (GUILayout.SelectionGrid(IsPreset ? 1 : 0, new string[] { "Defaults", data.Presets[presets.index].Title }, 2) == 0)
                        {
                            if (IsPreset)
                            {
                                LoadPreset(-1);
                            }
                        }
                        else
                        {
                            if (currentPreset != presets.index)
                            {
                                LoadPreset(presets.index);
                            }
                        }
                    }

                    mainScrollPosition = GUILayoutHelper.ScrollView(mainScrollPosition, () =>
                    {
                        sections.DoLayoutList();

                        duplicateSections = duplicateKeys = false;
                        var sectionNames  = new List <string>();
                        foreach (var section in data.Sections)
                        {
                            section.Name = !string.IsNullOrEmpty(section.Name) ? section.Name.Replace(" ", string.Empty) : GetUniqueName(sectionNames, "Section");
                            sectionNames.Add(section.Name);

                            var keyNames = new List <string>();
                            foreach (var key in section.Keys)
                            {
                                key.Name = !string.IsNullOrEmpty(key.Name) ? key.Name.Replace(" ", string.Empty) : GetUniqueName(keyNames, "Key");
                                keyNames.Add(key.Name);
                            }

                            duplicateKeys |= DuplicatesDetected(keyNames);
                            this.keyNames.Add(keyNames);
                        }
                        this.sectionNames  = sectionNames;
                        duplicateSections |= DuplicatesDetected(sectionNames);
                    });

                    GUILayout.FlexibleSpace();
                    EditorGUILayout.Space();
                });
            });
        }
Example #23
0
        void OnGUI()
        {
            EditorGUI.indentLevel++;

            GUILayoutHelper.Horizontal(() =>
            {
                if (GUILayout.Button("Create New Mod"))
                {
                    modInfo      = new ModInfo();
                    modInfo.GUID = System.Guid.NewGuid().ToString();
                    fileOpen     = SaveModFile();
                    if (modInfo != null)
                    {
                        modInfo.DFUnity_Version = VersionInfo.DaggerfallUnityVersion;
                    }
                }

                else if (GUILayout.Button("Open Existing Mod Settings File"))
                {
                    try
                    {
                        currentFilePath = EditorUtility.OpenFilePanelWithFilters("", ModManager.EditorModsDirectory, new string[] { "JSON", "dfmod.json" });

                        if (!File.Exists(currentFilePath))
                        {
                            Debug.Log("Invalid file selection");
                            currentFilePath = null;
                            fileOpen        = false;
                            return;
                        }

                        modInfo = ReadModInfoFile(currentFilePath);
                        Debug.Log(string.Format("opened mod file for: {0}", modInfo.ModTitle));
                    }
                    catch (Exception ex)
                    {
                        Debug.Log(string.Format("Error while trying to open mod file at: {0} \n {1}", currentFilePath, ex.Message));
                        currentFilePath = null;
                        fileOpen        = false;
                        return;
                    }

                    fileOpen = true;
                }

                if (GUILayout.Button(documentationGUIContent))
                {
                    Help.BrowseURL("https://www.dfworkshop.net/projects/daggerfall-unity/modding/");
                }
            });

            if (!isSupportedEditorVersion)
            {
                EditorGUILayout.HelpBox("Unsupported version of Unity Editor: generated mods may not be compatible with release builds!", MessageType.Warning);
            }

            if (modInfo == null)
            {
                fileOpen = false;
                modInfo  = new ModInfo();
            }

            if (!fileOpen) // if no fileopen, hide rest of UI
            {
                EditorGUILayout.HelpBox("Open a manifest file or create a new one to edit or build a mod.", MessageType.Info);
                return;
            }

            GUILayoutHelper.Vertical(() =>
            {
                EditorGUILayout.Space();
                GUILayoutHelper.Horizontal(() =>
                {
                    EditorGUILayout.LabelField(new GUIContent("Current File: "), titleStyle);
                    GUILayout.Space(-1000);
                    EditorGUILayout.LabelField(new GUIContent(currentFilePath), fieldStyle);
                });
                EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);

                EditorGUI.indentLevel++;

                GUILayoutHelper.Vertical(() =>
                {
                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod Title:"), titleStyle);
                        modInfo.ModTitle = EditorGUILayout.TextField(modInfo.ModTitle, GUILayout.MinWidth(1000));
                    });

                    EditorGUILayout.Space();


                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod Version:"), titleStyle);
                        modInfo.ModVersion = EditorGUILayout.TextField(modInfo.ModVersion, GUILayout.MinWidth(1000));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod Creator:"), titleStyle);
                        modInfo.ModAuthor = EditorGUILayout.TextField(modInfo.ModAuthor, GUILayout.MinWidth(1000));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Contact Info:"), titleStyle);
                        modInfo.ContactInfo = EditorGUILayout.TextField(modInfo.ContactInfo, GUILayout.MinWidth(1000));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("DFUnity Version:"), titleStyle);
                        modInfo.DFUnity_Version = EditorGUILayout.TextField(modInfo.DFUnity_Version, GUILayout.MinWidth(1000));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod Description:"), titleStyle);
                        modInfo.ModDescription = EditorGUILayout.TextArea(modInfo.ModDescription, GUILayout.MinWidth(1000));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod GUID: "), titleStyle);
                        EditorGUILayout.LabelField(new GUIContent(modInfo.GUID));
                        if (GUILayout.Button("Generate New GUID"))
                        {
                            modInfo.GUID = System.Guid.NewGuid().ToString();
                        }
                        GUILayout.Space(300);
                    });
                });

                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUI.indentLevel--;

                GUILayoutHelper.Horizontal(() =>
                {
                    if (GUILayout.Button("Add Selected Asset(s)"))
                    {
                        AddSelectedAssetsToMod();
                    }

                    else if (GUILayout.Button("Remove Selected Asset(s)"))
                    {
                        if (Assets == null || Assets.Count < 1)
                        {
                            return;
                        }
                        else if (assetSelection < 0 || assetSelection > Assets.Count)
                        {
                            return;
                        }
                        else
                        {
                            Assets.RemoveAt(assetSelection);
                        }
                    }
                    else if (GUILayout.Button("Clear ALL Asset(s)"))
                    {
                        if (Assets != null)
                        {
                            Assets = new List <string>();
                        }
                    }
                });
            });

            EditorGUILayout.Space();

            ShowFileFoldOut = GUILayoutHelper.Foldout(ShowFileFoldOut, new GUIContent("Files"), () =>
            {
                scrollPos = GUILayoutHelper.ScrollView(scrollPos, () =>
                {
                    assetSelection = GUILayout.SelectionGrid(assetSelection, modInfo.Files.ToArray(), 1);
                });
            });

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical();

            GUILayout.Label("\tBuild Targets:\n", titleStyle);

            for (int i = 0; i < buildTargetsToggles.Length; i++)
            {
                buildTargetsToggles[i] = EditorGUILayout.Toggle(buildTargets[i].ToString(), buildTargetsToggles[i], GUILayout.ExpandWidth(false));
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical();

            GUILayout.Label("Compression Type:\n", titleStyle);
            compressionOption = (ModCompressionOptions)EditorGUILayout.EnumPopup("", compressionOption, GUILayout.MaxWidth(125));
            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Collect Dependencies", GUILayout.MaxWidth(200)) && ModInfoReady)
            {
                foreach (var assetPath in Assets.ToArray())
                {
                    var depends = AssetDatabase.GetDependencies(assetPath);
                    foreach (var d in depends)
                    {
                        AddAssetToMod(d);
                    }
                }
            }

            GUILayout.Space(100);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);

            EditorGUILayout.Space();

            GUILayoutHelper.Horizontal(() =>
            {
                EditorGUILayout.LabelField("Build Path:", titleStyle);
                GUILayout.Space(-1000);
                EditorGUILayout.LabelField(modOutPutPath, fieldStyle);
                if (GUILayout.Button("Set", GUILayout.Width(50)))
                {
                    modOutPutPath = EditorUtility.SaveFolderPanel("Select Destination,", Application.dataPath, "");
                    Debug.Log("build path: " + modOutPutPath);
                }
            });
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);

            GUILayoutHelper.Horizontal(() =>
            {
                if (GUILayout.Button("Save Mod Settings to File"))
                {
                    SaveModFile(File.Exists(currentFilePath));
                    Debug.Log("got path: " + currentFilePath);
                }
                else if (GUILayout.Button("Build Mod"))
                {
                    SaveModFile(true);
                    BuildMod();
                }
            });
        }
        private void OnGUI()
        {
            if (shouldSetStyles)
            {
                SetStyles();
                shouldSetStyles = false;
            }

            var guiColor = GUI.color;

            GUILayout.Label("Versioning", bigLabelCenter);
            GUILayout.BeginHorizontal();
            GUI.color = Color.yellow;
            GUILayout.Label($"Current {version}", labelRight);
            GUILayout.Label($"(Committed {DlogVersion.Version.GetValue()})", label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = version != DlogVersion.Version.GetValue();
            if (GUILayout.Button("Reset", smallButton))
            {
                version = DlogVersion.Version.GetValue();
            }

            if (GUILayout.Button("Commit", smallButton))
            {
                CommitVersion();
            }

            GUI.enabled = true;
            GUILayout.FlexibleSpace();
            GUI.color = guiColor;
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(GUILayout.MaxHeight(32));
            GUI.backgroundColor = Color.red;
            GUILayout.Space(32);
            GUILayoutHelper.CenterVertically(() => {
                if (GUILayout.Button("Bump MAJOR"))
                {
                    version.BumpMajor();
                }
            });
            GUILayoutHelper.CenterVertically(() => {
                if (GUILayout.Button("Bump MINOR"))
                {
                    version.BumpMinor();
                }
            });
            GUILayoutHelper.CenterVertically(() => {
                if (GUILayout.Button("Bump PATCH"))
                {
                    version.BumpPatch();
                }
            });
            GUILayout.Space(32);
            GUI.backgroundColor = guiColor;
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(GUILayout.MaxHeight(32));
            GUILayout.Space(32);
            GUILayoutHelper.CenterVertically(() => { GUILayout.Label("(Enter Manually) Version", labelRight); });
            GUILayoutHelper.CenterVertically(() => { enteredVersion = GUILayout.TextField(enteredVersion); });
            if (!SemVer.IsValid(enteredVersion))
            {
                GUI.enabled = false;
            }
            GUILayoutHelper.CenterVertically(() => {
                if (GUILayout.Button("Set", button))
                {
                    version = (SemVer)enteredVersion;
                }
            });
            GUI.enabled = true;
            GUILayout.Space(32);
            GUILayout.EndHorizontal();
        }
        public void drawOverviewGUI()
        {
            GUILayoutHelper.DrawHeader("文件详情");
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Label("筛选:");
                selectAssetType = EditorGUILayout.Popup(selectAssetType, AssetAllTypes);

                GUILayout.FlexibleSpace();
                if (GUILayout.Button("关闭MipMaps", GUILayout.Width(100F)))
                {
                    List <TextureBean> _textures = new List <TextureBean>();
                    for (int i = 0; i < assetList.Count; i++)
                    {
                        if (selectAssetType != 0 && !assetList[i].AssetDesc.Equals(AssetAllTypes[selectAssetType]))
                        {
                            continue;
                        }
                        if (!assetList[i].MipMaps)
                        {
                            continue;
                        }
                        _textures.Add(assetList[i]);
                    }

                    for (int i = 0; i < _textures.Count; i++)
                    {
                        EditorUtility.DisplayProgressBar("Hold On", "正在自动处理...", i / (float)_textures.Count);
                        TextureImporter texImp = AssetImporter.GetAtPath(_textures[i].FilePath) as TextureImporter;
                        texImp.mipmapEnabled = false;
                        _textures[i].MipMaps = false;
                    }
                    EditorUtility.ClearProgressBar();
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                }

                if (GUILayout.Button("刷新", GUILayout.Width(80)))
                {
                    findAllTextures();
                }
                GUILayout.Space(10);
            }
            GUILayout.Space(5);

            GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
            if (GUILayout.Toggle(false, "名称", "ButtonLeft", GUILayout.MaxWidth(200f)))
            {
                sortName *= -1;
                assetList.Sort((x, y) => x.Name.CompareTo(y.Name) * sortName);
            }
            GUILayout.Toggle(false, "资源类型", "ButtonMid", GUILayout.MinWidth(100F));
            if (GUILayout.Toggle(false, "宽度", "ButtonMid", GUILayout.MinWidth(80f)))
            {
                sortWidth *= -1;
                assetList.Sort((x, y) => x.Width.CompareTo(y.Width) * sortWidth);
            }
            if (GUILayout.Toggle(false, "高度", "ButtonMid", GUILayout.MinWidth(80f)))
            {
                sortHeight *= -1;
                assetList.Sort((x, y) => x.Height.CompareTo(y.Height) * sortHeight);
            }
            GUILayout.Toggle(false, "MipMaps", "ButtonMid", GUILayout.MinWidth(100f));
            if (GUILayout.Toggle(false, "MaxSize", "ButtonMid", GUILayout.MinWidth(80F)))
            {
                sortMaxSize *= -1;
                assetList.Sort((x, y) => x.MaxSize.CompareTo(y.MaxSize) * sortMaxSize);
            }
            GUILayout.Toggle(false, "压缩格式", "ButtonMid", GUILayout.MinWidth(100F));
            if (GUILayout.Toggle(false, "内存消耗", "ButtonRight", GUILayout.MinWidth(100F)))
            {
                sortMemorySize *= -1;
                assetList.Sort((x, y) => x.MemorySize.CompareTo(y.MemorySize) * sortMemorySize);
            }
            GUILayout.Space(10);
            GUILayout.EndHorizontal();

            scrollPos = GUILayout.BeginScrollView(scrollPos);
            int index = 0;

            for (int i = 0; i < assetList.Count; i++)
            {
                if (selectAssetType != 0 && !assetList[i].AssetDesc.Equals(AssetAllTypes[selectAssetType]))
                {
                    continue;
                }

                GUI.backgroundColor = index % 2 == 1 ? Color.white : new Color(0.8f, 0.8f, 0.8f);
                GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                GUI.backgroundColor = Color.white;

                drawRow(index, assetList[i]);

                GUILayout.EndHorizontal();
                index++;
            }
            GUILayout.EndScrollView();
        }
Example #26
0
        private void OnGUI()
        {
            EditorGUILayout.HelpBox("Mod dependency rules can be used to define relationships between this mod and other ones.", MessageType.Info, true);

            scrollPosition = GUILayoutHelper.ScrollView(scrollPosition, () =>
            {
                bool applyDeletionRequests = false;

                for (int i = 0; i < dependencies.Count; i++)
                {
                    ModDependencyEditorData dependency = dependencies[i];

                    EditorGUILayout.LabelField(dependency.TitleContent ?? RefreshTitleContent(ref dependency, i), foldoutStyle);

                    EditorGUILayout.Space();
                    EditorGUILayout.Space();

                    GUILayoutHelper.Indent(() =>
                    {
                        GUILayoutHelper.Horizontal(() =>
                        {
                            using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
                            {
                                dependency.ModIndex = EditorGUILayout.Popup(modName, dependency.ModIndex, availableMods, GUILayout.MinWidth(100));
                                if (dependency.ModIndex < availableMods.Length - 1)
                                {
                                    dependency.Name = availableMods[dependency.ModIndex];
                                }
                                else
                                {
                                    dependency.Name = EditorGUILayout.TextField(dependency.Name, GUILayout.MinWidth(200));
                                }

                                if (changeCheckScope.changed)
                                {
                                    RefreshTitleContent(ref dependency, i);
                                }
                            }

                            EditorGUILayout.LabelField(".dfmod");

                            if (GUILayout.Button(deleteDependencyContent, EditorStyles.toolbarButton, GUILayout.Width(70)))
                            {
                                if (dependency.Name == null || EditorUtility.DisplayDialog("Delete dependency", $"Are you sure you want to delete dependency to {dependency.Name}?", "Yes", "No"))
                                {
                                    applyDeletionRequests |= dependency.DeletionRequest = true;
                                }
                            }
                        });

                        dependency.IsOptional = EditorGUILayout.Popup(requirement, dependency.IsOptional, requirementOptions);
                        dependency.IsPeer     = EditorGUILayout.Popup(loadOrder, dependency.IsPeer, loadOrderOptions);

                        GUILayoutHelper.Horizontal(() =>
                        {
                            dependency.RequireVersion = EditorGUILayout.Toggle(version, dependency.RequireVersion);

                            GUILayoutHelper.EnableGroup(dependency.RequireVersion, () =>
                            {
                                Vector3Int version = dependency.Version;
                                version.x          = EditorGUILayout.IntField(version.x);
                                version.y          = EditorGUILayout.IntField(version.y);
                                version.z          = EditorGUILayout.IntField(version.z);
                                dependency.Version = version;
                            });
                        });
                    });

                    dependencies[i] = dependency;

                    EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
                }

                if (applyDeletionRequests)
                {
                    var dependencies = new List <ModDependencyEditorData>();
                    for (int i = 0; i < this.dependencies.Count; i++)
                    {
                        if (!this.dependencies[i].DeletionRequest)
                        {
                            dependencies.Add(this.dependencies[i]);
                        }
                    }
                    this.dependencies = dependencies;
                }
            });

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            GUILayoutHelper.Horizontal(() =>
            {
                if (GUILayout.Button(addDependencyContent))
                {
                    dependencies.Add(new ModDependencyEditorData()
                    {
                        ModIndex = availableMods.Length - 1
                    });
                }

                if (GUILayout.Button(saveAndCloseContent))
                {
                    SaveChanges();
                    Close();
                }
            });
        }
        void OnGUI()
        {
            EditorGUI.indentLevel++;

            GUILayoutHelper.Horizontal(() =>
            {
                if (GUILayout.Button("Create New Mod"))
                {
                    fileOpen = true;
                    if (modInfo != null)
                    {
                        modInfo.DFUnity_Verion = VersionInfo.DaggerfallUnityVersion;
                    }
                }

                else if (GUILayout.Button("Open Existing Mod Settings File"))
                {
                    try
                    {
                        currentFilePath = EditorUtility.OpenFilePanelWithFilters("", Application.dataPath, new string[] { "JSON", "dfmod.json" });

                        if (!File.Exists(currentFilePath))
                        {
                            Debug.Log("Invalid file selection");
                            currentFilePath = null;
                            fileOpen        = false;
                            return;
                        }

                        string inPut = File.ReadAllText(currentFilePath);
                        modInfo      = (ModInfo)JsonUtility.FromJson(inPut, typeof(ModInfo));

                        Debug.Log(string.Format("opened mod file for: {0}", modInfo.ModTitle));
                    }
                    catch (Exception ex)
                    {
                        Debug.Log(string.Format("Error while trying to open mod file at: {0} \n {1}", currentFilePath, ex.Message));
                        currentFilePath = null;
                        fileOpen        = false;
                        return;
                    }

                    fileOpen = true;
                }
            });

            if (modInfo == null)
            {
                fileOpen = false;
                modInfo  = new ModInfo();
            }
            if (!fileOpen) // if no fileopen, hide rest of UI
            {
                return;
            }

            GUILayoutHelper.Vertical(() =>
            {
                EditorGUILayout.LabelField(new GUIContent("Mod File Path:" + currentFilePath));
                EditorGUI.indentLevel++;

                GUILayoutHelper.Vertical(() =>
                {
                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod File Name:"));
                        modInfo.ModFileName = EditorGUILayout.TextField(modInfo.ModFileName.ToLower(), GUILayout.MinWidth(600));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod Title:"));
                        modInfo.ModTitle = EditorGUILayout.TextField(modInfo.ModTitle, GUILayout.MinWidth(600));
                    });

                    EditorGUILayout.Space();


                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod Version:"));
                        modInfo.ModVersion = EditorGUILayout.TextField(modInfo.ModVersion, GUILayout.MinWidth(600));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod Creator:"));
                        modInfo.ModAuthor = EditorGUILayout.TextField(modInfo.ModAuthor, GUILayout.MinWidth(600));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Contact Info:"));
                        modInfo.ContactInfo = EditorGUILayout.TextField(modInfo.ContactInfo, GUILayout.MinWidth(600));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("DFUnity Version:"));
                        modInfo.DFUnity_Verion = EditorGUILayout.TextField(modInfo.DFUnity_Verion, GUILayout.MinWidth(600));
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        EditorGUILayout.LabelField(new GUIContent("Mod Description:"));
                        modInfo.ModDescription = EditorGUILayout.TextArea(modInfo.ModDescription, GUILayout.MinWidth(600));
                    });
                });

                EditorGUILayout.Space();
                EditorGUI.indentLevel--;

                GUILayoutHelper.Horizontal(() =>
                {
                    if (GUILayout.Button("Add Selected Asset(s)"))
                    {
                        AddAssetToMod();
                    }

                    else if (GUILayout.Button("Remove Selected Asset(s)"))
                    {
                        if (Assets == null || Assets.Count < 1)
                        {
                            return;
                        }
                        else if (assetSelection < 0 || assetSelection > Assets.Count)
                        {
                            return;
                        }
                        else
                        {
                            Assets.RemoveAt(assetSelection);
                        }
                    }
                    else if (GUILayout.Button("Clear ALL Asset(s)"))
                    {
                        if (Assets != null)
                        {
                            Assets = new List <string>();
                        }
                    }
                });
            });

            EditorGUILayout.Space();

            ShowFileFoldOut = GUILayoutHelper.Foldout(ShowFileFoldOut, new GUIContent("Files"), () =>
            {
                scrollPos = GUILayoutHelper.ScrollView(scrollPos, () =>
                {
                    assetSelection = GUILayout.SelectionGrid(assetSelection, modInfo.Files.ToArray(), 1);
                });
            });

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            GUILayoutHelper.Horizontal(() =>
            {
                if (GUILayout.Button("Save Mod Settings to File"))
                {
                    SaveModFile();
                    Debug.Log("got path: " + currentFilePath);
                }
                else if (GUILayout.Button("Build Mod"))
                {
                    SaveModFile();
                    BuildMod();
                }
            });
        }
Example #28
0
        private void drawOverviewGUI()
        {
            GUILayoutHelper.DrawHeader("文件详情");
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Label("筛选:");
                selectAssetType = EditorGUILayout.Popup(selectAssetType, AssetAllTypes);

                GUILayout.FlexibleSpace();
                if (GUILayout.Button("刷新", GUILayout.Width(80)))
                {
                    findModels();
                }
                GUILayout.Space(10);
            }
            GUILayout.Space(5);

            GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
            if (GUILayout.Toggle(false, "模型名称", "ButtonLeft", GUILayout.MaxWidth(200f)))
            {
                sortName *= -1;
                modelList.Sort((x, y) => x.Name.CompareTo(y.Name) * sortName);
            }
            GUILayout.Toggle(false, "资源类型", "ButtonMid", GUILayout.MinWidth(100F));
            GUILayout.Toggle(false, "顶点数", "ButtonMid", GUILayout.MinWidth(80f));
            if (GUILayout.Toggle(false, "三角面数", "ButtonMid", GUILayout.MinWidth(80f)))
            {
                sortTriangle *= -1;
                modelList.Sort((x, y) => x.TriangleCount.CompareTo(y.TriangleCount) * sortTriangle);
            }
            if (GUILayout.Toggle(false, "骨骼数", "ButtonMid", GUILayout.MinWidth(50f)))
            {
                sortBond *= -1;
                modelList.Sort((x, y) => x.BondCount.CompareTo(y.BondCount) * sortBond);
            }
            //            GUILayout.Label("贴图名称", GUILayout.Width(150F));
            GUILayout.Toggle(false, "贴图尺寸", "ButtonMid", GUILayout.MinWidth(100F));
            if (GUILayout.Toggle(false, "综合评分", "ButtonRight", GUILayout.MinWidth(100F)))
            {
                sortScore *= -1;
                modelList.Sort((x, y) => x.Score.CompareTo(y.Score) * sortScore);
            }
            GUILayout.Space(10);
            GUILayout.EndHorizontal();

            scrollPos = GUILayout.BeginScrollView(scrollPos);
            int index = 0;

            for (int i = 0; i < modelList.Count; i++)
            {
                if (selectAssetType != 0 && !modelList[i].AssetDesc.Equals(AssetAllTypes[selectAssetType]))
                {
                    continue;
                }

                GUI.backgroundColor = index % 2 == 1 ? Color.white : new Color(0.8f, 0.8f, 0.8f);
                GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                GUI.backgroundColor = Color.white;

                drawRow(modelList[i]);

                GUILayout.EndHorizontal();
                index++;
            }
            GUILayout.EndScrollView();
        }
Example #29
0
 private static void OnGUI(UnityModManager.ModEntry obj)
 {
     GUILayoutHelper.FloatField("MessageLifeTime", _cache, () => settings.MessageLifeTime, v => settings.MessageLifeTime = v, 0, 600);
     GUILayoutHelper.IntField("MaxLogsCount", _cache, () => settings.MaxLogsCount, v => settings.MaxLogsCount            = v, 0, 600);
 }
Example #30
0
        public void OnGUI()
        {
            if (settings == null)
            {
                this.Initizalize();
            }

            GUILayoutHelper.DrawHeader("模型规范设置");
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("清空", GUILayout.Width(80)))
                {
                    if (File.Exists(OverviewSetting.LocalParticleFilePath))
                    {
                        File.Delete(OverviewSetting.LocalParticleFilePath);
                    }
                    OverviewSetting.LocalParticleFilePath = "";
                }

                if (GUILayout.Button("加载", GUILayout.Width(80)))
                {
                    string filePath = EditorUtility.OpenFilePanel("打开", Application.dataPath, "xml");
                    OverviewSetting.LocalParticleFilePath = filePath.Replace(Application.dataPath, "Assets");
                    OverviewSetting.Instance.ReadParticelEffectSettings();
                    this.Initizalize();
                }
                GUILayout.Space(10);
            }

            GUILayout.Space(5);
            GUILayoutHelper.DrawSeparator();
            if (settings != null)
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos);
                for (int i = 0; i < settings.Count; i++)
                {
                    GUILayout.Space(5);
                    drawSetting(settings[i]);
                    GUILayoutHelper.DrawSeparator();
                }

                if (removeSettings.Count > 0)
                {
                    for (int i = 0; i < removeSettings.Count; i++)
                    {
                        settings.Remove(removeSettings[i]);
                    }
                    removeSettings.Clear();
                }
                GUILayout.EndScrollView();
            }

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("保存"))
            {
                if (string.IsNullOrEmpty(OverviewSetting.LocalParticleFilePath))
                {
                    string filePath = EditorUtility.SaveFilePanel("保存", Application.dataPath, "new file", "xml");
                    OverviewSetting.LocalParticleFilePath = filePath.Replace(Application.dataPath, "Assets");
                }
                this.saveSettingRule(OverviewSetting.LocalParticleFilePath);
                AssetDatabase.Refresh();
                Debug.Log("Save Success !");
            }
            GUILayout.Space(10);
            if (GUILayout.Button("添加规则"))
            {
                ParticleEffectSettingBean msb = new ParticleEffectSettingBean();
                msb.Folder.Add(string.Empty);
                settings.Add(msb);
            }
            GUILayout.EndHorizontal();
        }