private void DoSpecialEffect() { float listCenter = list.scrollPane.posX + list.viewWidth / 2; for (int i = 0; i < list.numChildren; i++) { GObject item = list.GetChildAt(i); float itemCenter = item.x + item.width / 2; float itemWidth = item.width; float distance = Mathf.Abs(listCenter - itemCenter); if (distance < itemWidth / 2) { item.SetScale(1, 1); GButton bt = item.asButton; for (int j = 0; j < 3; j++) { if (bt.icon == UIPackage.GetItemURL("mode", "effect" + (j + 1))) { currentEffect = j; } } } else { item.SetScale(0.8f, 0.8f); } } }
//产生滚动特效事件 private void DoSpecialEffect() { //获取列表中中心位置 float listCenter = list.scrollPane.posX + list.viewWidth / 2; //遍历每个已经渲染出来的子项 //如果子项中心与列表中心的距离小于子项宽度的一半,就增大这个子项 for (int i = 0; i < list.numChildren; ++i) { GObject item = list.GetChildAt(i); float HalfOfItemWidth = item.width / 2; float itemCenter = item.x + HalfOfItemWidth; //获取子项中心与列表中心的距离 float distance = Mathf.Abs(listCenter - itemCenter); if (distance < HalfOfItemWidth) { //增大的时候注意,需要根据距离来缓慢增大,会有好的体验 float distanceRange = 1 + (1 - distance / HalfOfItemWidth) * 0.2f; //改变缩放 item.SetScale(distanceRange, distanceRange); } else { item.SetScale(1, 1); } } }
private void ResetCardIndex(GObject sender) { sender.SetScale(.7f, .7f); g_handComp.SetChildIndex(sender, _touchCardIndex); _touchCardIndex = -1; _lastTouchedCard = null; }
void DoSpecialEffect() { float midX = roleList.scrollPane.posX + roleList.viewWidth / 2; int count = roleList.numChildren; for (int i = 0; i < count; i++) { GObject obj = roleList.GetChildAt(i); float dist = Mathf.Abs(midX - obj.x - obj.width / 2); if (dist > obj.width) { obj.SetScale(1, 1); } else { float scale = 1 + (1 - dist / obj.width) * 0.25f; obj.SetScale(scale, scale); } } ShowRoleName(); }
private void DoScrollEffect() { float centerX = list.scrollPane.posX + list.viewWidth / 2; for (int i = 0; i < list.numChildren; i++) { GObject item = list.GetChildAt(i); float halfW = item.width / 2; float itemX = item.x + halfW; float dis = Mathf.Abs(centerX - itemX); if (dis < halfW) { float scale = 1 + (1 - (dis / halfW)) * 0.3f; item.SetScale(scale, scale); } else { item.SetScale(1, 1); } } }
public void SetFairyObjectScale(string _comName, float _x, float _y) { GObject tempObj = GetFairyObject(_comName); if (tempObj == null || tempObj.asCom == null) { LogError("tempObj value nil"); return; } tempObj.SetScale(_x, _y); }
void DoSpecialEffect() { //change the scale according to the distance to middle float midX = _list.scrollPane.posX + _list.viewWidth / 2; int cnt = _list.numChildren; for (int i = 0; i < cnt; i++) { GObject obj = _list.GetChildAt(i); float dist = Mathf.Abs(midX - obj.x - obj.width / 2); if (dist > obj.width) //no intersection { obj.SetScale(1, 1); } else { float ss = 1 + (1 - dist / obj.width) * 0.24f; obj.SetScale(ss, ss); } } }
private void DoSpecialEffect() { float listCenter = list.scrollPane.posX + list.viewWidth / 2; for (int i = 0; i < list.numChildren; i++) { GObject item = list.GetChildAt(i); float itemCenter = item.x + item.width / 2; float itemWidth = item.width; float distance = Mathf.Abs(listCenter - itemCenter); if (distance < itemWidth / 2) { item.SetScale(1, 1); GButton bt = item.asButton; for (int j = 0; j < 3; j++) { if (bt.icon == UIPackage.GetItemURL("Package1", "bt" + (j + 1))) { currentMode = j; if (currentMode == 0) { mainUI.GetChild("freebt").onClick.Add(() => { SceneManager.LoadScene(3); }); } else if (currentMode == 1) { mainUI.GetChild("freebt").onClick.Add(() => { SceneManager.LoadScene(4); }); } else if (currentMode == 2) { mainUI.GetChild("freebt").onClick.Add(() => { SceneManager.LoadScene(5); }); } } } } else { item.SetScale(0.8f, 0.8f); } } }
private void DoSpecialEffect() { float listCenter = list.scrollPane.posX + list.viewWidth / 2; for (int i = 0; i < list.numChildren; i++) { GObject item = list.GetChildAt(i); float itemCenter = item.x + item.width / 2; float itemWidth = item.width; float distance = Mathf.Abs(listCenter - itemCenter); if (distance < itemWidth) { float distanceRange = 1 + (1 - distance / itemWidth) * 0.2f; item.SetScale(distanceRange, distanceRange); } else { item.SetScale(1, 1); } } ShowIDInformation((list.GetFirstChildInView() + 3) % list.numItems); }
void DoSpecialEffect() { float midX = _list.scrollPane.posX + _list.viewWidth / 2; int cnt = _list.numChildren; Debug.Log("cnt ---> " + cnt); for (int i = 0; i < cnt; i++) { GObject obj = _list.GetChildAt(i); float dist = Mathf.Abs(midX - obj.x - obj.width / 2); if (dist > obj.width) { obj.SetScale(1, 1); } else { float ss = 1 + (1 - dist / obj.width) * 0.24f; obj.SetScale(ss, ss); } } _mainView.GetChild("n3").text = "" + ((_list.GetFirstChildInView() + 1) % _list.numItems); }
//处于中部的坦克放大 private void DoSpecialEffect() { float listCenter = tankList.scrollPane.posX + tankList.viewWidth / 2; for (int i = 0; i < tankList.numChildren; i++) { GObject item = tankList.GetChildAt(i); float itemCenter = item.x + item.width / 2; float itemWidth = item.width; float distance = Mathf.Abs(listCenter - itemCenter); //判断子物体是否进入放大范围(距中心一个item宽) if (distance < itemWidth) { //按照0.2的系数,依据“距离/范围”进行缩放 float distanceRange = 1 + (1 - distance / itemWidth) * 0.2f; item.SetScale(distanceRange, distanceRange); } //范围外保持原大小 else { item.SetScale(1, 1); } } }
private IEnumerator FancyHandCardEffect(GObject item, float finalScale) { int frameCount = 18; float range = item.scaleX; float step = (range - finalScale) / frameCount; float judge = Mathf.Abs(step / 2 + step); while (Mathf.Abs(range - finalScale) > judge) { range -= step; item.SetScale(range, range); yield return(null); } }