Search Unity

Layers/Tags in unity packages?

Discussion in 'Editor & General Support' started by Bren, Apr 29, 2011.

  1. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    Is it possible to include project settings such as tags and layers in unity packages? This makes a lot of sense for things like the Asset Store.

    I noticed that Mr. Moustache's Jump 'n' Run hit similar problems, discussed in this thread. His hotfix workaround is a little klunky.

    Is there a "proper" way to do this?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    tags get regenerated so you could transfer them but layer are an editor per project exclusive property not affectable through other things (and thats good this way, you wouldn't want packages to modify the layer names - for tags no problem as just a new one gets added but layers are limited in number and often accessed by index)


    The proper way to really do it is include documentation and inform the user what is needed.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I brought this up early on and was told that project settings would be included in packages uploaded for the store, but I'm not convinced that's actually true.

    --Eric
     
    Lex4art likes this.
  4. KvanteTore

    KvanteTore

    Joined:
    Feb 16, 2010
    Posts:
    87
  5. jacz

    jacz

    Joined:
    Dec 14, 2013
    Posts:
    1
    I tried a hack where the TagManager.asset in Project Settings is copied separately, and it seems to work in our project.
     
  6. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    I just had an issue with this when publishing my Tycoon Terrain engine to the asset store. The terrain object does not get the layer that I need for raycasts when the user wants to lower or raise terrain etc. I tried the fix in Mr. Moustache's Jump 'n' Run article but then you copy all the project settings (networking, build settings etc etc you name it!) which I think might break existing projects in case the user forgets to uncheck them at import. Instead I wrote short script for exporting the correct folder and the TagManager.asset file only.

    It's pretty simple but it may save someone else an hours work and research i hope:

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using UnityEditor;
    5.  
    6. public static class ExportWithLayers {
    7.  
    8.     [MenuItem("Asset Store Tools/Export package with tags and physics layers")]
    9.     public static void ExportPackage()
    10.     {
    11.         string[] projectContent = new string[] {"Assets/Tycoon Terrain", "ProjectSettings/TagManager.asset"};
    12.         AssetDatabase.ExportPackage(projectContent, "UltimateTemplate.unitypackage",ExportPackageOptions.Interactive | ExportPackageOptions.Recurse |ExportPackageOptions.IncludeDependencies);
    13.         Debug.Log("Project Exported");
    14.     }
    15.  
    16. }
    17.  

    EDIT: Let me just clarify that this has no effect when uploading to the asset store. The asset store package upload tool will decide on its own what to include in the package (you can check the resulting package in the tmp-folder). If you upload into the "Complete Projects" category then tags and layers are included as well.
     
    Last edited: Mar 17, 2016
  7. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Sorry for necro-ing old thread.

    For those that are having this same problem after importing new packages from the asset store... and discovering

    "ALL MY LAYER SETTINGS ARE GONE!"

    Here is how to fix it. This works with everything from input settings, layer\tag settings, physics settings etc

    Sorry It's just simple screenshots this time. But hopefully it'll make sense to those used to Unity. Please note you should have saved your "working" Unity files somewhere else, before installing any new asset packages. (Otherwise you'll lose all your inspector settings after installing the new package)

    Broken Layers after new install of package
    http://imgur.com/YWf3Myg

    Go back to a working version
    http://imgur.com/ta1gShG

    Export the settings
    http://imgur.com/Pa8PG6G

    Import into new Scene
    http://imgur.com/D6lbc7f




    ----------------
    My Project
    https://twitter.com/AlaNendoroid
    https://madewith.unity.com/profiles/2dos
     
  8. zhool

    zhool

    Joined:
    Nov 28, 2016
    Posts:
    3
    I ran into this issue when exporting a scene to add it to a new project. The layer index for each object is retained, just not the layers themselves, so if you manually recreate the layers in the new project the objects will update.
    eg i had a 'boundary' layer at 11 and 'obstacle' at 12: i went to the new project's layer editor, added the layer names at the same indexes (11 & 12), and all the objects that were on those layers updated. also i had to redo the layer collisions.
    grab a screenie of the old project's layer editor and collision matrix to help copy them (or include such if publishing).
     
  9. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Yeah the overwriting/index of layers and tags is balls.

    This means any asset you import that has tags and layers just overwrites existing stuff, instead of adding new layers and using them as a reference.
     
  10. Spellloop

    Spellloop

    Joined:
    Jan 1, 2015
    Posts:
    2
    Sorry to necro this thread, but I was just having troubles with this and found a neat way to export/import Tags & Layers with the "new" Presets feature.
    1. Open Tags & Layers in the Inspector (for example via Layers dropdown menu in the upper right corner > Edit Layers...)
    2. Click on the little sliders icon in the upper right corner of the Inspector (between the blue ?-book and gear icon)
    3. In the Select Preset window click on "save current to"
    4. Set a name, select any place in your Assets folder and save the preset
    5. Open the project folder in your favorite file explorer and manually copy the preset file to any projects Asset folder that you want to import your Tags & Layers to
    6. Open the project that you have just copied the preset to
    7. Open Tags & Layers in the Inspector there
    8. Click on the sliders icon
    9. Select your preset
    ...and voila there are all your precious tags and layers!
     
  11. Lowfeye

    Lowfeye

    Joined:
    Dec 11, 2022
    Posts:
    4
    It is very helpful