コード例 #1
0
 public void RenderAllIcons()
 {
     this.Editor.gameObject.SetActive(true);
     if (!Directory.Exists("c:/test/icons"))
     {
         Directory.CreateDirectory("c:/test/icons");
     }
     Skinnable[] all = Skinnable.All;
     for (int i = 0; i < (int)all.Length; i++)
     {
         Skinnable skinnable = all[i];
         this.Editor.StartNewItem(skinnable.Name);
         PropRenderer.RenderScreenshot(this.Editor.Prefab, string.Concat("c:/test/icons/", skinnable.Name, ".png"), 512, 512, 4);
         int num = 0;
         UnityEngine.Mesh[] meshDownloads = skinnable.MeshDownloads;
         for (int j = 0; j < (int)meshDownloads.Length; j++)
         {
             UnityEngine.Mesh mesh = meshDownloads[j];
             if (mesh != null && mesh.isReadable)
             {
                 mesh.Export(string.Format("c:/test/icons/{0}{1}.obj", skinnable.Name, num));
                 num++;
             }
         }
     }
     this.Editor.gameObject.SetActive(false);
 }
コード例 #2
0
        private async Task ExportToFolder(string folder, bool OpenFolder)
        {
            Rust.Workshop.Skin.Manifest manifest = new Rust.Workshop.Skin.Manifest()
            {
                ItemType    = this.Skinnable.Name,
                Version     = 3,
                Groups      = new Rust.Workshop.Skin.Manifest.Group[(int)this.Skin.Materials.Length],
                PublishDate = DateTime.UtcNow,
                AuthorId    = SteamClient.SteamId
            };
            Rust.Workshop.Skin.Manifest group = manifest;
            for (int i = 0; i < (int)this.Skin.Materials.Length; i++)
            {
                group.Groups[i] = new Rust.Workshop.Skin.Manifest.Group();
                await this.ExportTexture(group.Groups[i].Textures, folder, i, "_MainTex", this.Skin.Materials[i], this.Skin.DefaultMaterials[i], false);

                await this.ExportTexture(group.Groups[i].Textures, folder, i, "_OcclusionMap", this.Skin.Materials[i], this.Skin.DefaultMaterials[i], false);

                await this.ExportTexture(group.Groups[i].Textures, folder, i, "_SpecGlossMap", this.Skin.Materials[i], this.Skin.DefaultMaterials[i], false);

                await this.ExportTexture(group.Groups[i].Textures, folder, i, "_BumpMap", this.Skin.Materials[i], this.Skin.DefaultMaterials[i], true);

                await this.ExportTexture(group.Groups[i].Textures, folder, i, "_EmissionMap", this.Skin.Materials[i], this.Skin.DefaultMaterials[i], false);

                group.Groups[i].Floats.Add("_Cutoff", this.Skin.Materials[i].GetFloat("_Cutoff"));
                group.Groups[i].Floats.Add("_BumpScale", this.Skin.Materials[i].GetFloat("_BumpScale"));
                group.Groups[i].Floats.Add("_Glossiness", this.Skin.Materials[i].GetFloat("_Glossiness"));
                group.Groups[i].Floats.Add("_OcclusionStrength", this.Skin.Materials[i].GetFloat("_OcclusionStrength"));
                if (this.Skin.Materials[i].shader.name.Contains("Cloth"))
                {
                    group.Groups[i].Floats.Add("_MicrofiberFuzzIntensity", this.Skin.Materials[i].GetFloat("_MicrofiberFuzzIntensity"));
                    group.Groups[i].Floats.Add("_MicrofiberFuzzScatter", this.Skin.Materials[i].GetFloat("_MicrofiberFuzzScatter"));
                    group.Groups[i].Floats.Add("_MicrofiberFuzzOcclusion", this.Skin.Materials[i].GetFloat("_MicrofiberFuzzOcclusion"));
                }
                group.Groups[i].Colors.Add("_Color", new Rust.Workshop.Skin.Manifest.ColorEntry(this.Skin.Materials[i].GetColor("_Color")));
                group.Groups[i].Colors.Add("_SpecColor", new Rust.Workshop.Skin.Manifest.ColorEntry(this.Skin.Materials[i].GetColor("_SpecColor")));
                group.Groups[i].Colors.Add("_EmissionColor", new Rust.Workshop.Skin.Manifest.ColorEntry(this.Skin.Materials[i].GetColor("_EmissionColor")));
                if (this.Skin.Materials[i].shader.name.Contains("Cloth"))
                {
                    group.Groups[i].Colors.Add("_MicrofiberFuzzColor", new Rust.Workshop.Skin.Manifest.ColorEntry(this.Skin.Materials[i].GetColor("_MicrofiberFuzzColor")));
                }
            }
            PropRenderer.RenderScreenshot(this.Prefab, string.Concat(folder, "/icon.png"), 512, 512, 4);
            this.CreateWorkshopIcon(folder);
            string str = JsonConvert.SerializeObject(group, Formatting.Indented);

            File.WriteAllText(string.Concat(folder, "/manifest.txt"), str);
            if (OpenFolder)
            {
                Os.OpenFolder(folder);
            }
        }