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;
            }
        }
        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
                    };
                    if (p.IsOptional)
                    {
                        newParam.value = p.DefaultValue;
                    }
                    parameters.Add(newParam);
                }

                this.checkValue = new BBObjectParameter(method.ReturnType)
                {
                    bb = blackboard
                };
                comparison = CompareMethod.EqualTo;
            }
        }
        ////////////////////////////////////////
        ///////////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);
            }
        }
        void SetMethod(MethodInfo method)
        {
            if (method == null)
            {
                return;
            }
            this.method = new SerializedMethodInfo(method);
            this.parameters.Clear();
            this.parameterIsByRef.Clear();
            var methodParameters = method.GetParameters();

            for (var i = 0; i < methodParameters.Length; i++)
            {
                var p        = methodParameters[i];
                var pType    = p.ParameterType;
                var newParam = new BBObjectParameter(pType.IsByRef ? pType.GetElementType() : pType)
                {
                    bb = blackboard
                };
                if (p.IsOptional)
                {
                    newParam.value = p.DefaultValue;
                }
                parameters.Add(newParam);
                parameterIsByRef.Add(pType.IsByRef);
            }

            this.checkValue = new BBObjectParameter(method.ReturnType)
            {
                bb = blackboard
            };
            comparison = CompareMethod.EqualTo;
        }
Exemplo n.º 5
0
 void SetMethod(MethodInfo method)
 {
     if (method != null)
     {
         this.method = new SerializedMethodInfo(method);
         this.parameter.SetType(method.GetParameters()[0].ParameterType);
     }
 }
        ////////////////////////////////////////
        ///////////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);
                }
            }
        }
Exemplo n.º 7
0
        void SetMethod(MethodInfo method)
        {
            if (method == null)
            {
                return;
            }

            this.method = new SerializedMethodInfo(method);
            setValue.SetType(method.GetParameters()[0].ParameterType);
        }
Exemplo n.º 8
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);
         }
     }
 }
Exemplo n.º 9
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
                #if UNITY_EDITOR
        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]);
                }
            }
        }
Exemplo n.º 10
0
        void SetMethod(MethodInfo method)
        {
            if (method == null)
            {
                return;
            }
            this.method = new SerializedMethodInfo(method);
            this.parameters.Clear();
            this.parameterIsByRef.Clear();
            var methodParameters = method.GetParameters();

            for (var i = 0; i < methodParameters.Length; i++)
            {
                var p        = methodParameters[i];
                var pType    = p.ParameterType;
                var newParam = new BBObjectParameter(pType.IsByRef ? pType.GetElementType() : pType)
                {
                    bb = blackboard
                };
                if (p.IsOptional)
                {
                    newParam.value = p.DefaultValue;
                }
                parameters.Add(newParam);
                parameterIsByRef.Add(pType.IsByRef);
            }

            if (method.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator))
            {
                this.returnValue = new BBObjectParameter(method.ReturnType)
                {
                    bb = blackboard
                };
            }
            else
            {
                this.returnValue = null;
            }
        }
Exemplo n.º 11
0
        ////////////////////////////////////////
        ///////////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);
            }
        }