Pretty sure there’s an easy answer to this.
I’m trying to figure out how to typecast the following but Unity keeps telling me I can’t convert and Object to a Transform. It is of course automatically downcasting but I want to explicitly set it.
Here’s my original source code:
for(var _child : Component in transform ) {
if(_child.particleEmitter)
_child.particleEmitter.emit = true;
}
And here are all the variations I’ve tried but with no success
for(var _child : Transform in transform) {
if(_child.particleEmitter)
_child.particleEmitter.emit = true;
}
for(var _child : Transform in transform as Transform) {
if(_child.particleEmitter)
_child.particleEmitter.emit = true;
}
for(var _child : Component in transform as Component) {
if(_child.particleEmitter)
_child.particleEmitter.emit = true;
}
for(var _child : Component in transform) {
if(_child.particleEmitter)
_child.particleEmitter.emit = true;
}
var _tempTransform : Transform = transform as Transform;
for(var _child : Transform in _tempTransform) {
if(_child.particleEmitter)
_child.particleEmitter.emit = true;
}
var _tempTransform : Component = transform as Component;
for(var _child : Component in _tempTransform) {
if(_child.particleEmitter)
_child.particleEmitter.emit = true;
}
var _tempTransform : Transform = GetComponent(typeof(Transform)) as Transform;
for(var _child : Transform in _tempTransform) {
if(_child.particleEmitter)
_child.particleEmitter.emit = true;
}