Esempio n. 1
0
 private async Task ExportTexture(Dictionary <string, string> data, string folder, int group, string paramname, Material mat, Material defaultMat, bool isNormalMap = false)
 {
     WorkshopItemEditor.Loading(true, string.Concat("Exporting Texture ", paramname), "", 0f);
     UnityEngine.Texture texture = mat.GetTexture(paramname);
     if (texture != defaultMat.GetTexture(paramname))
     {
         if (texture != null)
         {
             texture = Facepunch.Utility.Texture.LimitSize(texture as Texture2D, this.Skinnable.Groups[group].MaxTextureSize, this.Skinnable.Groups[group].MaxTextureSize);
             if (isNormalMap)
             {
                 texture = Facepunch.Utility.Texture.CreateReadableCopy(texture as Texture2D, 0, 0);
                 (texture as Texture2D).DecompressNormals();
             }
             string str = string.Format("{0}{1}{2}", paramname, group, ".png");
             data.Add(paramname, str);
             texture.SaveAsPng(string.Concat(folder, "/", str));
             await Task.Delay(1);
         }
         else
         {
             data.Add(paramname, "none");
         }
     }
 }
        internal IEnumerator DoImport(Item item, Skin skin)
        {
            ImportVersion2 importVersion2 = null;

            if (importVersion2.Bundle != null)
            {
                importVersion2.Bundle.Unload(true);
                importVersion2.Bundle = null;
            }
            WorkshopItemEditor.Loading(true, "Downloading..", "", 0f);
            if (!item.IsInstalled)
            {
                item.Download(true);
                while (item.IsDownloading)
                {
                    yield return(null);
                }
                while (!item.IsInstalled)
                {
                    yield return(null);
                }
            }
            string str = string.Concat(item.Directory, "/bundle");

            if (!File.Exists(str))
            {
                UnityEngine.Debug.LogWarning("No Bundle Found!");
                Os.OpenFolder(item.Directory);
                yield return(new WaitForSeconds(5f));
            }
            else
            {
                yield return(importVersion2.StartCoroutine(importVersion2.LoadItem(item.Directory, str, skin)));
            }
        }
Esempio n. 3
0
        private async Task PublishToSteam(string folder)
        {
            Steamworks.Ugc.Editor editor = new Steamworks.Ugc.Editor();
            editor = (this.ItemId != 0 ? new Steamworks.Ugc.Editor(this.ItemId) : Steamworks.Ugc.Editor.NewMicrotransactionFile);
            Steamworks.Ugc.Editor editor1 = editor.WithContent(folder);
            editor1 = editor1.WithPreviewFile(string.Concat(folder, "/icon_background.png"));
            editor1 = editor1.WithTitle(this.Title);
            editor1 = editor1.WithTag("Version3");
            editor1 = editor1.WithTag(this.Skinnable.Name);
            editor1 = editor1.WithTag("Skin");
            editor  = editor1.WithPublicVisibility();
            if (!string.IsNullOrEmpty(this.ChangeLog.text))
            {
                editor = editor.WithChangeLog(this.ChangeLog.text);
            }
            WorkshopItemEditor.Loading(true, "Publishing To Steam", "", 0f);
            PublishResult publishResult = await editor.SubmitAsync(null);

            if (publishResult.Success)
            {
                UnityEngine.Debug.Log(string.Concat("Published File: ", publishResult.FileId));
            }
            else
            {
                UnityEngine.Debug.Log(string.Concat("Error: ", publishResult.Result));
            }
            Item?nullable = await SteamUGC.QueryFileAsync(publishResult.FileId);

            if (nullable.HasValue)
            {
                WorkshopItemEditor id = this.Editor;
                Item value            = nullable.Value;
                id.ItemId = value.Id;
                WorkshopItemEditor title = this.Editor;
                value               = nullable.Value;
                title.ItemTitle     = value.Title;
                this.ChangeLog.text = "";
                value               = nullable.Value;
                UnityEngine.Application.OpenURL(value.Url);
                WorkshopItemList.RefreshAll();
            }
            else
            {
                UnityEngine.Debug.Log("Error Retrieving item information!");
                WorkshopItemList.RefreshAll();
            }
        }
Esempio n. 4
0
 internal IEnumerator DoImport(Item item, Skin skin)
 {
     WorkshopItemEditor.Loading(true, "Downloading..", "", 0f);
     if (!item.IsInstalled)
     {
         item.Download(true);
         while (item.IsDownloading)
         {
             yield return(null);
         }
         WorkshopItemEditor.Loading(true, "Installing..", "", 0f);
         while (!item.IsInstalled)
         {
             yield return(null);
         }
     }
     Os.OpenFolder(item.Directory);
     WorkshopItemEditor.Loading(true, "Unable To Import", "", 0f);
     yield return(new WaitForSeconds(5f));
 }
Esempio n. 5
0
        internal IEnumerator DoImport(Item item, Skin skin)
        {
            ImportVersion3 importVersion3 = null;

            WorkshopItemEditor.Loading(true, "Downloading..", "", 0f);
            yield return(importVersion3.StartCoroutine(importVersion3.DownloadFromWorkshop(item)));

            if (!item.IsInstalled || item.Directory == null)
            {
                UnityEngine.Debug.Log("Error opening item, not downloaded properly.");
                UnityEngine.Debug.Log(string.Concat("item.Directory: ", item.Directory));
                bool isInstalled = item.IsInstalled;
                UnityEngine.Debug.Log(string.Concat("item.Installed: ", isInstalled.ToString()));
                yield break;
            }
            WorkshopItemEditor.Loading(true, "Loading..", "Reloading Textures", 0f);
            yield return(importVersion3.StartCoroutine(skin.LoadIcon(item.Id, item.Directory, null)));

            yield return(importVersion3.StartCoroutine(skin.LoadAssets(item.Id, item.Directory, null)));
        }
    protected void OnGUI()
    {
        if (!SteamAPI.IsSteamRunning())
        {
            EditorGUILayout.HelpBox("Steam is not running. Please start Steam to continue.", MessageType.Error);
        }
        else if (ModConfig.Instance == null || string.IsNullOrEmpty(ModConfig.ID))
        {
            EditorGUILayout.HelpBox("You must configure your ModConfig using \"Keep Talking Mod Kit -> Configure Mod\".", MessageType.Error);
        }
        else if (!isInitialized)
        {
            EditorGUILayout.HelpBox("You must log in to Steam to continue.", MessageType.Error);
        }
        else
        {
            if (currentWorkshopItem == null)
            {
                string workshopItemAssetPath = "Assets/Editor/Resources/WorkshopItem.asset";

                currentWorkshopItem = AssetDatabase.LoadAssetAtPath <WorkshopItem>(workshopItemAssetPath);

                if (currentWorkshopItem == null)
                {
                    currentWorkshopItem = ScriptableObject.CreateInstance <WorkshopItem>();

                    if (ModConfig.Instance != null)
                    {
                        currentWorkshopItem.Title = ModConfig.Title;
                    }

                    AssetDatabase.CreateAsset(currentWorkshopItem, workshopItemAssetPath);
                }

                if (workshopItemEditor != null && workshopItemEditor.target != currentWorkshopItem)
                {
                    DestroyImmediate(workshopItemEditor);
                    workshopItemEditor = null;
                }

                if (workshopItemEditor == null)
                {
                    workshopItemEditor = (WorkshopItemEditor)Editor.CreateEditor(currentWorkshopItem, typeof(WorkshopItemEditor));
                }
            }

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            workshopItemEditor.OnInspectorGUI();

            //Publishing Tools
            EditorGUILayout.Separator();
            Color oldBGColor = GUI.backgroundColor;
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.5f, 0.7f);
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUI.backgroundColor = oldBGColor;

            EditorGUILayout.LabelField("Publishing Tools", EditorStyles.largeLabel);
            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("User:"******"Content Folder:", GetContentPath());

            DirectoryInfo dir = new DirectoryInfo(GetContentPath());

            if (dir.Exists)
            {
                FileInfo[] files     = dir.GetFiles("*.*", SearchOption.AllDirectories);
                long       totalSize = 0;
                foreach (var file in files)
                {
                    totalSize += file.Length;
                }

                EditorGUILayout.LabelField("File Count:", files.Length.ToString());
                EditorGUILayout.LabelField("Total Size:", FormatFileSize(totalSize));
            }
            else
            {
                EditorGUILayout.HelpBox("Content folder not found", MessageType.Error);
            }

            string[] tags = GetTags();
            if (tags == null)
            {
                EditorGUILayout.LabelField("Tags [0]: (none set)");
            }
            else
            {
                EditorGUILayout.LabelField(string.Format("Tags [{0}]: {1}", tags == null ? "0" : tags.Length.ToString(), string.Join(", ", tags)));
            }

            //Change Notes
            EditorGUILayout.PrefixLabel("Change Notes:");
            changeNotes = EditorGUILayout.TextArea(changeNotes, GUILayout.MinHeight(64));

            if (string.IsNullOrEmpty(changeNotes))
            {
                EditorGUILayout.HelpBox("Change notes must be entered before publishing to Workshop", MessageType.Warning);
            }


            //Publishing changes
            if (currentWorkshopItem.WorkshopPublishedFileID == 0)
            {
                //Create and Publish
                GUI.enabled = (onCreateItemCallResultHandler != null && !onCreateItemCallResultHandler.IsActive() && !string.IsNullOrEmpty(changeNotes));
                if (GUILayout.Button("Create New Workshop Item and Publish to Steam"))
                {
                    Debug.Log("CreateItem");
                    var createItemCall = SteamUGC.CreateItem(KTANE_APP_ID, EWorkshopFileType.k_EWorkshopFileTypeCommunity);
                    onCreateItemCallResultHandler.Set(createItemCall);
                }
                GUI.enabled = true;
            }
            else
            {
                //Publish to Existing Item
                GUI.enabled = (onItemUpdateCallResultHandler != null && !onItemUpdateCallResultHandler.IsActive() && !string.IsNullOrEmpty(changeNotes));
                if (GUILayout.Button("Publish Changes to Steam"))
                {
                    PublishWorkshopChanges();
                }

                if (!string.IsNullOrEmpty(ugcUpdateStatus))
                {
                    EditorGUILayout.LabelField(ugcUpdateStatus);
                }

                GUI.enabled = true;
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
    }