protected void checkRecycle() { List <LWindowBase> recycles = new List <LWindowBase>(); foreach (var item in delayDisposeWindows) { if (!isRunning(item.Value.name) && Time.time - delayWindowsTimes[item.Value] >= disposeDuration) { recycles.Add(item.Value); } } while (true) { if (recycles.Count == 0) { break; } LWindowBase win = recycles[0]; delayWindowsTimes.Remove(win); delayDisposeWindows.Remove(win.name); recycles.RemoveAt(0); Destroy(win.gameObject); Debug.Log(string.Format("Destroy Window [{0}]", win.name)); } }
public void runWindow(string name, Type type, WindowHierarchy e, ArrayList list = null) { if (isRunning(name)) { return; } LWindowBase win = loadWindow(name, type); if (win != null) { win.hierarchy = e; win.gameObject.transform.SetParent(hierarchys[e].transform); win.open(list); runningWindows[e].Add(win); if (win.disposeType == WindowDispose.Delay) { delayDisposeWindows[name] = win; delayWindowsTimes[win] = Time.time; } else if (win.disposeType == WindowDispose.Cache) { cacheWindows.Add(name, win); } } }
public void popWindow(LWindowBase win) { if (win != null) { runningWindows[win.hierarchy].Remove(win); win.close(); if (win.disposeType == WindowDispose.Cache) { win.gameObject.transform.SetParent(null); } else if (win.disposeType == WindowDispose.Normal) { cacheWindows.Remove(win.name); delayDisposeWindows.Remove(win.name); delayWindowsTimes.Remove(win); Destroy(win.gameObject); Debug.Log(string.Format("Destroy Window [{0}]", win.name)); } else if (win.disposeType == WindowDispose.Delay) { win.gameObject.transform.SetParent(null); } } }
protected LWindowBase loadWindow(string name) { LWindowBase ret = null; if (cacheWindows.ContainsKey(name)) { ret = cacheWindows[name]; } else if (delayDisposeWindows.ContainsKey(name)) { ret = delayDisposeWindows[name]; } else { GameObject res = LLoadBundle.GetInstance().LoadAsset(LGameConfig.PREFAB_BUNDLE, name, typeof(GameObject)) as GameObject; GameObject obj = Instantiate(res); //string[] split_names = name.Split('/'); //obj.name = split_names[split_names.Length-1]; obj.name = name; obj.GetComponent <RectTransform>().sizeDelta = canvas.GetComponent <RectTransform>().rect.size; ret = obj.GetComponent <LWindowBase>(); if (ret) { ret.name = obj.name; } } return(ret); }
protected LWindowBase loadWindow(string name, Type t) { LWindowBase ret = null; if (cacheWindows.ContainsKey(name)) { ret = cacheWindows[name]; } else if (delayDisposeWindows.ContainsKey(name)) { ret = delayDisposeWindows[name]; } else { GameObject res = Resources.Load(string.Format(loadPath, name)) as GameObject; GameObject obj = Instantiate(res) as GameObject; obj.name = name; obj.GetComponent <RectTransform>().sizeDelta = canvas.GetComponent <RectTransform>().rect.size; ret = obj.GetComponent <LWindowBase>(); if (ret == null) { ret = obj.AddComponent(t) as LWindowBase; } ret.name = name; } return(ret); }
public void runWindow(string name, WindowHierarchy e, object[] list = null) { if (isRunning(name)) { return; } LWindowBase win = loadWindow(name); if (win != null) { win.hierarchy = e; win.gameObject.transform.SetParent(hierarchys[e].transform); win.gameObject.transform.localScale = new Vector3(1, 1, 1); win.gameObject.transform.localPosition = Vector3.zero; win.Open(list); runningWindows[e].Add(win); if (win.disposeType == WindowDispose.Delay) { delayDisposeWindows[name] = win; delayWindowsTimes[win] = Time.time; } else if (win.disposeType == WindowDispose.Cache) { cacheWindows.Add(name, win); } } }
protected LWindowBase loadWindow(string name) { LWindowBase ret = null; if (cacheWindows.ContainsKey(name)) { ret = cacheWindows[name]; } else if (delayDisposeWindows.ContainsKey(name)) { ret = delayDisposeWindows[name]; } else { string abName = LGameConfig.GetABNameWithAtlasPath(name); GameObject res = LLoadBundle.GetInstance().LoadAsset <GameObject>(abName, name); GameObject obj = Instantiate(res); obj.name = name; obj.GetComponent <RectTransform>().sizeDelta = canvas.GetComponent <RectTransform>().rect.size; ret = obj.GetComponent <LWindowBase>(); if (ret) { ret.name = obj.name; } } return(ret); }
static public int get_hierarchy(IntPtr l) { try { LWindowBase self = (LWindowBase)checkSelf(l); pushValue(l, true); pushEnum(l, (int)self.hierarchy); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int close(IntPtr l) { try { LWindowBase self = (LWindowBase)checkSelf(l); self.close(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { LWindowBase o; o = new LWindowBase(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int set_hierarchy(IntPtr l) { try { LWindowBase self = (LWindowBase)checkSelf(l); WindowHierarchy v; checkEnum(l, 2, out v); self.hierarchy = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_disposeType(IntPtr l) { try { LWindowBase self = (LWindowBase)checkSelf(l); WindowDispose v; checkEnum(l, 2, out v); self.disposeType = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int open(IntPtr l) { try { LWindowBase self = (LWindowBase)checkSelf(l); System.Collections.ArrayList a1; checkType(l, 2, out a1); self.open(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public LWindowBase seekWindow(string name) { LWindowBase ret = null; foreach (var item in runningWindows) { foreach (var iitem in item.Value) { if (iitem.name == name) { ret = iitem; break; } } } return(ret); }
public void popWindow(string name) { LWindowBase win = seekWindow(name); popWindow(win); }