Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Layers hint

Discussion in 'Scripting' started by Jonathan Czeck, Oct 29, 2005.

  1. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    If you use a lot of layers in Unity, you may notice that right now you cannot get the layer number by tag. So, just make a Layers.cs file with simply this in it: (Of course designed for your own game's needs)

    Code (csharp):
    1. public enum Layers
    2. {
    3.     Default = 0,
    4.     TransparentFX = 1,
    5.     IgnoreRaycast = 2,
    6.     SolidGround = 8,
    7.     GUI = 15
    8. }
    Then refer to it like (int)Layers.SolidGround

    -Jon
     
  2. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Nice hint aarku. Now if I only knew how I would use that :?
     
  3. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    I think the reason is so you can set the layer number in a script:

    Code (csharp):
    1.  
    2. int Layers.SolidGround = 1;
    3.  
    but my syntax might be a bit off, sorry!