////////////////////////////////////////
		///////////GUI AND EDITOR STUFF/////////
		////////////////////////////////////////
		#if UNITY_EDITOR
		
		protected override void OnTaskInspectorGUI(){

			if (!Application.isPlaying && GUILayout.Button("Select Static Method")){

				UnityEditor.GenericMenu.MenuFunction2 MethodSelected = (m) => {
					var newMethod = (MethodInfo)m;
					this.method = new SerializedMethodInfo(newMethod);
					this.parameters.Clear();
					foreach(var p in newMethod.GetParameters()){
						var newParam = new BBObjectParameter{bb = blackboard};
						newParam.SetType(p.ParameterType);
						if (p.IsOptional){
							newParam.value = p.DefaultValue;
						}
						parameters.Add(newParam);
					}

					if (newMethod.ReturnType != typeof(void)){
						this.returnValue = new BBObjectParameter{bb = blackboard};
						this.returnValue.SetType(newMethod.ReturnType);
					}					
				};
				
				var menu = new UnityEditor.GenericMenu();
				foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(object), true)){
					foreach(var m in t.GetMethods(BindingFlags.Static | BindingFlags.Public).OrderBy(m => !m.IsSpecialName) ){
						
						if (m.IsGenericMethod)
							continue;

						var parameters = m.GetParameters();
						if (parameters.Length > 3)
							continue;

						menu.AddItem(new GUIContent(t.FriendlyName() + "/" + m.SignatureName()), false, MethodSelected, m);

					}
				}
				menu.ShowAsContext();
				Event.current.Use();
			}


			if (targetMethod != null){
				GUILayout.BeginVertical("box");
				UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.DeclaringType.FriendlyName());
				UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name);
				UnityEditor.EditorGUILayout.LabelField("Returns", targetMethod.ReturnType.FriendlyName());
				GUILayout.EndVertical();

				var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray();
				for (var i = 0; i < paramNames.Length; i++){
					EditorUtils.BBParameterField(paramNames[i], parameters[i]);
				}

				if (targetMethod.ReturnType != typeof(void)){
					EditorUtils.BBParameterField("Save Return Value", returnValue, true);
				}
			}
		}
		////////////////////////////////////////
		///////////GUI AND EDITOR STUFF/////////
		////////////////////////////////////////
		#if UNITY_EDITOR

		protected override void OnTaskInspectorGUI(){

			if (!Application.isPlaying && GUILayout.Button("Select Property")){

				System.Action<MethodInfo> MethodSelected = (method)=> {
					this.method = new SerializedMethodInfo(method);
					this.parameter.SetType(method.GetParameters()[0].ParameterType);
				};

				if (agent != null){
					EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(void), typeof(object), MethodSelected, 1, true, false);
				} else {
					var menu = new UnityEditor.GenericMenu();
					foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
						menu = EditorUtils.GetMethodSelectionMenu(t, typeof(void), typeof(object), MethodSelected, 1, true, false, menu);
					menu.ShowAsContext();
					Event.current.Use();
				}				
			}

			if (targetMethod != null){
				GUILayout.BeginVertical("box");
				UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName());
				UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name);
				UnityEditor.EditorGUILayout.LabelField("Set Type", parameter.varType.FriendlyName() );
				GUILayout.EndVertical();
				EditorUtils.BBParameterField("Set Value", parameter);
			}
		}
		////////////////////////////////////////
		///////////GUI AND EDITOR STUFF/////////
		////////////////////////////////////////
		#if UNITY_EDITOR

		protected override void OnTaskInspectorGUI(){

			if (!Application.isPlaying && GUILayout.Button("Select Property")){
				System.Action<MethodInfo> MethodSelected = (method)=> {
					this.method = new SerializedMethodInfo(method);
					this.checkValue.SetType(method.ReturnType);
					comparison = CompareMethod.EqualTo;
				};

				if (agent != null){
					EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 0, true, true);
				} else {
					var menu = new UnityEditor.GenericMenu();
					foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
						menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 0, true, true, menu);
					menu.ShowAsContext();
					Event.current.Use();
				}				
			}			

			if (targetMethod != null){
				GUILayout.BeginVertical("box");
				UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName());
				UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name);
				GUILayout.EndVertical();

				GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
				comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
				GUI.enabled = true;
				EditorUtils.BBParameterField("Value", checkValue);
			}
		}
		////////////////////////////////////////
		///////////GUI AND EDITOR STUFF/////////
		////////////////////////////////////////
		#if UNITY_EDITOR

		protected override void OnTaskInspectorGUI(){

			if (!Application.isPlaying && GUILayout.Button("Select Method")){
				
				System.Action<MethodInfo> MethodSelected = (method)=> {
					this.method = new SerializedMethodInfo(method);
					this.parameters.Clear();
					foreach(var p in method.GetParameters()){
						var newParam = new BBObjectParameter{bb = blackboard};
						newParam.SetType(p.ParameterType);
						if (p.IsOptional){
							newParam.value = p.DefaultValue;
						}
						parameters.Add(newParam);
					}

					this.checkValue = new BBObjectParameter{bb = blackboard};
					this.checkValue.SetType(method.ReturnType);
					comparison = CompareMethod.EqualTo;
				};

				if (agent != null){
					EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 3, false, true);
				} else {
					var menu = new UnityEditor.GenericMenu();
					foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
						menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 3, false, true, menu);
					menu.ShowAsContext();
					Event.current.Use();
				}
			}

			if (targetMethod != null){
				GUILayout.BeginVertical("box");
				UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName());
				UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name);
				GUILayout.EndVertical();

				var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray();
				for (var i = 0; i < paramNames.Length; i++){
					EditorUtils.BBParameterField(paramNames[i], parameters[i]);
				}

				GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
				comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
				GUI.enabled = true;				
				EditorUtils.BBParameterField("Check Value", checkValue);
			}
		}
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Method")){

                System.Action<MethodInfo> MethodSelected = (method) => {
                    this.method = new SerializedMethodInfo(method);
                    this.parameters.Clear();
                    foreach(var p in method.GetParameters()){
                        var newParam = new BBObjectParameter{bb = blackboard};
                        newParam.SetType(p.ParameterType);
                        if (p.IsOptional){
                            newParam.value = p.DefaultValue;
                        }
                        parameters.Add(newParam);
                    }

                    if (method.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator)){
                        this.returnValue = new BBObjectParameter{bb = blackboard};
                        this.returnValue.SetType(method.ReturnType);
                    }
                };

                if (agent != null){

                    EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(object), typeof(object), MethodSelected, 3, false, false);

                } else {
                    var menu = new UnityEditor.GenericMenu();
                    foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
                        menu = EditorUtils.GetMethodSelectionMenu(t, typeof(object), typeof(object), MethodSelected, 3, false, false, menu);
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }

            if (targetMethod != null){
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name);
                UnityEditor.EditorGUILayout.LabelField("Returns", targetMethod.ReturnType.FriendlyName());

                if (targetMethod.ReturnType == typeof(IEnumerator))
                    GUILayout.Label("<b>This will execute as a Coroutine</b>");

                GUILayout.EndVertical();

                var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase() ).ToArray();
                for (var i = 0; i < paramNames.Length; i++){
                    EditorUtils.BBParameterField(paramNames[i], parameters[i]);
                }

                if (targetMethod.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator)){
                    EditorUtils.BBParameterField("Save Return Value", returnValue, true);
                }
            }
        }
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Action Method")){

                System.Action<MethodInfo> MethodSelected = (method)=>{
                    this.method = new SerializedMethodInfo(method);
                    this.parameters.Clear();
                    foreach(var p in method.GetParameters()){
                        var newParam = new BBObjectParameter{bb = blackboard};
                        newParam.SetType(p.ParameterType);
                        parameters.Add(newParam);
                    }
                };

                if (agent != null){
                    EditorUtils.ShowGameObjectMethodSelectionMenu(agent.gameObject, typeof(Status), typeof(object), MethodSelected, 1, false, true);
                } else {
                    var menu = new UnityEditor.GenericMenu();
                    foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
                        menu = EditorUtils.GetMethodSelectionMenu(t, typeof(Status), typeof(object), MethodSelected, 1, false, true, menu);
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }

            if (targetMethod != null){
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Selected Action Method:", targetMethod.Name);
                GUILayout.EndVertical();

                if (targetMethod.GetParameters().Length == 1){
                    var paramName = targetMethod.GetParameters()[0].Name.SplitCamelCase();
                    EditorUtils.BBParameterField(paramName, parameters[0]);
                }
            }
        }
 void SetMethod(MethodInfo method)
 {
     if (method != null){
         this.method = new SerializedMethodInfo(method);
         this.parameters.Clear();
         foreach(var p in method.GetParameters()){
             var newParam = new BBObjectParameter(p.ParameterType){bb = blackboard};
             parameters.Add(newParam);
         }
     }
 }
        void SetMethod(MethodInfo method)
        {
            this.method = new SerializedMethodInfo(method);
            this.parameters.Clear();
            foreach(var p in method.GetParameters()){
                var newParam = new BBObjectParameter(p.ParameterType){bb = blackboard};
                if (p.IsOptional){
                    newParam.value = p.DefaultValue;
                }
                parameters.Add(newParam);
            }

            this.checkValue = new BBObjectParameter(method.ReturnType){bb = blackboard};
            comparison = CompareMethod.EqualTo;
        }
        void SetMethod(MethodInfo method)
        {
            if (method == null){
                return;
            }
            this.method = new SerializedMethodInfo(method);
            this.parameters.Clear();
            var methodParameters = method.GetParameters();
            for (var i = 0; i < methodParameters.Length; i++){
                var p = methodParameters[i];
                var newParam = new BBObjectParameter(p.ParameterType){bb = blackboard};
                if (p.IsOptional){
                    newParam.value = p.DefaultValue;
                }
                parameters.Add(newParam);
            }

            if (method.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator)){
                this.returnValue = new BBObjectParameter(method.ReturnType){bb = blackboard};
            } else {
                this.returnValue = null;
            }
        }
        void SetMethod(MethodInfo method)
        {
            if (method == null){
                return;
            }

            this.method = new SerializedMethodInfo(method);
            this.parameters.Clear();
            foreach(var p in method.GetParameters()){
                var newParam = new BBObjectParameter(p.ParameterType){bb = blackboard};
                if (p.IsOptional){
                    newParam.value = p.DefaultValue;
                }
                parameters.Add(newParam);
            }

            if (method.ReturnType != typeof(void)){
                this.returnValue = new BBObjectParameter(method.ReturnType){bb = blackboard};
            } else {
                this.returnValue = null;
            }
        }
Ejemplo n.º 11
0
 void SetMethod(MethodInfo method)
 {
     if (method != null){
         this.method = new SerializedMethodInfo(method);
         this.parameter.SetType(method.GetParameters()[0].ParameterType);
     }
 }