////////////////////////////////////////
        ///////////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)
            {
                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();
            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)
            {
                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;
        }
 void SetMethod(MethodInfo method)
 {
     if (method != null)
     {
         this.method = new SerializedMethodInfo(method);
         this.returnValue.SetType(method.ReturnType);
     }
 }
示例#6
0
 void SetMethod(MethodInfo method)
 {
     if (method != null)
     {
         this.method = new SerializedMethodInfo(method);
         this.parameter.SetType(method.GetParameters()[0].ParameterType);
     }
 }
示例#7
0
 void SetMethod(MethodInfo method)
 {
     if (method != null)
     {
         this.method = new SerializedMethodInfo(method);
         this.checkValue.SetType(method.ReturnType);
         comparison = CompareMethod.EqualTo;
     }
 }
        ////////////////////////////////////////
        ///////////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);
                }
            }
        }
示例#9
0
        void SetMethod(MethodInfo method)
        {
            if (method == null)
            {
                return;
            }

            this.method = new SerializedMethodInfo(method);
            setValue.SetType(method.GetParameters()[0].ParameterType);
        }
 ///When ports connects and is a generic method, try change method to that port type
 public override void OnPortConnected(Port port, Port otherPort)
 {
     if (method.IsGenericMethod)
     {
         var wildType  = method.GetFirstGenericParameterConstraintType();
         var newMethod = FlowNode.TryGetNewGenericMethodForWild(wildType, port.type, otherPort.type, method);
         if (newMethod != null)
         {
             _method = new SerializedMethodInfo(newMethod);
             GatherPorts();
         }
     }
 }
示例#11
0
        void SetMethod(MethodInfo method)
        {
            if (method == null)
            {
                return;
            }

            this.method = new SerializedMethodInfo(method);

            var returnType = method.ReturnType;

            //arrayToList = returnType.IsArray && returnValue.value != null && returnValue.value.GetType().Implements(ICollection<ArrayElementType>)
            returnValue.SetType(returnType);
        }
示例#12
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);
         }
     }
 }
示例#13
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]);
                }
            }
        }
示例#14
0
        ///Set a new MethodInfo to be used by ReflectedMethodNode
        public void SetMethod(MethodInfo method, object instance = null)
        {
            //drop hierarchy to base definition
            method = method.GetBaseDefinition();

            _method   = new SerializedMethodInfo(method);
            _callable = method.ReturnType == typeof(void);
            GatherPorts();

            if (instance != null && !method.IsStatic)
            {
                var port = (ValueInput)GetFirstInputOfType(instance.GetType());
                if (port != null)
                {
                    port.serializedValue = instance;
                }
            }
        }
        ///Set a new MethodInfo to be used by ReflectedMethodNode
        void SetMethod(MethodInfo newMethod, object instance = null)
        {
            //open generic
            if (newMethod.IsGenericMethodDefinition)
            {
                var wildType = newMethod.GetFirstGenericParameterConstraintType();
                newMethod = newMethod.MakeGenericMethod(wildType);
            }

            //drop hierarchy to base definition
            newMethod = newMethod.GetBaseDefinition();

            _method   = new SerializedMethodInfo(newMethod);
            _callable = newMethod.ReturnType == typeof(void);
            GatherPorts();

            base.SetDropInstanceReference(newMethod, instance);
            base.SetDefaultParameterValues(newMethod);
        }
示例#16
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;
            }
        }
        ////////////////////////////////////////
        ///////////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);
            }
        }
示例#18
0
        ////////////////////////////////////////
        ///////////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);
                }
            }
        }
示例#19
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);
            }
        }