/// <summary> /// Assign Unity layer to the GameObject if found on the part as attribute. /// </summary> /// <param name="session"></param> /// <param name="geoID"></param> /// <param name="partID"></param> /// <param name="gameObject"></param> public static void AssignUnityLayer(HEU_SessionBase session, HAPI_NodeId geoID, HAPI_PartId partID, GameObject gameObject) { HAPI_AttributeInfo layerAttrInfo = new HAPI_AttributeInfo(); int[] layerAttr = new int[0]; HEU_GeneralUtility.GetAttribute(session, geoID, partID, HEU_PluginSettings.UnityLayerAttributeName, ref layerAttrInfo, ref layerAttr, session.GetAttributeStringData); if (layerAttrInfo.exists) { string layerStr = HEU_SessionManager.GetString(layerAttr[0]); if (layerStr.Length > 0) { int layer = LayerMask.NameToLayer(layerStr); if (layer < 0) { Debug.LogWarningFormat("Unity layer '{0}' does not exist for current project. Add the layer in order to use it!", layerStr); } else { HEU_GeneralUtility.SetLayer(gameObject, layer, true); } } } }