Exemple #1
0
        public static void DrawParamsInspector( MethodInfo methodInfo, MethodParams methodParams )
        {
            if (methodInfo != null && methodInfo.GetParameters().Length > 0)
            {
                GUILayout.BeginVertical();
                List< string > paramsValues = methodParams.ParamsValues;
                ParameterInfo[] paramsDef = methodInfo.GetParameters();
                for (int i = 0; i < paramsDef.Length; ++i)
                {
                    ParameterInfo parameter = paramsDef[i];
                    GUILayout.BeginHorizontal();

                    GUILayout.Label(parameter.Name, GUILayout.Width(100));
                    if( parameter.ParameterType == typeof( bool ) )
                    {
                        bool currentVal = MethodParamsConverter.SafeConvertToBool(paramsValues[i]);
                        paramsValues[i] =  GUILayout.Toggle( currentVal, "").ToString();
                    }
                    else if( parameter.ParameterType == typeof( string ) )
                    {
                        paramsValues[ i ] = GUILayout.TextField( paramsValues[ i ], GUILayout.Width( 120 ) );

                    }
                    else if( parameter.ParameterType == typeof( int ) || parameter.ParameterType == typeof( float ) )
                    {
                        string regex = "";
                        if( parameter.ParameterType == typeof( int ) )
                        {
                            regex = "[^0-9]";
                        }
                        else
                        {
                            regex = "[^.0-9]";
                        }
                        string newVal = GUILayout.TextField(paramsValues[i], GUILayout.Width(120));
                        paramsValues[i] = Regex.Replace(newVal, regex, "");
                    }

                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
        }
Exemple #2
0
 public static IEnumerator<NodeResult> InvokeMethod( MethodInfo _methodInfo, Component _component, MethodParams _params )
 {
     object[] callParams = ConvertParams( _methodInfo, _params );
     IEnumerator<NodeResult> result = (IEnumerator<NodeResult>)_methodInfo.Invoke(_component, callParams );
     return result;
 }
Exemple #3
0
        public override void DrawInspector()
        {
            base.DrawInspector ();
            if(editorReactable != null) {
                var methods = editorReactable.Actions;
                if(methods.Count > 0) {
                    var idx = 0;
                    if(methods.Contains(actionMethod))
                        idx = methods.IndexOf(actionMethod);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Action");
                    GUILayout.BeginVertical();
                    var methodsArray = methods.ToArray();
                    idx = EditorGUILayout.Popup(idx, methodsArray, "button");

                    if(searchShow = EditorGUILayout.Foldout(searchShow, "Search for:"))
                    {
                        searchScrollPos = EditorGUILayout.BeginScrollView(searchScrollPos, GUILayout.Height(128));
                        searchString = EditorGUILayout.TextField(searchString);
                        if(!string.IsNullOrEmpty(searchString))
                        {
                            for(int i = 0; i < methodsArray.Length; i++)
                            {
                                var methodName = methodsArray[i];
                                if(!string.IsNullOrEmpty(methodName) && methodName.Contains(searchString))
                                {
                                    if(GUILayout.Button(methodName))
                                        idx = i;
                                }
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();

                    actionMethod = methods[idx];
                    GUILayout.Space (8);
                    GUILayout.Label(editorReactable.DocText(actionMethod), "textarea");

                    if (methodParams == null)
                    {
                        methodParams = new MethodParams();
                    }
                    MethodInfo methodInfo = editorReactable.FindMethod( actionMethod );
                    methodParams.ReInit( methodInfo );
                    ReactParamsDrawer.DrawParamsInspector( methodInfo, methodParams );

                }
            }
        }
Exemple #4
0
        private static object[] ConvertParams(MethodInfo _methodInfo, MethodParams _params )
        {
            if (_params == null)
            {
                return null;
            }

            return ConvertParams( _methodInfo, _params.ParamsValues );
        }