|
This is for WeaponManager.js error at 'enabled' //Dectivate all weapon for (var i : int = 0; i < weaponsInUse.length; i++){ weaponsInUse[i].gameObject.SendMessage("Deselect", SendMessageOptions.DontRequireReceiver); var deactivate : Component[] = weaponsInUse[i].gameObject.GetComponentsInChildren(MonoBehaviour); for (var d in deactivate) { var d : MonoBehaviour = d as MonoBehaviour; if (d) d.enabled = false; } weaponsInUse[i].gameObject.SetActiveRecursively(false);
(comments are locked)
|
|
Change d.enabled to d.gameObject.active or convert it to a GameObject and use d.renderer.enabled. active is not part of UnityEngine.Object or GameObject. active is to check if is it avaiable/enabled. If you need to check the renderer check gameObject.renderer.enabled. That works, thx! how about this similiar but I could not get through error at 'enabled' function PauseGame() { transform.position = new Vector3(0, 1, 0); Screen.lockCursor = false; }
Aug 04 '12 at 10:49 AM
Xdy
'enabled' is only a property on some components. Use 'active' is for GameObjects. 'Active' maps to the checkbox in unity whether it is active or not. If you just want to make the item invisible but still there and scriptable/findable you use renderer.enabled usually. Use .active on GameObjects. .enabled is for some components.
Aug 04 '12 at 07:28 PM
drawcode
No, .active is only for GameObjects. .enabled is for all components.
Aug 04 '12 at 07:44 PM
Eric5h5
@Eric5h5 only some components have .enabled as it is not part of the base UnityEngine.Object or UnityEngine.Component. renderer, collider and camera are some that have it. http://docs.unity3d.com/Documentation/ScriptReference/Component.html http://docs.unity3d.com/Documentation/ScriptReference/Object.html http://docs.unity3d.com/Documentation/ScriptReference/30_search.html?q=enabled .enabled is available on some components. Joint for instance is a Component that does not: http://docs.unity3d.com/Documentation/ScriptReference/Joint.html
Aug 04 '12 at 09:00 PM
drawcode
The point is that .active is only for GameObjects. If you're able to disable/enable a component, it will be with .enabled, not .active. In no case is .active "preferred", nor should .enabled ever be changed to .active. If you try, you'll get a warning specifically telling you not use use .active for components (since that usage was deprecated quite a long time ago). Saying "active is not part of GameObject" is clearly wrong as you can see in the docs.
Aug 04 '12 at 09:55 PM
Eric5h5
(comments are locked)
|
