浏览代码

use asset role labels as display name instead of partial class names

/generic-asset-sources
Mohsen Kamalzadeh 3 年前
当前提交
0df8f4ca
共有 1 个文件被更改,包括 12 次插入2 次删除
  1. 14
      com.unity.perception/Editor/Randomization/VisualElements/AssetSource/AssetSourceElement.cs

14
com.unity.perception/Editor/Randomization/VisualElements/AssetSource/AssetSourceElement.cs


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using UnityEditor;

VisualElement m_FieldsContainer;
TextElement m_LocationNotes;
Type m_AssetType;
Dictionary<string, Type> m_AssetRoleLabelsToTypes = new Dictionary<string, Type>();
AssetRoleBase assetRole =>
(AssetRoleBase)StaticData.GetManagedReferenceValue(m_AssetRoleProperty);

"None",
a => ReplaceAssetRole(null),
a => DropdownMenuAction.Status.Normal);
m_AssetRoleLabelsToTypes.Clear();
var label = GetAssetRoleDisplayName(type);
if (m_AssetRoleLabelsToTypes.ContainsKey(label))
Debug.LogError($"The asset role classes {type.Name} && {m_AssetRoleLabelsToTypes[label].Name} have an identical label: \"{label}\". Asset role labels should be unique.");
else
m_AssetRoleLabelsToTypes.Add(label, type);
GetAssetRoleDisplayName(type),
label,
a => ReplaceAssetRole(type),
a => DropdownMenuAction.Status.Normal);
}

static string GetAssetRoleDisplayName(Type type)
{
return type.Name.Replace("AssetRole", string.Empty);
return ((AssetRoleBase)Activator.CreateInstance(type)).label;
}
}
}
正在加载...
取消
保存