Skip to main content
New Participant
March 2, 2016

How to disable Editor Scripts when building GearVR apps

I am trying to make a Developer Build for a Virtual Reality enabled app. My Android device does not support Editor Mode. I have scripts in my project that I use for generating Asset Bundles. Can I keep these scripts in my project but disable them when building for my Android device? The error is unknown namespace UnityEditor.
    This topic has been closed for replies.

    2 replies

    Up and Coming
    March 2, 2016
    Yes, there are a number of compilation symbols that are set by unity when compiling for a target. For example if you did

    public void Update()
    {
    #if !UNITY_ANDROID
    //This only happens on non android devices
    #endif
    }
    You can have code that only runs if you are not on a android device.

    or if you want your code to only be compiled when running inside the Unity editor do

    public void Awake()
    {
    #if UNITY_EDITOR
    //This only happens if the code is run from inside the editor.
    #endif
    }

    See http://docs.unity3d.com/Manual/Platform ... ation.html for more information about symbols that are available to you when compiling.
    Up and Coming
    March 7, 2016
    Typically if you have a script that is only executed in the Editor (such as your Asset Bundle generator), you should be putting them in an Editor/ directory. Here's the manual on Special Folders: http://docs.unity3d.com/Manual/SpecialFolders.html.
    Developer of Elementalist X : Immersive and intense tower defense for Gear VR.