public T createWindow <T>(string name, txUIObject parent) where T : txUIObject, new() { txUIObject window = null; Type type = typeof(T); // 从未使用列表中获取 if (mUnusedList.ContainsKey(type) && mUnusedList[type].Count > 0) { window = mUnusedList[type][mUnusedList[type].Count - 1]; mUnusedList[type].RemoveAt(mUnusedList[type].Count - 1); } // 未使用列表中没有就创建新窗口 if (window == null) { window = mScript.createObject <T>(name); } // 加入到已使用列表中 if (!mInusedList.ContainsKey(type)) { mInusedList.Add(type, new List <txUIObject>()); } mInusedList[type].Add(window); window.setActive(true); window.setName(name); window.setParent(parent); return(window as T); }