public UIMediator(string mediatorName, UIControlData ctrlData) : base(mediatorName, null) { if (ctrlData != null) { ctrlData.BindDataTo(this); } }
public override void OnInspectorGUI() { UIControlData data = target as UIControlData; if (data.controls == null) { data.controls = new List <ControlItem>(); data.controls.Add(new ControlItem()); } _controls = data.controls; CheckDrawers(); EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("控件绑定", skin.customStyles[0]); for (int i = 0, imax = _drawers.Count; i < imax; i++) { GUILayout.Space(10f); if (!_drawers[i].Draw()) { Repaint(); return; } GUILayout.Space(10f); } // 如果有拖放则添加一个新的控件 GUILayout.Space(10f); EditorGUILayout.EndVertical(); this.Repaint(); }
public LuaTable BindLua(string viewClassName) { this.viewClassName = viewClassName; ClearLua(); if (!LoadLuaCode()) { return(luaUI); } UIControlData ctrl = GetComponent <UIControlData>(); //创建成功并初始化子节点后调用Init,给lua初始化变量的机会 if (ctrl != null) { ctrl.BindDataToLua(this, luaUI); } if (_lua_Initialize != null) { Debug.Log("_lua_Initialize -- successed--" + viewClassName); _lua_Initialize.Func <LuaTable, LuaTable>(luaUI); } else { Debug.Log("_lua_Initialize -- failed--" + viewClassName); } if (_lua_GetUIType != null) { UILayer = _lua_GetLayer.Func <LuaTable, UI_LAYER>(luaUI); } return(luaUI); }
public CBLuaPanel(string file, LuaTable v, UIControlData uiControlData) { _file = file; _table = v; _table.Get("OnReady", out m_OnReady); _table.Get("OnHiding", out m_OnHiding); _table.Get("OnDispose", out m_OnDispose); uiControlData.BindDataToLua(this, _table); }
public PassportMediator( AppSetting setting, SaveService saveService, IAudioService audioService, UIControlData viewComponent) : base(TypeName, viewComponent) { this.audioService = audioService; this.saveService = saveService; this.setting = setting; this.passportVo = new PassportVo(); }
private IWindowBase CreateWindow(UGUI_TYPE uiType) { UIData uicfg = GetUIDataByUIType(uiType); if (uicfg == null) { Debug.LogErrorFormat("ui type {0} cfg is empty", uiType.ToString()); return(null); } GameObject windowObj; Debug.LogError("prefa name " + uicfg.PrefabName); var prefab = Resources.Load <GameObject>(uicfg.PrefabName); //根据项目具体调整 windowObj = GameObject.Instantiate(prefab, transform); if (windowObj == null) { Debug.LogErrorFormat("ui type {0} prefab is null", uiType.ToString()); return(null); } windowObj.transform.position = Vector3.zero; Type scriptType = Type.GetType(uicfg.ScriptName); if (scriptType == null || scriptType.GetInterface("IWindowBase") == null) { Debug.LogErrorFormat("ui type {0} not have IWindowBase attach", uiType.ToString()); return(null); } var scaler = windowObj.GetComponent <CanvasScaler>(); if (scaler != null) { scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand; //屏幕的适应方式 scaler.referenceResolution = new Vector2(1280, 720); } IWindowBase uiwindow = windowObj.AddComponent(scriptType) as IWindowBase; UIControlData ctrlData = windowObj.GetComponent <UIControlData>(); if (ctrlData != null) { ctrlData.BindDataTo(uiwindow); } windowObj.SetActive(false); m_loadedWindow.Add(uiType, uiwindow); return(uiwindow); }
private CBLuaPanel GetLuaPanel(string key, UIControlData uiControlData) { string luaPath = UIPathHelper.GetLuaPath(key); LuaTable scriptEnv = NgameLua.Load(luaPath); if (scriptEnv == null) { return(null); } CBLuaPanel pnl = new CBLuaPanel(luaPath, scriptEnv, uiControlData); return(pnl); }
void Start() { // TODO get config from xml IBindableUI uiA = Activator.CreateInstance(Type.GetType("UIA")) as IBindableUI; GameObject prefab = Resources.Load <GameObject>("UI/UIA"); GameObject go = Instantiate(prefab); UIControlData ctrlData = go.GetComponent <UIControlData>(); if (ctrlData != null) { ctrlData.BindDataTo(uiA); } (uiA as UIA).CheckBinding(); }
void Start() { // TODO get config from xml UIA uiA = new UIA(); GameObject prefab = Resources.Load <GameObject>("UI/UIA"); GameObject go = Instantiate(prefab); UIControlData ctrlData = go.GetComponent <UIControlData>(); if (ctrlData != null) { ctrlData.BindAllFields(uiA); } uiA.CheckBinding(); }
private void OnDestroy() { UIControlData.UnBindUI(gameObject); ClearLua(); }
public HomeMediator(NetService netService, UIControlData viewComponent) : base(TypeName, viewComponent) { this.net = netService; }
/// <summary> /// 加载指定名称的“UI窗体” /// 功能: /// 1:根据“UI窗体名称”,加载预设克隆体。 /// 2:根据不同预设克隆体中带的脚本中不同的“位置信息”,加载到“根窗体”下不同的节点。 /// 3:隐藏刚创建的UI克隆体。 /// 4:把克隆体,加入到“所有UI窗体”(缓存)集合中。 /// /// </summary> /// <param name="uiFormName">UI窗体名称</param> private BaseUIForm LoadUIForm(string uiFormName) { string strUIFormPaths = uiFormName; //UI窗体路径 GameObject goCloneUIPrefabs = null; //创建的UI克隆体预设 BaseUIForm baseUiForm = null; //窗体基类 //根据UI窗体名称,得到对应的加载路径 //_DicFormsPaths.TryGetValue(uiFormName, out strUIFormPaths); //根据“UI窗体名称”,加载“预设克隆体” if (!string.IsNullOrEmpty(strUIFormPaths)) { goCloneUIPrefabs = OpenUIPanel(strUIFormPaths); } UIControlData ctrlData = goCloneUIPrefabs.GetComponent <UIControlData>(); CBLuaPanel luaPanel = GetLuaPanel(uiFormName, ctrlData); if (luaPanel == null) { //C# 脚本逻辑 IBindableUI uiA = Activator.CreateInstance(Type.GetType(uiFormName)) as IBindableUI; baseUiForm = uiA as BaseUIForm; } else { //Lua 逻辑 baseUiForm = luaPanel as BaseUIForm; } baseUiForm.Source = goCloneUIPrefabs; if (ctrlData != null) { ctrlData.BindDataTo(baseUiForm); } //设置“UI克隆体”的父节点(根据克隆体中带的脚本中不同的“位置信息”) if (_TraCanvasTransfrom != null && goCloneUIPrefabs != null) { //baseUiForm = goCloneUIPrefabs.GetComponent<BaseUIForm>(); if (baseUiForm == null) { Debug.Log("baseUiForm==null! ,请先确认窗体预设对象上是否加载了baseUIForm的子类脚本! 参数 uiFormName=" + uiFormName); return(null); } baseUiForm.OnReady(); switch (baseUiForm.CurrentUIType.UIForms_Type) { case UIFormType.Normal: //普通窗体节点 goCloneUIPrefabs.transform.SetParent(_TraNormal, false); break; case UIFormType.Fixed: //固定窗体节点 goCloneUIPrefabs.transform.SetParent(_TraFixed, false); break; case UIFormType.PopUp: //弹出窗体节点 goCloneUIPrefabs.transform.SetParent(_TraPopUp, false); break; default: break; } //设置隐藏 goCloneUIPrefabs.SetActive(false); //把克隆体,加入到“所有UI窗体”(缓存)集合中。 _DicALLUIForms.Add(uiFormName, baseUiForm); return(baseUiForm); } else { Debug.Log("_TraCanvasTransfrom==null Or goCloneUIPrefabs==null!! ,Plese Check!, 参数uiFormName=" + uiFormName); } Debug.Log("出现不可以预估的错误,请检查,参数 uiFormName=" + uiFormName); return(null); }//Mehtod_end