Search Unity

activeSceneChanged hates me

Discussion in 'Scripting' started by LeRan, Aug 25, 2016.

  1. LeRan

    LeRan

    Joined:
    Nov 24, 2015
    Posts:
    118
    Hi forum,

    I have that little something that's driving me crazy. I'm trying to fire some methods on active scene changed, so I wrote some code that looks like that :

    Code (CSharp):
    1. using UnityEngine.SceneManagement;
    2.  
    3. public class LeEventManager:MonoBehaviour{
    4.  
    5. void Awake()
    6. {
    7. SceneManager.activeSceneChanged+=someMethod;// subscribe
    8. }
    9.  
    10. void OnDestroy()
    11. {
    12. SceneManager.activeSceneChanged-=someMethod;// unsubscribe
    13. }
    14.  
    15. (...etc)
    16. }
    But everytime the compiler tells me: " UnityEngine.SceneManagement.SceneManager does not contain a definition for activeSceneChanged".

    What am I missing? Please help me, I'm unfamiliar with events and the online official documentation of activeSceneChanged is especially unhelpful.
     
  2. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    That functionality is brand-new in 5.4 I believe so I'll get the obvious question out of the way- are you using the most recent version of Unity?
     
  3. LeRan

    LeRan

    Joined:
    Nov 24, 2015
    Posts:
    118
    It's absolutely valid to check that first indeed... I'm using Unity 5.3.6f1 which is still quite new but maybe I need to update Unity before asking further questions. Thanks ! :D
     
  4. LeRan

    LeRan

    Joined:
    Nov 24, 2015
    Posts:
    118
    As a side note, Unity documentation is somewhat tricky: it displays by default v5.4 which is still in beta testing, and requires user action to switch back to 5.3 which is the current stable version... Not to say that it wasn't my mistake however :)
     
  5. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    The current stable version is 5.4, which is why it displays that by default. As far as I know, there's no beta version right now.
     
  6. fei

    fei

    Joined:
    Aug 23, 2012
    Posts:
    9
    Had the same problem, turned out I had my own SceneManager, which was the one picked up and of course, didn't have the activeSceneChanged definition
     
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    There are a few features under public alpha/beta at the moment, 2D features and the like.
     
  8. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    Yup, but I made the comment in August and there weren't any alpha or beta versions available at the time. In a semi-related note, I'm really looking forward to the new NavMesh and scene directing tools, but they keep pushing them back- I think they're back in the "no idea" alpha list of future features instead of the beta list like they were a couple months ago.
     
  9. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Whoops. Burned by a necro again. Apologies for that...