public static float getK(long code, GameTextureType type) { float ret = 1; PictureResource r; if (loadedList.TryGetValue(hashPic(code, type), out r)) { ret = r.k; } return(ret); }
private static UInt64 hashPic(long code, GameTextureType type) { return(((UInt64)type << 32) | ((UInt64)code)); }
public static Texture2D get(long code, GameTextureType type, Texture2D nullReturnValue = null) { try { PictureResource r; if (loadedList.TryGetValue(hashPic(code, type), out r)) { Texture2D re = null; if (r.u_data != null) { if (r.u_data == myBack) { return(nullReturnValue); } else { return(r.u_data); } } if (r.data != null) { re = new Texture2D(400, 600); re.LoadImage(r.data); r.u_data = re; return(re); } if (r.hashed_data != null) { int width = r.hashed_data.GetLength(0); int height = r.hashed_data.GetLength(1); UnityEngine.Color[] cols = new UnityEngine.Color[width * height]; re = new Texture2D(width, height); for (int h = 0; h < height; h++) { for (int w = 0; w < width; w++) { cols[h * width + w] = new UnityEngine.Color(r.hashed_data[w, h, 0], r.hashed_data[w, h, 1], r.hashed_data[w, h, 2], r.hashed_data[w, h, 3]); } } re.SetPixels(0, 0, width, height, cols); re.Apply(); r.u_data = re; return(re); } } else { if (!addedMap.ContainsKey(hashPic(code, type))) { PictureResource a = new PictureResource(type, code, nullReturnValue); bLock = true; waitLoadStack.Push(a); bLock = false; addedMap.Add((UInt64)type << 32 | (UInt64)code, true); } } } catch (Exception e) { Debug.Log("BIGERROR1:" + e.ToString()); } return(null); }
public PictureResource(GameTextureType t, long c, Texture2D n) { type = t; code = c; nullReturen = n; }