Search Unity

Pragma Directives Global On Gameobject?

Discussion in 'Editor & General Support' started by SteveJ, Nov 2, 2010.

  1. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    I just wanted to run something by you guys. I'm having some problems with some scripts and I think I've got an idea why but need it confirmed.

    I've got a gameobject that has two scripts attached to it (A and B). This is an existing Unity iPhone 1.7 project that used to work just fine as is.

    In Unity 3, I've had to add "#pragma strict" to script A in order to have my collider.Raycast statements work (as per the manual). When I do this though, I start to get complaints about some of my typing (or lack of) in script B (e.g. Cannot convert 'System.Array' to 'UnityEngine.GameObject[]').

    If I remove the "#pragma strict" from script A, then script B successfully compiles (no typing complaints), but I get the collider.Raycast errors back again in script A.

    So... what I suspect is that if you put a directive in ANY script on a gameobject, it applies to ALL scripts on the gameobject.

    Does anyone know if that's true or not, or have any other possible explanation for what I'm seeing? I feel like I'm finally right on the verge of getting these bugs sorted out.

    EDIT: Sorry - realised this should have gone into scripting.
     
    Last edited: Nov 2, 2010
  2. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    Does anyone have any thoughts on this?