Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Serialized property for layers has changed ?

Discussion in 'Unity 5 Pre-order Beta' started by nasos_333, Feb 23, 2015.

  1. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,291
    I am trying to find a layer by code, by checking the type, value and name of property

    This worked in Unity 4, but seems that the it1.name value is "data" than the corresponding definition like "User Layer"

    Is there a way to distinguish between the layer and tags in Unity 5 ? Maybe the data has the proper attribute as child ?

    Thanks

    Code (csharp):
    1.  
    2.   SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
    3.      
    4.        SerializedProperty it1 = tagManager.GetIterator();
    5.        bool showChildren = true;
    6.   while (it1.NextVisible(showChildren))
    7.        {
    8.          if(it1.propertyType == SerializedPropertyType.String){
    9.            Debug.Log (it1.name);
    10.            if(it1.stringValue == "TEM_Sheet_Maker" & it1.name.Contains("User Layer")){
    11.              TEM_layer_already_changed=true;
    12.            
    13.              break;
    14.            }
    15.          }
    16.        }
    17.