void ChangeApplyed(object obj) { ChangePoint(textInfo); ThreadMission.InvokeToMain((o) => { InputCaret.ChangeCaret(textInfo); }, null); }
static void Decode(object mis) { Mission m = mis as Mission; m.gifdata = parseGifData(m.dat); ThreadMission.InvokeToMain(DataToTexture, m); }
void Delete(int dir) { if (DeleteSelected(textInfo)) { goto label; } if (dir < 0) { int index = textInfo.startSelect; if (index > 0) { index--; textInfo.buffer.Remove(index, 1); textInfo.startSelect = index; } } else { int index = textInfo.startSelect; if (index < textInfo.buffer.Length) { textInfo.buffer.Remove(index, 1); } } label :; textInfo.text = textInfo.buffer.FullString; textInfo.CaretStyle = 1; ThreadMission.InvokeToMain(TextChanged, textInfo, ChangeApplyed); }
internal override void OnDragEnd(UserAction action) { long r = action.EventTicks - pressTime; if (r <= ClickTime) { float x = action.CanPosition.x; float y = action.CanPosition.y; x -= RawPosition.x; x *= x; y -= RawPosition.y; y *= y; x += y; if (x < ClickArea) { return; } } textInfo.endSelect = GetPressIndex(textInfo, this, action, ref textInfo.endDock); Selected(); if (OnSelectEnd != null) { OnSelectEnd(this, action); } ThreadMission.InvokeToMain((o) => { InputCaret.ChangeCaret(textInfo); }, null); }
public override void Initial(ModelElement mod) { palette = new Palette(); callBackR = EventCallBack.RegEvent <EventCallBack>(mod); callBackR.IsCircular = true; callBackR.Drag = callBackR.DragEnd = DragingR; callBackR.PointerDown = PointDownR; NobA = mod.Find("NobA"); NobB = mod.Find("NobB"); hc = mod.Find("HTemplate"); template = hc.GetComponent <RawImageElement>(); callBackC = EventCallBack.RegEvent <EventCallBack>(hc); callBackC.Drag = callBackC.DragEnd = DragingC; callBackC.PointerDown = PointDownC; htemp = mod.GetComponent <RawImageElement>(); ThreadMission.InvokeToMain((o) => { htemp.Context.texture = Palette.LoadCTemplateAsync(); template.Context.texture = palette.texture; slider.Context.texture = Palette.AlphaTemplate(); }, null); palette.LoadHSVTAsync(1); SelectColor.a = 1; var son = mod.Find("Slider"); slider = son.GetComponent <RawImageElement>(); uISlider = new UISlider(); uISlider.Initial(son); uISlider.OnValueChanged = AlphaChanged; uISlider.Percentage = 1; }
protected override void OnDrag(UserAction action) { a++; if (a < 2) { return; } a = 0; if (Pressed) { if (TextCom != null) { if (entry) { if (action.Motion != Vector2.zero) { textInfo.CaretStyle = 2; int end = textInfo.endSelect; textInfo.endSelect = GetPressIndex(textInfo, this, action, ref textInfo.endDock); if (end != textInfo.endSelect) { Selected(); if (OnSelectChanged != null) { OnSelectChanged(this, action); } ThreadMission.InvokeToMain((o) => { InputCaret.ChangeCaret(textInfo); }, null); } } } } } }
/// <summary> /// 热更新使用此方法 /// </summary> /// <param name="func"></param> /// <param name="dat"></param> public void LoadAsync(Func <ScenePage> func, object dat) { ThreadMission.InvokeToMain((o) => { base.Apply(); ApplyScene(); Scene.ChangeScene(func(), dat); }, null); }
public void LoadAsync <T>(object dat) where T : ScenePage, new () { ThreadMission.InvokeToMain((o) => { base.Apply(); ApplyScene(); Scene.ChangeScene <T>(dat); }, null); }
/// <summary> /// /// </summary> /// <param name="dat"></param> /// <param name="tag"></param> /// <param name="callback">返回Mission</param> public static void AsyncDecode(byte[] dat, string tag, Action <object> callback) { Mission m = new Mission(); m.dat = dat; m.tag = tag; m.CallBack = callback; ThreadMission.AddMission(Decode, m, "gif"); }
public override void Initial(ModelElement parent, object dat = null) { model = ModelManagerUI.CloneModel("baseUI", "gif"); base.Initial(parent, dat); view = model.ComponentReflection <View>(); ThreadMission.InvokeToMain(LoadGif, null); view.Last.Click = (o, e) => { LoadPage <AniTestPage>(); }; view.Next.Click = (o, e) => { LoadPage <TestPage>(); }; }
static void CheckCollision(float time) { ThreadMission.AddMission((o) => { for (int i = 0; i < factories.Count; i++) { factories[i].RefreshCollider(); } UnitCollision.Collision(); }, null); }
public static void FindSpritesAsync(string bundle, string tname, string[][] names, Action <Sprite[][]> callBack) { Sprite[][] result = null; ThreadMission.InvokeToMain( (o) => { result = FindSprites(bundle, tname, names); }, null, (e) => { if (callBack != null) { callBack(result); } }); }
/// <summary> /// 主线程使用此函数 /// </summary> /// <returns></returns> public Texture2D LoadHSVTAsyncM(float h) { if (t2d == null) { t2d = new Texture2D(256, 256, TextureFormat.ARGB32, false); } ThreadMission.AddMission( (o) => { HSVTemplate(h, buffer); }, this, null, (o) => { t2d.SetPixels(buffer); t2d.Apply(); }); return(t2d); }
/// <summary> /// 多线程使用此函数 /// </summary> /// <returns></returns> public void LoadHSVTAsync(float h) { HSVTemplate(h, buffer); ThreadMission.InvokeToMain( (o) => { if (t2d == null) { t2d = new Texture2D(256, 256, TextureFormat.ARGB32, false); } t2d.SetPixels(buffer); t2d.Apply(); }, this); }
void Batch2() { if (subFrame == mainFrame) { MatCollector.renderQueue = renderQueue; LateFrame++; point = 1; max = 0; top_txt = 0; Collection(transform, -1, 0); //MainUpdate(); for (int i = 1; i < max; i++)//跳过HCanvas { var scr = scripts[i]; if (scr.LateFrame != LateFrame) { scr.LateFrame = LateFrame; scr.MainUpdate(); } else { Debug.Log("脚本重复更新"); } } Collection(transform, -1, 0); for (int i = 0; i < top_txt; i++) { texts[i].Populate(); } if (ftr)//纹理被改变了,需要重新计算 { ftr = false; HText.DirtyAll(); for (int i = 0; i < top_txt; i++) { texts[i].Populate(); } } ApplyMeshRenderer(); ApplyToCamera(); mainFrame++; if (thread == null) { thread = new ThreadMission("UI"); } thread.AddSubMission((o) => { Batch(); subFrame++; }, this); } }
static void DataToTexture(object mis) { Mission m = mis as Mission; m.gifdata.CreateNextTexture(); ThreadMission.AddMission((o) => { if (m.CallBack != null) { m.CallBack(m); } }, mis, "UI"); }
static void Decode(object mis) { Mission m = mis as Mission; m.gifdata = parseGifData(m.dat); m.count = m.gifdata.graphicsControlExtensions.Count; while (m.gifdata.DecodeNext()) { //ThreadMission.AddMission(); ThreadMission.InvokeToMain(DataToTexture, m); } //CalculColors(m.gifdata); //ThreadMission.InvokeToMain(DataToTexture,m); }
/// <summary> /// 主线程异步使用此函数 /// </summary> /// <returns></returns> public static Texture2D LoadHTemplateAsync() { if (ht2d == null) { Color[] colors = new Color[360]; ht2d = new Texture2D(1, 360, TextureFormat.ARGB32, false); ThreadMission.AddMission((o) => { HTemplate(colors); }, null, null, (o) => { ht2d.SetPixels(colors); ht2d.Apply(); }); } return(ht2d); }
/// <summary> /// 主线程访问此函数 /// </summary> /// <returns></returns> public void AwaitLoadHSVT(float h) { if (t2d == null) { t2d = new Texture2D(256, 256, TextureFormat.ARGB32, false); } ThreadMission.AddMission( (o) => { HSVTemplate(h, buffer); }, null, null, (o) => { t2d.SetPixels(buffer); t2d.Apply(); }); }
protected override void Update() { MainCanvas = this; UserAction.Update(); Keyboard.InfoCollection(); DispatchUserAction(); AnimationManage.Manage.Update(); if (UIPage.CurrentPage != null) { UIPage.CurrentPage.Update(UserAction.TimeSlice); } TextInput.Dispatch(); InputCaret.UpdateCaret(); CheckSize(); ThreadMission.ExtcuteMain(); }
void OnLostFocus(EventCallBack eventCall, UserAction action) { TextInput text = eventCall as TextInput; if (text == InputEvent) { if (InputEvent.OnSubmit != null) { InputEvent.OnSubmit(InputEvent); } InputEvent = null; } Editing = false; SetShowText(); ThreadMission.InvokeToMain((o) => { Keyboard.EndInput(); }, null); }
/// <summary> /// 主线程异步使用此函数 /// </summary> /// <returns></returns> public static Texture2D LoadCTemplateAsync() { if (ct2d == null) { Color[] colors = new Color[640 * 640]; ct2d = new Texture2D(640, 640, TextureFormat.ARGB32, false); ThreadMission.AddMission((o) => { CTemplate(colors); }, null, null, (o) => { ct2d.SetPixels(colors); ct2d.Apply(); }); } return(ct2d); }
string OnInputChanged(string input) { if (input == "") { return(""); } EmojiString es = new EmojiString(input); string str = textInfo.buffer.FilterString; if (CharacterLimit > 0) { string fs = es.FilterString; if (fs.Length + str.Length > CharacterLimit) { int len = CharacterLimit - str.Length; if (len <= 0) { return(""); } es.Remove(fs.Length - len, len); } } str = es.FullString; if (Validate(characterValidation, textInfo.text, textInfo.startSelect, str[0]) == 0) { return(""); } if (ValidateChar != null) { if (ValidateChar(this, textInfo.startSelect, str[0]) == 0) { return(""); } } DeleteSelected(textInfo); textInfo.buffer.Insert(textInfo.startSelect, es); textInfo.startSelect += es.FilterString.Length; if (OnValueChanged != null) { OnValueChanged(this); } textInfo.text = textInfo.buffer.FullString; SetShowText(); textInfo.CaretStyle = 1; ThreadMission.InvokeToMain(TextChanged, textInfo, ChangeApplyed); return(input); }
void Drag(EventCallBack callBack, UserAction action, Vector2 v) { if (drawModel == DrawModel.Brush) { CurPos = callBack.ScreenToLocal(action.CanPosition); float hx = Width * 0.5f; float hy = Height * 0.5f; if (LastPos.x <= hx & LastPos.x >= -hx) { if (LastPos.y <= hy & LastPos.y >= -hy) { DrawLine(LastPos, CurPos); ThreadMission.InvokeToMain(Apply, null); LastPos = CurPos; } } } }
public static void AsyncGetSizeY(string fontName, Vector2 designSize, int fontSize, EmojiString txt, FontStyle style, Action <Vector2> callback) { string str = txt.FilterString; Vector2 v = Vector2.zero; ThreadMission.InvokeToMain((o) => { var font = FindFont(fontName); if (font != null) { TextGenerationSettings settings = new TextGenerationSettings(); settings.resizeTextMinSize = 2; settings.resizeTextMaxSize = 40; settings.scaleFactor = 1; settings.textAnchor = TextAnchor.UpperLeft; settings.color = Color.red; settings.generationExtents = new Vector2(designSize.x, 0); settings.pivot = new Vector2(0.5f, 0.5f); settings.richText = true; settings.font = font; settings.fontSize = fontSize; settings.fontStyle = FontStyle.Normal; settings.alignByGeometry = false; settings.updateBounds = false; settings.lineSpacing = 1; settings.horizontalOverflow = HorizontalWrapMode.Wrap; settings.verticalOverflow = VerticalWrapMode.Overflow; TextGenerator generator = new TextGenerator(); v.y = generator.GetPreferredHeight(str, settings); v.x = designSize.x; if (generator.lineCount == 1) { v.x = generator.verts[generator.vertexCount - 1].position.x - generator.verts[0].position.x + 0.1f;//加0.1增加容错率 } } }, null, (o) => { if (callback != null) { callback(v); } }); }
void Drag(UserEvent callBack, UserAction action, Vector2 v) { if (drawModel == DrawModel.Brush) { CurPos = callBack.ScreenToLocal(action.CanPosition); float hx = Width * 0.5f; float hy = Height * 0.5f; if (LastPos.x <= hx & LastPos.x >= -hx) { if (LastPos.y <= hy & LastPos.y >= -hy) { Vector3 a = LastPos; Vector3 b = CurPos; ThreadMission.AddMission((o) => { DrawLine(a, b); }, null, null, Apply); LastPos = CurPos; } } } }
/// <summary> /// 更新内容包含:UI动画,UI页面更新,UI通知页更新,用户事件采集,键盘信息采集,事件派发,屏幕尺寸监测,执行分线程的委托任务 /// </summary> protected virtual void Update() { if (Pause) { return; } MainCanvas = this; AnimationManage.Manage.Update(); if (UIPage.CurrentPage != null) { UIPage.CurrentPage.Update(UserAction.TimeSlice); } UINotify.UpdateAll(UserAction.TimeSlice); UserAction.Update(); Keyboard.InfoCollection(); DispatchUserAction(); CheckSize(); ThreadMission.ExtcuteMain(); }
public override void Initial(ModelElement mod) { base.Initial(mod); model = mod; raw = model.GetComponent <RawImageElement>(); var size = model.data.sizeDelta; Width = (int)size.x; Height = (int)size.y; HalfW = Width / 2; HalfH = Height / 2; buffer = new Color[Width * Height]; gesture = EventCallBack.RegEvent <GestureEvent>(model); gesture.PointerDown = PointDown; gesture.Drag = Drag; gesture.DragEnd = DragEnd; gesture.AutoColor = false; gesture.TowFingerMove = TowFingerMove; ThreadMission.InvokeToMain(Apply, null); }
void OnClick(EventCallBack eventCall, UserAction action) { TextInput input = eventCall as TextInput; if (input == null) { return; } InputEvent = input; textInfo.startSelect = GetPressIndex(textInfo, this, action, ref textInfo.startDock); textInfo.endSelect = -1; textInfo.CaretStyle = 1; ChangePoint(textInfo); ThreadMission.InvokeToMain((o) => { bool pass = InputEvent.contentType == ContentType.Password ? true : false; Keyboard.OnInput(textInfo.text, InputEvent.touchType, InputEvent.multiLine, pass, CharacterLimit); InputCaret.SetParent(Context.Context); InputCaret.ChangeCaret(textInfo); }, null); }
void SetSelectPoint(int index) { if (index != 0) { index += textInfo.startSelect; if (index < 0) { index = 0; } if (index > textInfo.text.Length) { index = textInfo.text.Length; } } textInfo.startSelect = index; textInfo.endSelect = -1; textInfo.CaretStyle = 1; ChangePoint(textInfo); ThreadMission.InvokeToMain((o) => { InputCaret.ChangeCaret(textInfo); }, null); }