Search Unity

Working out if a Layer exists, and if it doesn't, then create it.

Discussion in 'Editor & General Support' started by kevdotbadger, Mar 10, 2014.

  1. kevdotbadger

    kevdotbadger

    Joined:
    Sep 13, 2011
    Posts:
    82
    Hello, I've got a problem and I can't seem to find a solution.

    I have a simple script that creates a gameObject from the editor. My problem is that my enemy should be on a Layer named "Moveable Enemy", I can do this using c# to place it on the desired Layer. However, I'm planning on giving my script to a friend who might not have the "Moveable Enemy" layer setup on his machine, so I need away to search for a layer, and if it doesn't exist make it.

    Any idea's how to do this?