public void Initialize(System.Action initOK) { string manifestName = MonoTool.GetRuntimePlatformName() + MonoTool.GetAssetbundleSuffix(); m_fLastGCTime = Time.realtimeSinceStartup; //注意这里的 "AssetBundleManifest" 参数是和bundle文件的主bundle的manifest文件里面的AssetBundleManifest对应的,不能随意修改 LoadAsset(typeof(AssetBundleManifest), manifestName, new string[] { "AssetBundleManifest" }, (ABObject objs) => { if (objs.m_UObjectList.Count > 0) { m_AssetBundleManifest = objs.m_UObjectList[0] as AssetBundleManifest; } if (initOK != null) { initOK(); } }); }
private static T WindowCreateEX <T>(WindowBase parent, params object[] param) where T : WindowBase, new() { T win = new T(); string uifile = typeof(T).Name; if (win != null) { StringBuilder sb = Tool.StringBuilder.AppendFormat("ui/{0}" + MonoTool.GetAssetbundleSuffix(), uifile.ToLower()); string abname = sb.ToString(); sb.Clear(); win.SetLogicOpen(true); win.m_UIName = uifile; win.SetUserData(param); win.m_ABId = ResourceManager.LoadPrefab(typeof(GameObject), abname, uifile, (abobject) => { #region 异步加载UI资源回调 win.m_WinObj = (GameObject)GameObject.Instantiate(abobject.m_UObjectList[0]); win.m_WinTransform = win.m_WinObj.transform; Transform AttachObject = GetLayer(win.m_Layer); if (AttachObject == null) { UnityEngine.Debug.LogWarning("挂节点没有找到"); return; } //先将大小还原到他的父对象的局部坐标 Vector3 parentScale = AttachObject.localScale; Vector3 now = win.m_WinTransform.localScale; Vector3 childScale = new Vector3(now.x * parentScale.x, now.y * parentScale.y, now.z * parentScale.z); win.m_WinTransform.localScale = childScale; //挂接到对应的位置 RectTransform rect = win.m_WinObj.GetComponent(typeof(RectTransform)) as RectTransform; if (rect != null) { Vector3 pos = rect.anchoredPosition3D; Quaternion rotation = rect.localRotation; Vector3 scale = rect.localScale; Vector2 offsetMax = rect.offsetMax; Vector2 offsetMin = rect.offsetMin; win.m_WinTransform.SetParent(AttachObject); rect.anchoredPosition3D = pos; rect.localRotation = rotation; rect.localScale = scale; rect.offsetMax = offsetMax; rect.offsetMin = offsetMin; } win.m_WindowPos = win.m_WinTransform.position; win.ShowWindowObj(); //设置该layer下面层级 List <WindowBase> wins = GetWindowsByLayer(win.m_Layer); SortLayerWindows(wins, win.m_Layer); win.m_WindowPos = win.m_WinTransform.position; win.DoWindowDataBind(); #endregion }); if (parent != null) { parent.AddChild(win); } m_OpenedList.Add(win); //添加逻辑窗口和层的对应关系 List <WindowBase> winList = GetWindowsByLayer(win.m_Layer); if (winList != null) { winList = AddWindowToParentLast(winList, win, parent); } else { winList = new List <WindowBase>(); winList = AddWindowToParentLast(winList, win, parent); m_LayerWindows.Add((int)win.m_Layer, winList); } return(win); } else { UnityEngine.Debug.LogError("打开的窗口不存在," + uifile); } return(null); }