浏览代码

cleanup and polish

/main
Mohsen Kamalzadeh 4 年前
当前提交
ba811b85
共有 2 个文件被更改,包括 25 次插入9 次删除
  1. 24
      com.unity.perception/Editor/GroundTruth/LabelingEditor.cs
  2. 10
      com.unity.perception/Runtime/GroundTruth/Labeling/Labeling.cs

24
com.unity.perception/Editor/GroundTruth/LabelingEditor.cs


}
}
private bool AreSelectedAssetsCompatibleWithAutoLabelScheme(AssetLabelingScheme scheme)
{
foreach (var asset in serializedObject.targetObjects)
{
string label = scheme.GenerateLabel(asset);
if (label == null)
{
return false;
}
}
return true;
}
m_LabelingSchemes.Add(new AssetNameLabelingScheme());
m_LabelingSchemes.Add(new AssetFileNameLabelingScheme());
m_LabelingSchemes.Add(new CurrentOrParentsFolderNameLabelingScheme());
AssetLabelingScheme labelingScheme = new AssetNameLabelingScheme();
if (AreSelectedAssetsCompatibleWithAutoLabelScheme(labelingScheme)) m_LabelingSchemes.Add(labelingScheme);
labelingScheme = new AssetFileNameLabelingScheme();
if (AreSelectedAssetsCompatibleWithAutoLabelScheme(labelingScheme)) m_LabelingSchemes.Add(labelingScheme);
labelingScheme = new CurrentOrParentsFolderNameLabelingScheme();
if (AreSelectedAssetsCompatibleWithAutoLabelScheme(labelingScheme)) m_LabelingSchemes.Add(labelingScheme);
var descriptions = m_LabelingSchemes.Select(scheme => scheme.Description).ToList();
descriptions.Insert(0, "<Select Scheme>");

10
com.unity.perception/Runtime/GroundTruth/Labeling/Labeling.cs


public override string GenerateLabel(Object asset)
{
string assetPath = Labeling.GetAssetOrPrefabPath(asset);
var stringList = assetPath?.Split(Labeling.PathSeparators, StringSplitOptions.RemoveEmptyEntries)
var stringList = assetPath.Split(Labeling.PathSeparators, StringSplitOptions.RemoveEmptyEntries)
return stringList?.Last();
return stringList.Count > 0 ? stringList.Last() : null;
}
}

public override string GenerateLabel(Object asset)
{
string assetPath = Labeling.GetAssetOrPrefabPath(asset);
var stringList = assetPath?.Split(Labeling.PathSeparators, StringSplitOptions.RemoveEmptyEntries)
var stringList = assetPath.Split(Labeling.PathSeparators, StringSplitOptions.RemoveEmptyEntries)
//if stringList is not null, it always has at least two members, the file's name and the parent folder
return stringList?[stringList.Count-2];
return stringList.Count > 1 ? stringList[stringList.Count-2] : null;
}
}
}
正在加载...
取消
保存