private GameObject AddUIPanel(string packageName, string componentName) { GameObject go = new GameObject("UIPanel"); go.layer = LayerMask.NameToLayer("UI"); UIPanel panel = go.AddComponent <UIPanel>(); panel.packageName = packageName; panel.componentName = componentName; panel.CreateUI(); return(go); }
private void Start() { initUI(); UIPackage.AddPackage("UI/" + _packageName); UIPanel uiPanel = gameObject.AddComponent <UIPanel>(); uiPanel.packageName = _packageName; uiPanel.componentName = _componentName; uiPanel.fitScreen = FitScreen.FitSize; uiPanel.CreateUI(); _view = GetComponent <UIPanel>().ui; onOpen(); }
// Use this for initialization void Start1() { //GComponent view = UIPackage.CreateObject("DialogPanel", "Main") as GComponent; UIPackage.AddPackage("DialogPanel"); gameObject.transform.position = new Vector3(0f, 0f, 0f); gameObject.AddComponent <UIPanel>(); gameObject.layer = 5; UIPanel panel = gameObject.GetComponent <UIPanel>(); panel.packageName = "DialogPanel"; panel.componentName = "Main"; panel.CreateUI(); GComponent view = panel.ui; }
/// <summary> /// FUI构建(注:每次UIPanel会毁掉之前的UI内容) /// </summary> public bool CreateFUI(string packageName, string componentName) { if (_root != null) { Debug.LogWarning("UI引擎层级已经初始化了,再次初始化无效!"); return(false); } UIPanel panel = uiPanelGo.GetComponent <UIPanel>(); panel.packageName = packageName; panel.componentName = componentName; panel.CreateUI(); InitLayers(panel.ui); return(true); }
public void ShowWindow <T>(string packageName, string componentName) where T : WindowsBasePanel { if (_curWindow != null) { UIPanel panel = _curWindow.gameObject.GetComponent <UIPanel>(); if (panel == null) { Debug.LogError("Error!!!"); } else { string curPackageName = panel.packageName; string curComponentName = panel.componentName; if (packageName == curPackageName) { if (componentName == curComponentName) { Debug.LogError("窗口已经打开"); return; } else { panel.componentName = componentName; panel.CreateUI(); DestroyImmediate(_curWindow); _curWindow = panel.gameObject.AddComponent <T>(); } } else { UIPackage.AddPackage("UI/" + packageName); _curWindow.gameObject.SetActive(false); _beforeWindow.Add(_curWindow); _curWindow = AddUIPanel(packageName, componentName).AddComponent <T>(); } } } else { _curWindow = AddUIPanel(packageName, componentName).AddComponent <T>(); } }
IEnumerator LoadUIPackage(string name, LuaFunction funct) { //string filePath = Application.streamingAssetsPath + "/" + name;//Android //string filePath = "file://" + Application.streamingAssetsPath + "/" + name;//IOS //string filePath = "file://" + Application.dataPath + "/StreamingAssets/" + name +".unity3d" ;//PC //string filePath = "file://" + Application.persistentDataPath + "/LuaFramework/" + name;//Android、IOS更新 //string filePath = "file://" + "c:/LuaFramework/" + name;//PC更新 string filePath = m_BaseDownloadingURL + name + ".unity3d"; WWW www = new WWW(filePath); yield return(www); AssetBundle bundle = www.assetBundle; UIPackage.AddPackage(bundle); GameObject g = new GameObject(name + "Panel"); g.layer = 5; UIPanel gc = g.AddComponent <UIPanel>(); gc.packageName = name + "UI"; gc.componentName = name + "Panel"; gc.container.renderMode = RenderMode.ScreenSpaceCamera; gc.SetSortingOrder(1, true); gc.SetHitTestMode(HitTestMode.Default); gc.CreateUI(); gc.gameObject.AddComponent <LuaBehaviour>(); GComponent panel = gc.ui; panel.SetSize(GRoot.inst.width, GRoot.inst.height); funct.Call(panel); }