Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Compile error if turn Analytics off

Discussion in 'Unity Analytics' started by Simon-Glass, Oct 5, 2015.

  1. Simon-Glass

    Simon-Glass

    Joined:
    Feb 11, 2015
    Posts:
    2
    If I turn Unity Analytics off in the Unity editor I get a compile error for any code that uses AnalyticsResult as shown below. This is resolved as soon as Unity Analytics is turned back on - failing this we have to comment out the effected code. Is this any way to overcome this automatically eg by using something similar to the platform dependent compile options such as '#if UNITY_EDITOR'

    "The type or namespace name `AnalyticsResult' could not be found. Are you missing a using directive or an assembly reference?"
     
  2. mpinol

    mpinol

    Unity Technologies

    Joined:
    Jul 29, 2015
    Posts:
    317
    Hi @Simon Glass,

    You can surround your Analytics methods with '#if UNITY_ANALYTICS, #endif' to remove the editor compiler errors when Analytics is turned off.
     
  3. Simon-Glass

    Simon-Glass

    Joined:
    Feb 11, 2015
    Posts:
    2
    Many thanks - that is just what I was looking for. Not sure how I missed it!
     
    mpinol likes this.