标签:
背景:
AR卡项目中,需要在识别出的模型上加上升级时粒子效果,需要在生成模型的位置最上层出粒子效果。
然后粒子飞向进度条,实现升级。
关键方法及注意事项:
Camera.WorldToScreenPoint Unity官方文档
//根据Canvas的设置,转换出uGUI可使用的坐标
public Vector2 GetUIPosByScreen(Vector2 screenPos) { Vector2 v = Vector2.zero; v.x = screenPos.x * 2048f/Screen.width; v.y = screenPos.y * 1536f/Screen.height; return v; }
public void PlayLevelUpAnimation(Vector2 v) { Debug.Log("v: " + v); Card.anchoredPosition = GetUIPosByScreen(v); GameObject levelUpParticle = Instantiate(Resources.Load("FX/LevelUp/E_Candel_B") as GameObject); levelUpParticle.transform.SetParent(Card); levelUpParticle.transform.localPosition = new Vector3(0f, 0f, -45f); Card.gameObject.SetActive(true); Tweener moveChou = Card.DOLocalMove(expSlider.transform.localPosition, 6.2f); moveChou.OnComplete(()=>{ Card.gameObject.SetActive(false); }); }
Camera.main.WorldToScreenPoint注意事项
标签:
原文地址:http://www.cnblogs.com/xuanll/p/5249805.html