2016-08-02 70 views
0

我能之前在Visual Studio C#代碼中使用,不能使用c#particleSystem屬性了嗎?

particleSystem.SetParticles(points, points.Length); 

但現在它給我一個錯誤。語法是否改變?我必須使用

GetComponent<ParticleSystem>().SetParticles(points, points.Length); 

now?我的VS項目(在這裏使用Unity)不再顯示我的粒子,但我還沒有找到任何其他語法我可以/應該使用。這是否正確,是否還有其他錯誤?或者這是不正確的? 謝謝。

+0

它給出了什麼特別的錯誤? – stuartd

+0

@stuartd它告訴我,particleSystem.SetParticles()已經過時,並告訴我使用GetComponent行。我用它,因爲他們說,但現在我沒有顆粒。 – mkpappu

+1

當然,你現在使用「GetComponent」 - 沒什麼大不了的 – Fattie

回答

2

基於relevant Unity documentation,這是另一個最近(從版本5.4.0開始)不推薦使用的屬性。

所以是的,您現在必須使用GetComponent<ParticleSystem>()來獲取對粒子系統的引用 - 並且您可能需要在Awake()方法中將該引用緩存到變量中,以便在需要頻繁製作使用它。