Search Unity

How to exclude gameobject from buld?

Discussion in 'Scripting' started by trzmiel, Mar 20, 2014.

  1. trzmiel

    trzmiel

    Joined:
    Nov 5, 2013
    Posts:
    28
    I have got game object which uses UnityEditor. This object holds some textures for other UnityEditor scripts.
    How can I exclude this game object from build?
    Because during build "UnityEditor" could not be found (which is obvious).
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    #if UNITY_EDITOR
    // editor code here
    #endif

    --Eric
     
  3. trzmiel

    trzmiel

    Joined:
    Nov 5, 2013
    Posts:
    28
    Thank you. Very helpful tip.
     
  4. trzmiel

    trzmiel

    Joined:
    Nov 5, 2013
    Posts:
    28
    OK. I have used your tip very simply: just pasted all my script between your #if UNITY_EDITOR tag. And it works, I have no "UnityEditor" errors during build.
    But as I mentioned the gameObject which uses this script holds references to a lot of textures which are neccessary for this script but not neccessary during build. And now I am wondering if #if UNITY_EDITOR is enough to exclude this textures from build.
    ?
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Look at the build log and see what it says.

    --Eric