/// <summary> /// 当前脚本挂载时调用一次 父类Init方法可调用当前方法 /// </summary> public override void BindVariables() { //如果当前绑定变量名列表有值 if (this.paramBinds != null && this.paramBinds.Length > 0) { this.variableList = new UIVariable[this.paramBinds.Length]; for (int i = 0; i < this.paramBinds.Length; i++) { //paramBinds存的是变量的名称 string text = this.paramBinds[i]; if (!string.IsNullOrEmpty(text)) {//拿到所有的变量 UIVariable uIVariable = base.FindVariable(text); if (uIVariable == null) { //Debug.Log(name + "can not find a variable " + text); } else { //将刷新text的方法 挂载到 变量初始化的的回调上 uIVariable.OnValueInitialized += new Action(this.SetFormat); //将刷新text的方法 挂载到 变量改变的回调上 uIVariable.OnValueChanged += new Action(this.SetFormat); //uIVariable.AddBind(this); //给当前的variableList变量列表赋值 this.variableList[i] = uIVariable; } } } //刷新一次text this.SetFormat(); } }
public static void FireEvent(string key, UIVariable variable) { if (eventAction.ContainsKey(key)) { eventAction[key](variable); } }
public void __Gen_Delegate_Imp2(UIVariable p0) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.rawL; int err_func = LuaAPI.load_error_func(L, errorFuncRef); ObjectTranslator translator = luaEnv.translator; LuaAPI.lua_getref(L, luaReference); translator.Push(L, p0); int __gen_error = LuaAPI.lua_pcall(L, 1, 0, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_settop(L, err_func - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
public ImageEditor(string name, string initArg, CGRect rect) : base(UIType.CUSTOM, name) { m_data = initArg; m_rect = rect; m_sfImageEditor = new SfImageEditor(m_rect); m_sfImageEditor.ImageSaved += (sender, args) => { if (!string.IsNullOrEmpty(m_actionDoneEdit)) { UIVariable.GetAction(m_actionDoneEdit, WidgetName, "\"" + args.Location + "\""); } m_editing = false; }; m_sfImageEditor.EndReset += (sender, args) => { if (m_editing) { if (!string.IsNullOrEmpty(m_actionDoneEdit)) { UIVariable.GetAction(m_actionDoneEdit, WidgetName, ""); } //ActionDelegate?.Invoke(WidgetName, ""); m_editing = false; } }; m_sfImageEditor.Hidden = true; ViewX = m_sfImageEditor; }
public ImageEditor(string name, string text, Context context, int width = 0, int height = 0) : base(UIType.CUSTOM, name) { m_data = text; Context = context; m_width = width; m_height = height; Editor = new SfImageEditor(Context); Editor.ImageSaved += (sender, args) => { if (!string.IsNullOrEmpty(m_actionDoneEdit)) { UIVariable.GetAction(m_actionDoneEdit, WidgetName, args.Location); } m_editing = false; }; Editor.EndReset += (sender, args) => { if (m_editing) { if (!string.IsNullOrEmpty(m_actionDoneEdit)) { UIVariable.GetAction(m_actionDoneEdit, WidgetName, ""); } //ActionDelegate?.Invoke(WidgetName, ""); m_editing = false; } }; Editor.Visibility = ViewStates.Invisible; ViewX = Editor; Instance = this; }
/// <summary> /// 编辑器状态下刷新变量字典 /// </summary> public void FlushVariableDic() { //字典根据键进行排序 if (this.variables != null) { if (variableDic == null) { this.variableDic = new Dictionary <string, UIVariable>(StringComparer.Ordinal); } variableDic.Clear(); repeatVar.Clear(); tempList = this.variables; for (int i = 0; i < tempList.Length; i++) { tmp = tempList[i]; if (variableDic.ContainsKey(tmp.Name)) { repeatVar.Add(tmp.Name); } else { this.variableDic.Add(tmp.Name, tmp); } } } }
public override void AddAction(string varName, string strAction, string argument = "") { ActionDelegate += (arg1, arg2) => { UIVariable.GetAction(strAction, varName, "\"" + arg2 + "\""); }; }
/// <summary> /// 外部修改绑定的变量列表时调用刷新文本 /// </summary> public void SetFormat() { if (this.UIText == null) { this.UIText = base.GetComponent <Text>(); } if (UIText == null || paramBinds == null || variableList == null) { return; } //如果当前format是空的 只显示参数列表第一个参数的值 if (string.IsNullOrEmpty(this.format)) { //且参数名列表不为空 if (this.paramBinds.Length > 0) { //拿到当前变量列表第一个 UIVariable uIVariable = this.variableList[0]; if (uIVariable != null) {//如果不为空 拿到当前变量的 值 object valueObject = uIVariable.ValueObject; if (valueObject != null) { //如果有值 this.UIText.text = valueObject.ToString(); } } else { this.UIText.text = ""; } } } else { //如果format 不为空 object[] array = new object[this.paramBinds.Length]; for (int i = 0; i < this.paramBinds.Length; i++) {//拿到所有变量 UIVariable uIVariable2 = this.variableList[i]; if (uIVariable2 != null) {//拿到所有变量的值 array[i] = uIVariable2.ValueObject; } } try {//尝试按照format格式进行组合 tmp = this.format; if (Regex.Matches(tmp, "{").Count % 2 == 1 && Regex.Matches(tmp, "{").Count != Regex.Matches(tmp, "}").Count) { tmp = tmp.Replace("{", "{{"); } this.UIText.text = string.Format(tmp, array); } catch (FormatException ex) {//如果失败 抛出异常 if (Application.isPlaying) { Debug.Log(ex.Message, this); } } } }
/// <inheritdoc/> protected override void UnbindVariables() { if (m_Variable != null) { m_Variable.OnValueChanged -= OnValueChanged; m_Variable = null; } }
public override void LoadCallBack() { Debug.Log("LoadCallBack"); ListenEvent("Click", Click); ListenEvent("ClickClose", ClickClose); text = FindVariable("text"); text.SetVlaue("这是主界面"); }
public void ExecuteAction(string arg) { Tuple <string, string> action; if (m_actions.TryGetValue(Name, out action)) { UIVariable.GetAction(action.Item1, action.Item2, arg); } }
public virtual void AddData(List <string> data, string varName, string title, string extra) { if (ViewX is UIPickerView) { UIPickerView pickerView = ViewX as UIPickerView; TypePickerViewModel model = pickerView.Model as TypePickerViewModel; if (model == null) { model = new TypePickerViewModel(AppDelegate.GetCurrentController()); } model.Data = data; if (!string.IsNullOrWhiteSpace(title)) { model.RowSelected += (row) => { UIVariable.GetAction(title, varName, row.ToString()); }; } if (!string.IsNullOrWhiteSpace(extra)) { var al = UtilsiOS.GetAlignment(extra); model.Alignment = al.Item2; } model.SetSize((int)pickerView.Bounds.Width, (int)pickerView.Bounds.Height / 4); pickerView.Model = model; } else if (ViewX is UITableView) { UITableView tableView = ViewX as UITableView; TableViewSource source = tableView.Source as TableViewSource; if (source == null) { source = new TableViewSource(); } source.Data = data; tableView.Source = source; tableView.ReloadData(); } else if (m_picker != null) { TypePickerViewModel model = m_picker.Model as TypePickerViewModel; model.Data = data; if (!string.IsNullOrEmpty(extra)) { Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al = UtilsiOS.GetAlignment(extra); model.Alignment = al.Item2; } m_picker.Model = model; SetText(data[0], extra, true /* triggered */); } }
protected override void BindVariables() { if (string.IsNullOrEmpty(m_VariableName)) { return; } m_Variable = FindVariable(m_VariableName); if (m_Variable != null) { m_Variable.OnValueChanged += OnValueChanged; } OnValueChanged(); }
public static void RunOnMainThread(string strAction, string arg1, string arg2 = null, string arg3 = null) { #if __ANDROID__ scripting.Droid.MainActivity.TheView.RunOnUiThread(() => { #elif __IOS__ scripting.iOS.AppDelegate.GetCurrentController().InvokeOnMainThread(() => { #endif UIVariable.GetAction(strAction, arg1, arg2, arg3); #if __ANDROID__ || __IOS__ }); #endif }
/// <summary> /// 添加变量 /// </summary> public void AddDefaultVariable() { UIVariable uIVariable = new UIVariable(); if (this.variables == null) { this.variables = new UIVariable[1]; this.variables[0] = uIVariable; } else { //将元素添加至数组最后一位 ArrayUtility.Add <UIVariable>(ref this.variables, uIVariable); } }
public static void RegisterCallbacks(string strAction) { OnIAPOK = null; OnIAPError = null; InAppBilling.OnIAPOK += (productIds) => { UIVariable.GetAction(strAction, "", productIds); }; InAppBilling.OnIAPError += (errorStr) => { UIVariable.GetAction(strAction, errorStr, ""); }; s_prevAction = strAction; }
void ImagePicker_FinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e) { m_imagePicker.DismissModalViewController(true); var path = e.MediaUrl; m_sfImageEditor.Image = e.OriginalImage; m_sfImageEditor.Hidden = false; m_editing = true; if (!string.IsNullOrEmpty(m_actionStarting)) { UIVariable.GetAction(m_actionStarting, WidgetName, ""); } //AppDelegate.GetCurrentController().ShowViewController( // new ImageEditorViewController(e.OriginalImage), null); }
public override void LoadCallBack() { Debug.Log("LoadCallBack"); ListenEvent("Click", Click); ListenEvent("ClickClose", ClickClose); text = FindVariable("text"); tab1 = FindObj("Tab1"); tab2 = FindObj("Tab2"); tab3 = FindObj("Tab3"); AddToggleValueChangedListener(tab1, OnToggleChange, (int)TabIndex.Test1View); AddToggleValueChangedListener(tab2, OnToggleChange, (int)TabIndex.Test2View); AddToggleValueChangedListener(tab3, OnToggleChange, (int)TabIndex.Test3View); GameObject tab1_obj = FindObj("Tab1Content"); GameObject tab2_obj = FindObj("Tab2Content"); GameObject tab3_obj = FindObj("Tab3Content"); tab1_obj.GetComponent <UIPrefabLoader>().Wait( (obj) => { tab1_view = new Tab1View(obj); }); tab2_obj.GetComponent <UIPrefabLoader>().Wait( (obj) => { tab2_view = new Tab2View(obj); }); tab3_obj.GetComponent <UIPrefabLoader>().Wait( (obj) => { tab3_view = new Tab3View(obj); }); // local inlay_content = self:FindObj("Tab1") //inlay_content.uiprefab_loader:Wait(function(obj) // obj = U3DObject(obj) // self.inlay_view = RuneInlayView.New(obj) // self.inlay_view:InitView() //end) }
//将变量存储 private Dictionary <string, UIVariable> GetVariableDic() { if (this.variableDic == null) { //字典根据键进行排序 this.variableDic = new Dictionary <string, UIVariable>(StringComparer.Ordinal); if (this.variables != null) { UIVariable[] array = this.variables; for (int i = 0; i < array.Length; i++) { UIVariable uIVariable = array[i]; this.variableDic.Add(uIVariable.Name, uIVariable); } } } return(this.variableDic); }
/// <summary> /// 解绑变量 销毁时调用 /// </summary> public override void UnbindVariables() { if (this.variableList != null) { UIVariable[] array = this.variableList; for (int i = 0; i < array.Length; i++) { UIVariable uIVariable = array[i]; if (uIVariable != null) { uIVariable.OnValueChanged -= new Action(this.SetFormat); uIVariable.OnValueInitialized -= new Action(this.SetFormat); //uIVariable.RemoveBind(this); } } this.variableList = null; } }
public static void OnActivityResult(int requestCode, Result resultCode, Intent data) { if (data == null) { data = mainIntent; } if ((resultCode != Result.Ok) || (data == null)) { return; } if (resultCode == Result.Ok) { var uri = data.Data; ImageEditor.Instance.m_editing = true; if (!string.IsNullOrEmpty(ImageEditor.Instance.m_actionStarting)) { UIVariable.GetAction(ImageEditor.Instance.m_actionStarting, ImageEditor.Instance.WidgetName, ""); } if (requestCode == SELECT_FROM_GALLERY) { try { ImageEditor.Instance.Path = GetPathToImage(uri); ImageEditor.Instance.Editor.Bitmap = BitmapFactory.DecodeFile(ImageEditor.Instance.Path); //MainActivity.TheView.StartActivity(typeof(SfImageEditorActivity)); } catch (Exception ex) { System.Console.WriteLine("Exception: " + ex); } } else if (requestCode == SELECT_FROM_CAMERA) { try { mainIntent.PutExtra("image-path", m_imageCaptureUri.Path); mainIntent.PutExtra("scale", true); ImageEditor.Instance.Path = m_imageCaptureUri.Path; ImageEditor.Instance.Editor.Bitmap = BitmapFactory.DecodeFile(ImageEditor.Instance.Path); //MainActivity.TheView.StartActivity(typeof(SfImageEditorActivity)); } catch (Exception ex) { System.Console.WriteLine("Exception: " + ex); } } } }
static int _m_GetVariable(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UIVariableTable gen_to_be_invoked = (UIVariableTable)translator.FastGetCSObj(L, 1); { int _index = LuaAPI.xlua_tointeger(L, 2); UIVariable gen_ret = gen_to_be_invoked.GetVariable(_index); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public virtual void AddAction(string varName, string strAction, string argument = "") { if (!string.IsNullOrWhiteSpace(argument)) { if (argument.Equals("FINISHED")) { if (ViewX is ListView) { ListView listView = ViewX as ListView; listView.NothingSelected += (sender, e) => { UIVariable.GetAction(strAction, varName, ""); }; } return; } } if (string.IsNullOrWhiteSpace(strAction)) { return; } if (ViewX is Button) { Button button = ViewX as Button; button.Click += (sender, e) => { UIVariable.GetAction(strAction, varName, argument); }; } else if (ViewX is EditText) { if (argument.Equals("FINISHED")) { } else { EditText editText = ViewX as EditText; editText.TextChanged += (sender, e) => { UIVariable.GetAction(strAction, varName, e.Text.ToString()); }; } } else if (ViewX is Switch) { Switch sw = ViewX as Switch; sw.CheckedChange += (sender, e) => { UIVariable.GetAction(strAction, varName, e.ToString()); }; } else if (ViewX is SeekBar) { SeekBar slider = ViewX as SeekBar; slider.ProgressChanged += (sender, e) => { UIVariable.GetAction(strAction, varName, e.Progress.ToString()); }; } else if (ViewX is NumberPicker) { NumberPicker pickerView = ViewX as NumberPicker; pickerView.ValueChanged += (sender, e) => { UIVariable.GetAction(strAction, varName, e.NewVal.ToString()); }; } else if (ViewX is Spinner) { Spinner spinner = ViewX as Spinner; spinner.ItemSelected += (sender, e) => { var adapter = spinner.Adapter as TextImageAdapter; var item = adapter != null?adapter.Position2Text(e.Position) : ""; UIVariable.GetAction(strAction, varName, item); }; } else if (ViewX is ListView) { ListView listView = ViewX as ListView; listView.ItemClick += (sender, e) => { UIVariable.GetAction(strAction, varName, e.Position.ToString()); }; } else { ActionDelegate += (arg1, arg2) => { UIVariable.GetAction(strAction, varName, arg2); }; } m_actions[Name] = new Tuple <string, string>(strAction, varName); }
public DroidVariable(UIType type, string name, UIVariable refViewX, UIVariable refViewY = null) : base(type, name, refViewX, refViewY) { }
public override void ReleaseCallBack() { Debug.Log("ReleaseCallBack"); text = null; }
public virtual void AddAction(string varName, string strAction, string argument = "") { if (!string.IsNullOrWhiteSpace(argument)) { if (argument.Equals("FINISHED")) { if (ViewX is UITextField) { UITextField textField = ViewX as UITextField; textField.EditingDidEnd += (sender, e) => { UIVariable.GetAction(strAction, varName, "\"" + textField.Text + "\""); }; } return; } } if (WidgetType == UIVariable.UIType.COMBOBOX) { ActionDelegate += (arg1, arg2) => { UIVariable.GetAction(strAction, arg1, "\"" + arg2 + "\""); }; } else if (ViewX is UIButton) { UIButton button = ViewX as UIButton; button.TouchUpInside += (sender, e) => { UIVariable.GetAction(strAction, varName, "\"" + argument + "\""); }; } else if (ViewX is UISwitch) { UISwitch sw = ViewX as UISwitch; sw.ValueChanged += (sender, e) => { UIVariable.GetAction(strAction, varName, "\"" + sw.On + "\""); }; } else if (ViewX is UITextField) { UITextField textField = ViewX as UITextField; textField.EditingChanged += (sender, e) => { UIVariable.GetAction(strAction, varName, "\"" + textField.Text + "\""); }; } else if (ViewX is UISlider) { UISlider slider = ViewX as UISlider; slider.ValueChanged += (sender, e) => { UIVariable.GetAction(strAction, varName, "\"" + slider.Value + "\""); }; } else if (ViewX is UISegmentedControl) { UISegmentedControl seg = ViewX as UISegmentedControl; seg.ValueChanged += (sender, e) => { UIVariable.GetAction(strAction, varName, "\"" + seg.SelectedSegment + "\""); }; } else if (ViewX is UIPickerView) { UIPickerView pickerView = ViewX as UIPickerView; TypePickerViewModel model = pickerView.Model as TypePickerViewModel; if (model == null) { model = new TypePickerViewModel(AppDelegate.GetCurrentController()); } model.RowSelected += (row) => { UIVariable.GetAction(strAction, varName, row.ToString()); }; pickerView.Model = model; } else if (ViewX is UITableView) { UITableView tableView = ViewX as UITableView; TableViewSource source = tableView.Source as TableViewSource; if (source == null) { source = new TableViewSource(); } source.RowSelectedDel += (row) => { UIVariable.GetAction(strAction, varName, "\"" + row + "\""); }; tableView.Source = source; } else { ActionDelegate += (arg1, arg2) => { UIVariable.GetAction(strAction, varName, "\"" + arg2 + "\""); }; } }
public static void RegisterWidget(UIVariable widget, Rect rect, string parent = "", int tabId = 0) { RegisterWidget(widget.Name, rect, parent, tabId); ParserFunction.AddGlobal(widget.Name, new GetVarFunction(widget)); }
protected override void Start() { UIVariable name = variableTable.FindVariable("ddddd"); //print(name.name); name.SetVlaue("测试一"); cube = nameTable.FindObj("cube"); cube.SetActive(false); //table.ListenEvent("Click", Click); //table.ListenEvent("ClickThree", ClickThree); // GlobalEventSystem.Bind(GlobalEventType.test, ClickThree); // GlobalEventSystem.Bind(GlobalEventType.test2, ClickTwo); //TimeControl timer = TimeControl.CreaterTimer(); //timer.StartTiming(10, Complete, Func, 3, true, false, true); string path = IPathTool.GetAssetBundlePath();//.Substring(IPathTool.GetAssetBundlePath().IndexOf("Assets")); //路径/斜 //AssetBundle ab = AssetBundle.LoadFromFile(Application.dataPath + @"/StreamingAssets/Windows/sceneone/one/cube.unity3d"); //Debug.Log(Application.dataPath + @"/StreamingAssets/Windows/sceneone/one/cube.unity3d"); //Debug.Log(IPathTool.GetAssetBundlePath()); //IABResLoader abloader = new IABResLoader(ab); // GameObject ob = abloader["Cube"] as GameObject; //Instantiate(ob, transform); //abloader.Dispose(); //abScene.LoadAsset("Cube.prefab", ClickTwo, Complete); //abLoader = new IABLoader(path); // print(path); //abLoader.OnLoadFinish(Click); //abLoader.OnLoad(ClickTwo); //StartCoroutine(abLoader.CommonLoad()); //print(IPathTool.GetWWWAssetBundlePath() +"/" + "sceneone/one/cube.unity3d"); //ab = new IABLoader(bundleName, Complete1, null); //StartCoroutine(ab.CommonLoad()); // relation = new IABRelationManager(bundleName, Complete); //StartCoroutine(relation.LoadAssetBundle()); //manifest = new IABManifestLoader(Complect3); //StartCoroutine(manifest.LoadManifet()); //string sceneName = "SceneOne"; //IABScenceManager abScene = new IABScenceManager(sceneName); //abScene.ReadConfiger(sceneName); IABManifestLoader manifest = new IABManifestLoader(ManifestLoadComplete); StartCoroutine(manifest.LoadManifet()); }