Beispiel #1
0
        private static BuildAssetBundleOptions ToBuildAssetBundleOptions(ModCompressionOptions value)
        {
            switch (value)
            {
            case ModCompressionOptions.LZ4:
                return(BuildAssetBundleOptions.ChunkBasedCompression);

            case ModCompressionOptions.Uncompressed:
                return(BuildAssetBundleOptions.UncompressedAssetBundle);

            default:
                return(BuildAssetBundleOptions.None);
            }
        }
Beispiel #2
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();
                }
            });
        }