void Start() { Application.targetFrameRate = 60; Stage.inst.onKeyDown.Add(OnKeyDown); _mainView = this.GetComponent <UIPanel>().ui; _guideLayer = UIPackage.CreateObject("Guide", "GuideLayer").asCom; _guideLayer.SetSize(GRoot.inst.width, GRoot.inst.height); _guideLayer.AddRelation(GRoot.inst, RelationType.Size); GObject bagBtn = _mainView.GetChild("bagBtn"); bagBtn.onClick.Add(() => { _guideLayer.RemoveFromParent(); }); _mainView.GetChild("n2").onClick.Add(() => { GRoot.inst.AddChild(_guideLayer); //!!Before using GlobalToLocal, the object must be added first Rect rect = bagBtn.TransformRect(new Rect(0, 0, bagBtn.width, bagBtn.height), _guideLayer); GObject window = _guideLayer.GetChild("window"); window.size = new Vector2((int)rect.size.x, (int)rect.size.y); window.TweenMove(new Vector2((int)rect.position.x, (int)rect.position.y), 0.5f); }); }
void Start() { Application.targetFrameRate = 60; GRoot.inst.SetContentScaleFactor(1136, 640); Stage.inst.onKeyDown.Add(OnKeyDown); UIPackage.AddPackage("UI/Guide"); _mainView = UIPackage.CreateObject("Guide", "Main").asCom; _mainView.fairyBatching = true; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _guideLayer = UIPackage.CreateObject("Guide", "GuideLayer").asCom; _guideLayer.SetSize(GRoot.inst.width, GRoot.inst.height); _guideLayer.AddRelation(GRoot.inst, RelationType.Size); GObject bagBtn = _mainView.GetChild("bagBtn"); bagBtn.onClick.Add(() => { _guideLayer.RemoveFromParent(); }); _mainView.GetChild("n2").onClick.Add(() => { Rect rect = bagBtn.LocalToGlobal(new Rect(0, 0, bagBtn.width, bagBtn.height)); GRoot.inst.AddChild(_guideLayer); //!!Before using GlobalToLocal, the object must be added first rect = bagBtn.TransformRect(new Rect(0, 0, bagBtn.width, bagBtn.height), _guideLayer); GObject window = _guideLayer.GetChild("window"); window.size = new Vector2((int)rect.size.x, (int)rect.size.y); window.TweenMove(new Vector2((int)rect.position.x, (int)rect.position.y), 0.5f); }); }
public void Movesize(GObject parent, GObject gameObject, Vector2 sd, Vector2 pos, float time) { parent.position = sd; parent.visible = true; GTween.Kill(dosettw); GTween.Kill(movesizepar); dosettw = parent.TweenResize(gameObject.size, time); movesizepar = parent.TweenMove(pos, time).OnComplete(() => { gameObject.visible = true; parent.visible = false; }); }
private void OnTouchEnd(EventContext context) { InputEvent inputEvent = (InputEvent)context.data; if (touchID != -1 && inputEvent.touchId == touchID) { touchID = -1; center.visible = false; tweener = thumb.TweenMove(GetReduceHalfWHPos(initPos, thumb), 0.3f).OnComplete(() => { SetCenterPosXY(center, initPos); center.visible = true; thumb.rotation = 0; thumb.visible = false; }); // Debug.Log("===============>TouchEnd"); } onEnd.Call(); }
private void OnTouchUp(EventContext context) { InputEvent evt = (InputEvent)context.data; if (touchId != -1 && touchId == evt.touchId) { touchId = -1; } _tweener = _thumb.TweenMove(new Vector2(_bg.x + _bg.width / 2 - _thumb.width / 2, _bg.y + _bg.height / 2 - _thumb.height / 2), 0.2f).OnComplete(() => { _tweener = null; _bg.alpha = 1; _bg.x = _origPos.x; _bg.y = _origPos.y; _thumb.x = _bg.x + _bg.width / 2 - _thumb.width / 2; _thumb.y = _bg.y + _bg.height / 2 - _thumb.height / 2; }); Stage.inst.onTouchMove.Remove(this.OnTouchMove); Stage.inst.onTouchEnd.Remove(this.OnTouchUp); }