Skip to content

Commit

Permalink
fix(Logger): saved to scene in Editor
Browse files Browse the repository at this point in the history
If the Logger was used in the Editor to log something it was added to
scene. This fix makes sure the Logger isn't visible in and is not saved
to the scene when in the Editor.
Additionally the `DontDestroyOnLoad` call has been moved to not be
called when destroying the object anyway.
  • Loading branch information
Christopher - Marcel Böddecker committed Mar 31, 2017
1 parent b6c1bad commit a0256d9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Assets/VRTK/Scripts/Internal/VRTK_Logger.cs
Expand Up @@ -56,7 +56,10 @@ public static void CreateIfNotExists()
{
if (instance == null)
{
GameObject loggerObject = new GameObject("[VRTK_Logger]");
GameObject loggerObject = new GameObject("[VRTK_Logger]")
{
hideFlags = HideFlags.DontSaveInEditor | HideFlags.HideInHierarchy
};
instance = loggerObject.AddComponent<VRTK_Logger>();
instance.minLevel = LogLevels.Trace;
instance.throwExceptions = true;
Expand Down Expand Up @@ -164,12 +167,12 @@ protected virtual void Awake()
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else if (instance != this)
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);
}
}
}

0 comments on commit a0256d9

Please sign in to comment.