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); }
private bool LoadItemType(string v) { this.ClearEditor(); this.Skinnable = Skinnable.FindForItem(v); if (this.Skinnable == null) { return(false); } this.ItemTypeSelector.@value = this.ItemTypeSelector.options.IndexOf(this.ItemTypeSelector.options.First <Dropdown.OptionData>((Dropdown.OptionData x) => x.text == this.Skinnable.Name)); this.Prefab = Global.CreatePrefab(this.Skinnable.EntityPrefabName); WorkshopItemEditor.RemoveLODs(this.Prefab); this.Prefab.transform.position = this.item_position_a.transform.position; this.Prefab.transform.rotation = this.item_position_a.transform.rotation; this.Prefab.SetActive(true); this.Prefab.AddComponent <DepthOfFieldFocusPoint>(); this.Prefab.BroadcastMessage("BuildRig", SendMessageOptions.DontRequireReceiver); this.Prefab.BroadcastMessage("WorkshopMode", SendMessageOptions.DontRequireReceiver); Camera.main.FocusOnRenderer(this.Prefab, new Vector3(0.3f, 0.5f, 1f), Vector3.up, -1); if (this.Skin == null) { this.Skin = new Rust.Workshop.Skin(); } this.Skin.Skinnable = this.Skinnable; this.Skin.ReadDefaults(); return(true); }
private static Skinnable[] LoadSkinnableAssets() { string[] skinnables = GameManifest.loadedManifest.skinnables; Skinnable[] skinnableArray = new Skinnable[skinnables.Length]; for (int index = 0; index < skinnables.Length; ++index) { skinnableArray[index] = FileSystem.Load <Skinnable>(skinnables[index], true); } return(skinnableArray); }
private static Skinnable[] LoadSkinnableAssets() { string[] current = GameManifest.Current.skinnables; Skinnable[] skinnableArray = new Skinnable[(int)current.Length]; for (int i = 0; i < (int)current.Length; i++) { skinnableArray[i] = FileSystem.Load <Skinnable>(current[i], true); } return(skinnableArray); }
public void SaveSkinnable(Skinnable skinnable) { bool replacePrefab = false; bool changeMesh = false; bool changeMaterials = false; bool changeMatColors = false; bool changeLightColor = false; bool changeLightIntensity = false; bool changeParticleColors = false; bool applyToChildren = false; if (skinnable is SkinnableGeneral) { replacePrefab = false; changeMaterials = (skinnable as SkinnableGeneral).changeMaterials; changeMatColors = (skinnable as SkinnableGeneral).changeMaterialColor; changeParticleColors = false; applyToChildren = false; if (skinnable is SkinnableMesh) { replacePrefab = false; changeMesh = (skinnable as SkinnableMesh).changeMesh; changeMaterials = (skinnable as SkinnableGeneral).changeMaterials; changeMatColors = (skinnable as SkinnableGeneral).changeMaterialColor; changeParticleColors = false; applyToChildren = false; } else if (skinnable is SkinnablePrefab) { replacePrefab = (skinnable as SkinnablePrefab).replacePrefab; changeMesh = false; changeMaterials = (skinnable as SkinnablePrefab).changeMaterials; changeMatColors = (skinnable as SkinnablePrefab).changeMaterialColor; changeParticleColors = false; applyToChildren = false; } else if (skinnable is SkinnableParticles) { replacePrefab = false; changeMesh = false; changeMaterials = (skinnable as SkinnableParticles).changeMaterials; changeMatColors = (skinnable as SkinnableParticles).changeMaterialColor; changeParticleColors = (skinnable as SkinnableParticles).changeParticleColors; } } if (skinnable is SkinnableLight) { changeLightColor = (skinnable as SkinnableLight).changeLightColor; changeLightIntensity = (skinnable as SkinnableLight).changeLightIntensity; } SaveSkinnableWindow.Init(skinnable, replacePrefab, changeMesh, changeMaterials, changeMatColors, changeLightColor, changeLightIntensity, changeParticleColors, applyToChildren); }
public override void OnInspectorGUI() { Skinnable skinnable = (Skinnable)target; base.OnInspectorGUI(); GUILayout.Space(10); if (GUILayout.Button("Save Skinnable")) { SaveSkinnable(skinnable); } }
/// <summary> /// Retrieves all available skins for an item /// </summary> /// <param name="item">The ItemName or ShortName.</param> /// <returns></returns> IEnumerable <ApprovedSkinInfo> GetSkinsForItem(string itemName) { if (string.IsNullOrEmpty(itemName)) { return(null); } if (itemName.EndsWith("deployed")) { switch (itemName) { case "sleepingbag_leather_deployed": { itemName = "sleepingbag"; break; } case "vendingmachine.deployed": { itemName = "vending.machine"; break; } case "woodbox_deployed": { itemName = "box.wooden"; break; } case "reactivetarget_deployed": { itemName = "target.reactive"; break; } default: break; } } var skinnable = Skinnable.FindForItem(itemName); if (skinnable == null) { return(null); } return(Approved.All .Where(x => x.Value.Skinnable == skinnable) .Select(x => x.Value)); }
public static void Apply(GameObject obj, Skinnable skinnable, Material[] Materials) { TimeWarning.BeginSample("Skin.Apply"); if (Materials == null) { TimeWarning.EndSample(); return; } if (obj == null) { TimeWarning.EndSample(); return; } MaterialReplacement.ReplaceRecursive(obj, skinnable.SourceMaterials, Materials); TimeWarning.EndSample(); }
public static void Init(Skinnable skinnable, bool replacePrefab = false, bool changeMesh = false, bool changeMaterials = false, bool changeMatColors = false, bool changeLightColor = false, bool changeLightIntensity = false, bool changeParticleColors = false, bool applyToChildren = false) { SaveSkinnableWindow window = (SaveSkinnableWindow)GetWindow(typeof(SaveSkinnableWindow)); window._skinnable = skinnable; window._savePrefab = replacePrefab; window._saveMesh = changeMesh; window._saveMaterials = changeMaterials; window._saveMatColors = changeMatColors; window._saveLightColor = changeLightColor; window._saveLightIntensity = changeLightIntensity; window._saveParticleColors = changeParticleColors; window._saveChildren = applyToChildren; window.saveColors = skinnable.saveColors; window.minSize = new Vector2(250, 250); window.Show(); }