haimat
1
I want to load a particle system prefab for one of my objects from within a Boo script. So I tried the following:
class scriptEnemy(MonoBehaviour):
public tr as Transform = null
def Update():
if tr:
(Instantiate(tr, transform.position, transform.rotation) as Transform)
However, this gives me the following error in the Unity console:
BCE0034: Expressions in statements must only be executed for their side-effects.
After some googling I found out that the problem here is the lack of side-effects, at least the compiler thinks that. So I can fix that via the following line instead:
dummy = (Instantiate(tr, transform.position, transform.rotation) as Transform)
This does work now as intended. But it looks a bit odd, also the compiler now gives me a warning about the unused local variable dummy (of course).
Isn’t there a nicer way to achieve this, without having to use the dummy variable?
I don’t really use boo, but if it’s much like C# or js, then you should be able to take out the cast and then it will probably be okay.
class scriptEnemy(MonoBehaviour):
public tr as Transform = null
def Update():
if tr:
Instantiate(tr, transform.position, transform.rotation)
Right now the compiler is trying to figure out why you want to treat it as a Transform if you aren’t actually going to do anything with it.