2017-06-14 1 views
0

Ich möchte ein Objekt mit Lean Tween skalieren, aber ich bin auch nur instanziieren.Kombinieren Sie Instantiate mit Lean Tween

Wie kann ich die folgenden Codezeilen kombinieren? Mit anderen Worten, ich möchte das Prefab skalieren/animieren, während ich es instanziiere.

//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); 

Antwort

3

Wenn Sie das GameObject instanziieren, speichern Sie das Ergebnis in einer temporären Variablen. Fügen Sie diese temporäre Variable zur Liste hinzu und verwenden Sie diese temporäre Variable auch in der Funktion 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); 
+1

Danke für die Antwort –