本文整理汇总了C#中System.Reflection.MemberInfo.RTGetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.RTGetAttribute方法的具体用法?C# MemberInfo.RTGetAttribute怎么用?C# MemberInfo.RTGetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.RTGetAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BBParameterField
//a special object field for the BBParameter class to let user choose either a real value or enter a string to read data from a Blackboard
public static BBParameter BBParameterField(string prefix, BBParameter bbParam, bool blackboardOnly = false, MemberInfo member = null)
{
if (bbParam == null){
EditorGUILayout.LabelField(prefix, "Non Set Variable");
return null;
}
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
//override if we have a memeber info
if (member != null){
blackboardOnly = member.RTGetAttribute<BlackboardOnlyAttribute>(false) != null;
}
//Direct assignement
if (!blackboardOnly && !bbParam.useBlackboard){
GUILayout.BeginVertical();
bbParam.value = GenericField(prefix, bbParam.value, bbParam.varType, member);
GUILayout.EndVertical();
//Dropdown variable selection
} else {
GUI.color = new Color(0.9f,0.9f,1f,1f);
var varNames = new List<string>();
//Local
if (bbParam.bb != null){
varNames.AddRange(bbParam.bb.GetVariableNames(bbParam.varType));
}
//Seperator
varNames.Add("/");
//Globals
foreach (var globalBB in GlobalBlackboard.allGlobals) {
var globalVars = globalBB.GetVariableNames(bbParam.varType);
if (globalVars.Length == 0){
varNames.Add(globalBB.name + "/");
}
for (var i = 0; i < globalVars.Length; i++){
globalVars[i] = globalBB.name + "/" + globalVars[i];
}
varNames.AddRange( globalVars );
}
//Dynamic
varNames.Add("(DynamicVar)");
//New
if (bbParam.bb != null){
varNames.Add("(Create New)");
}
var isDynamic = !string.IsNullOrEmpty(bbParam.name) && !varNames.Contains(bbParam.name);
if (!isDynamic){
bbParam.name = StringPopup(prefix, bbParam.name, varNames, false, true);
if (bbParam.name == "(DynamicVar)"){
bbParam.name = "_";
}
if (bbParam.bb != null && bbParam.name == "(Create New)"){
if (bbParam.bb.AddVariable(prefix, bbParam.varType) != null){
bbParam.name = prefix;
} else {
bbParam.name = null;
}
}
} else {
bbParam.name = EditorGUILayout.TextField(prefix + " (" + bbParam.varType.FriendlyName() + ")", bbParam.name);
}
}
GUI.color = Color.white;
GUI.backgroundColor = Color.white;
if (!blackboardOnly){
bbParam.useBlackboard = EditorGUILayout.Toggle(bbParam.useBlackboard, EditorStyles.radioButton, GUILayout.Width(18));
}
GUILayout.EndHorizontal();
if (bbParam.isNone || bbParam.bb == null){
GUI.backgroundColor = new Color(0.8f,0.8f,1f,0.5f);
GUI.color = new Color(1f,1f,1f,0.5f);
GUILayout.BeginVertical("textfield");
var info = string.Empty;
if (bbParam.bb == null){
info = "<i>No current Blackboard reference</i>";
}
else if (bbParam.isNone){
info = "Select '" + bbParam.varType.FriendlyName() + "' Assignable Blackboard Variable";
//.........这里部分代码省略.........
示例2: BBParameterField
//a special object field for the BBParameter class to let user choose either a real value or enter a string to read data from a Blackboard
public static BBParameter BBParameterField(string prefix, BBParameter bbParam, bool blackboardOnly = false, MemberInfo member = null)
{
if (bbParam == null){
EditorGUILayout.LabelField(prefix, "Non Set Variable");
return null;
}
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
//override if we have a memeber info
if (member != null){
blackboardOnly = member.RTGetAttribute<BlackboardOnlyAttribute>(false) != null;
}
//Direct assignement
if (!blackboardOnly && !bbParam.useBlackboard){
bbParam.value = GenericField(prefix, bbParam.value, bbParam.varType, member);
//Dropdown variable selection
} else {
GUI.color = new Color(0.9f,0.9f,1f,1f);
var varNames = new List<string>();
//Local
if (bbParam.bb != null)
varNames.AddRange(bbParam.bb.GetVariableNames(bbParam.varType));
//Globals
foreach (var globalBB in GlobalBlackboard.allGlobals.Where(globalBB => globalBB != bbParam.bb)) {
varNames.Add(globalBB.name + "/");
var globalVars = globalBB.GetVariableNames(bbParam.varType);
for (var i = 0; i < globalVars.Length; i++)
globalVars[i] = globalBB.name + "/" + globalVars[i];
varNames.AddRange( globalVars );
}
//Dynamic
varNames.Add("(DynamicVar)");
var isDynamic = !string.IsNullOrEmpty(bbParam.name) && !varNames.Contains(bbParam.name);
if (!isDynamic){
bbParam.name = StringPopup(prefix, bbParam.name, varNames, false, true);
if (bbParam.name == "(DynamicVar)"){
bbParam.name = "_";
}
} else {
bbParam.name = EditorGUILayout.TextField(prefix + " (" + bbParam.varType.FriendlyName() + ")", bbParam.name);
}
}
GUI.color = Color.white;
GUI.backgroundColor = Color.white;
if (!blackboardOnly)
bbParam.useBlackboard = EditorGUILayout.Toggle(bbParam.useBlackboard, EditorStyles.radioButton, GUILayout.Width(18));
GUILayout.EndHorizontal();
if (bbParam.useBlackboard && string.IsNullOrEmpty(bbParam.name)){
GUI.backgroundColor = new Color(0.8f,0.8f,1f,0.5f);
GUI.color = new Color(1f,1f,1f,0.5f);
GUILayout.BeginVertical("textfield");
GUILayout.BeginHorizontal();
if ( bbParam.bb != null && bbParam.varType != typeof(object) ){
if (GUILayout.Button("<b>+</b>", (GUIStyle)"label", GUILayout.Width(20) )){
if (bbParam.bb.AddVariable(prefix, bbParam.varType) != null)
bbParam.name = prefix;
}
EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.ArrowPlus);
}
if (bbParam.bb != null){
GUILayout.Label("Select a '" + bbParam.varType.FriendlyName() + "' Blackboard Variable");
} else {
GUILayout.Label("<i>No current Blackboard reference</i>");
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
GUILayout.Space(2);
}
GUILayout.EndVertical();
GUI.backgroundColor = Color.white;
GUI.color = Color.white;
return bbParam;
}