将实例化与精益补间相结合

Combine instantiate with lean tween

我想使用精益补间缩放一个对象,但我也只是实例化它。

如何组合下面的代码行?换句话说,我想在实例化预制件时 scale/animate。

//this line instantiates the Gem
gemList1.Add(Instantiate(Gem, new Vector2((xPos_Hole1 + (Random.Range(-20, 20))) * 2.0F, (-229 + (20 * i))), Quaternion.identity));

//This line animates the GEM by scaling it
LeanTween.scale(Gem, new Vector3(1.7f, 1.7f, 1.7f), 5f).setEase(LeanTweenType.easeOutBounce);

实例化游戏对象时,将结果保存到一个临时变量中。将该临时变量添加到列表中,然后也在 LeanTween.scale 函数中使用该临时变量。

//this line instantiates the Gem
GameObject tempObj = Instantiate(Gem, new Vector2((xPos_Hole1 + (Random.Range(-20, 20))) * 2.0F, (-229 + (20 * i))), Quaternion.identity);

//this line add the instantiated Gem to the List
gemList1.Add(tempObj);

//This line animates the GEM by scaling it
LeanTween.scale(tempObj, new Vector3(1.7f, 1.7f, 1.7f), 5f).setEase(LeanTweenType.easeOutBounce);