|
Im using lastest iPhone version...works in regular Unity. I cut and pasted this script from the wiki. http://www.unifycommunity.com/wiki/index.php?title=Particle_Spiral_Effect It give me the error CS1002: Expecting ';' It happens of every line that uses a generic, like ParticleAnimator animator = emitter.transform.GetComponent(); Can anyone explain what is different here or what the problem is when using the iPhone version of Unity? Looks like it may be a limitation of ParticleEmitter and ParticleAnimator types in iPhone or something.
(comments are locked)
|
|
Adding to what Mike said, here are some generic methods I compiled together for the iPhone.
I couldn't extend the component or gameObject classes with these so you simply have to add the object as a passed value, and the class is GM instead of gameObject or Component. Performance wise, I haven't done any benchmark tests. I don't believe they are any faster than 1.1 casting methods because that is how they work. If anything, they might be a little slower, but any of these functions wouldn't be called very often so it doesn't make much difference. So this
becomes this:
and this:
becomes Thank you, could you add a method above for GetComponentsInChildren...I tried but can't get it to work.
Jun 06 '10 at 02:54 AM
chearner
You can thank a couple of forum users for the GetComponentsInChildren. http://forum.unity3d.com/viewtopic.php?t=42686&postdays=0&postorder=asc&highlight=getcomponentsinchildren+error&start=0
Jun 06 '10 at 12:10 PM
Peter G
I added this to the generic methods for GetComponentsInChildren and seemed to work. public static T[] GetComponentsInChildren(Component caller) where T : Component { T[] t = caller.GetComponentsInChildren(typeof(T)) as T[]; return t; }
Jun 06 '10 at 07:34 PM
chearner
(comments are locked)
|
|
IPhone does support generics, but it hasn't got some of the helper functions as generic yet. GetComponent for example hasn't been updated to allow generics. I assume this is probably because it's still possible to compile against the older version of .NET, so generics in the API would stop it from compiling The only solution would be to provide your own generics wrapper for GetComponent, or just use the non generic function
(comments are locked)
|
