public static Texture2D getCard(Transform item, Transform hook_0, Transform hook_1, int width, int height, float size, float range) { if (item == null) { return(null); } item.position = new Vector3(-256f, -256f, 0f); RenderTexture temporary = RenderTexture.GetTemporary(width, height, 16, 0, 2); temporary.name = "Card_Render"; RenderTexture.active = temporary; ItemTool.tool.GetComponent <Camera>().targetTexture = temporary; ItemTool.tool.GetComponent <Camera>().orthographicSize = size; Texture2D texture2D = new Texture2D(width * 2, height, 5, false, false); texture2D.name = "Card_Atlas"; texture2D.filterMode = 0; texture2D.wrapMode = 1; bool fog = RenderSettings.fog; AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientSkyColor = RenderSettings.ambientSkyColor; Color ambientEquatorColor = RenderSettings.ambientEquatorColor; Color ambientGroundColor = RenderSettings.ambientGroundColor; RenderSettings.fog = false; RenderSettings.ambientMode = 1; RenderSettings.ambientSkyColor = Color.white; RenderSettings.ambientEquatorColor = Color.white; RenderSettings.ambientGroundColor = Color.white; if (Provider.isConnected) { LevelLighting.setEnabled(false); } ItemTool.tool.GetComponent <Camera>().cullingMask = RayMasks.RESOURCE; ItemTool.tool.GetComponent <Camera>().farClipPlane = range; ItemTool.tool.transform.position = hook_0.position; ItemTool.tool.transform.rotation = hook_0.rotation; ItemTool.tool.GetComponent <Camera>().Render(); texture2D.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0); ItemTool.tool.transform.position = hook_1.position; ItemTool.tool.transform.rotation = hook_1.rotation; ItemTool.tool.GetComponent <Camera>().Render(); texture2D.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), width, 0); if (Provider.isConnected) { LevelLighting.setEnabled(true); } RenderSettings.fog = fog; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientSkyColor = ambientSkyColor; RenderSettings.ambientEquatorColor = ambientEquatorColor; RenderSettings.ambientGroundColor = ambientGroundColor; item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); for (int i = 0; i < texture2D.width; i++) { for (int j = 0; j < texture2D.height; j++) { Color32 color = texture2D.GetPixel(i, j); if (color.r == 255 && color.g == 255 && color.b == 255) { color.a = 0; } else { color.a = byte.MaxValue; } texture2D.SetPixel(i, j, color); } } texture2D.Apply(); RenderTexture.ReleaseTemporary(temporary); return(texture2D); }
private void Update() { if (ItemTool.icons == null || ItemTool.icons.Count == 0) { return; } ItemIconInfo itemIconInfo = ItemTool.icons.Dequeue(); if (itemIconInfo == null) { return; } if (itemIconInfo.itemAsset == null) { return; } Transform item = ItemTool.getItem(itemIconInfo.id, itemIconInfo.skin, itemIconInfo.quality, itemIconInfo.state, false, itemIconInfo.itemAsset, itemIconInfo.skinAsset); item.position = new Vector3(-256f, -256f, 0f); Transform transform; if (itemIconInfo.scale && itemIconInfo.skin != 0) { if (itemIconInfo.itemAsset.size2_z == 0f) { item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Assets.errors.Add("Failed to create a skin icon of size 0 for " + itemIconInfo.id + "."); return; } transform = item.FindChild("Icon2"); if (transform == null) { item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Assets.errors.Add("Failed to find a skin icon hook on " + itemIconInfo.id + "."); return; } } else { if (itemIconInfo.itemAsset.size_z == 0f) { item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Assets.errors.Add("Failed to create an item icon of size 0 for " + itemIconInfo.id + "."); return; } transform = item.FindChild("Icon"); if (transform == null) { item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Assets.errors.Add("Failed to find an item icon hook on " + itemIconInfo.id + "."); return; } } ItemTool.tool.transform.position = transform.position; ItemTool.tool.transform.rotation = transform.rotation; RenderTexture temporary = RenderTexture.GetTemporary(itemIconInfo.x, itemIconInfo.y, 16, 0, 2); temporary.name = string.Concat(new object[] { "Item_Render_", itemIconInfo.id, "_", itemIconInfo.skin }); RenderTexture.active = temporary; ItemTool.tool.GetComponent <Camera>().targetTexture = temporary; ItemTool.tool.GetComponent <Camera>().orthographicSize = itemIconInfo.itemAsset.size_z; if (itemIconInfo.scale) { if (itemIconInfo.skin != 0) { ItemTool.tool.GetComponent <Camera>().orthographicSize = itemIconInfo.itemAsset.size2_z; } else { float num = (float)itemIconInfo.itemAsset.size_x / (float)itemIconInfo.itemAsset.size_y; ItemTool.tool.GetComponent <Camera>().orthographicSize *= num; } } bool fog = RenderSettings.fog; AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientSkyColor = RenderSettings.ambientSkyColor; Color ambientEquatorColor = RenderSettings.ambientEquatorColor; Color ambientGroundColor = RenderSettings.ambientGroundColor; RenderSettings.fog = false; RenderSettings.ambientMode = 1; RenderSettings.ambientSkyColor = Color.white; RenderSettings.ambientEquatorColor = Color.white; RenderSettings.ambientGroundColor = Color.white; if (Provider.isConnected) { LevelLighting.setEnabled(false); } ItemTool.tool.GetComponent <Light>().enabled = true; ItemTool.tool.GetComponent <Camera>().cullingMask = RayMasks.ITEM; ItemTool.tool.GetComponent <Camera>().farClipPlane = 16f; ItemTool.tool.GetComponent <Camera>().Render(); ItemTool.tool.GetComponent <Light>().enabled = false; if (Provider.isConnected) { LevelLighting.setEnabled(true); } RenderSettings.fog = fog; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientSkyColor = ambientSkyColor; RenderSettings.ambientEquatorColor = ambientEquatorColor; RenderSettings.ambientGroundColor = ambientGroundColor; item.position = new Vector3(0f, -256f, -256f); Object.Destroy(item.gameObject); Texture2D texture2D = new Texture2D(itemIconInfo.x, itemIconInfo.y, 5, false, true); texture2D.name = string.Concat(new object[] { "Item_Icon_", itemIconInfo.id, "_", itemIconInfo.skin }); texture2D.filterMode = 0; texture2D.ReadPixels(new Rect(0f, 0f, (float)itemIconInfo.x, (float)itemIconInfo.y), 0, 0); texture2D.Apply(); RenderTexture.ReleaseTemporary(temporary); if (itemIconInfo.callback != null) { itemIconInfo.callback(texture2D); } if (itemIconInfo.state.Length == 0 && itemIconInfo.skin == 0 && itemIconInfo.x == (int)(itemIconInfo.itemAsset.size_x * 50) && itemIconInfo.y == (int)(itemIconInfo.itemAsset.size_y * 50) && !ItemTool.cache.ContainsKey(itemIconInfo.id)) { ItemTool.cache.Add(itemIconInfo.id, texture2D); } }
// Token: 0x0600342A RID: 13354 RVA: 0x00154300 File Offset: 0x00152700 public static Texture2D captureIcon(ushort id, ushort skin, Transform model, Transform icon, int width, int height, float orthoSize) { ItemTool.tool.transform.position = icon.position; ItemTool.tool.transform.rotation = icon.rotation; RenderTexture temporary = RenderTexture.GetTemporary(width, height, 16, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB); temporary.name = string.Concat(new object[] { "Render_", id, "_", skin }); RenderTexture.active = temporary; ItemTool.tool.GetComponent <Camera>().targetTexture = temporary; ItemTool.tool.GetComponent <Camera>().orthographicSize = orthoSize; bool fog = RenderSettings.fog; AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientSkyColor = RenderSettings.ambientSkyColor; Color ambientEquatorColor = RenderSettings.ambientEquatorColor; Color ambientGroundColor = RenderSettings.ambientGroundColor; RenderSettings.fog = false; RenderSettings.ambientMode = AmbientMode.Trilight; RenderSettings.ambientSkyColor = Color.white; RenderSettings.ambientEquatorColor = Color.white; RenderSettings.ambientGroundColor = Color.white; if (Provider.isConnected) { LevelLighting.setEnabled(false); } ItemTool.tool.GetComponent <Light>().enabled = true; ItemTool.tool.GetComponent <Camera>().cullingMask = (RayMasks.ITEM | RayMasks.VEHICLE | RayMasks.MEDIUM | RayMasks.SMALL); ItemTool.tool.GetComponent <Camera>().farClipPlane = 16f; ItemTool.tool.GetComponent <Camera>().Render(); ItemTool.tool.GetComponent <Light>().enabled = false; if (Provider.isConnected) { LevelLighting.setEnabled(true); } RenderSettings.fog = fog; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientSkyColor = ambientSkyColor; RenderSettings.ambientEquatorColor = ambientEquatorColor; RenderSettings.ambientGroundColor = ambientGroundColor; model.position = new Vector3(0f, -256f, -256f); UnityEngine.Object.Destroy(model.gameObject); Texture2D texture2D = new Texture2D(width, height, TextureFormat.ARGB32, false, true); texture2D.name = string.Concat(new object[] { "Icon_", id, "_", skin }); texture2D.filterMode = FilterMode.Point; texture2D.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0); texture2D.Apply(); RenderTexture.ReleaseTemporary(temporary); return(texture2D); }