void DrawParameters(PresenterActionInfo action)
        {
            EditorGUILayout.LabelField("Parameters");
            EditorGUI.indentLevel++;

            var binderProperties = serializedObject.FindProperty("_toSendDataBinders");
            var parameters       = action.Method.GetParameters();

            var parameterLength = parameters.Length;

            if (action.IsAsync)
            {
                parameterLength--;
            }

            if (parameterLength == 0)
            {
                EditorGUILayout.HelpBox("No parameter to send", MessageType.Info);
            }
            else
            {
                for (var i = 0; i < parameterLength; i++)
                {
                    if (binderProperties.arraySize <= i)
                    {
                        binderProperties.InsertArrayElementAtIndex(i);
                    }

                    var binderProperty = binderProperties.GetArrayElementAtIndex(i);
                    var parameter      = parameters[i];

                    var paraType          = parameter.ParameterType;
                    var requireBinderInfo = BinderUtil.GetRequireBinderInfoByValueType(paraType);
                    binderProperty.objectReferenceValue = EditorKit.DrawBinderField(
                        parameter.Name, requireBinderInfo.ValueTypeName, binderProperty.objectReferenceValue, requireBinderInfo.InterfaceType);
                }
            }
            while (binderProperties.arraySize > parameters.Length)
            {
                binderProperties.DeleteArrayElementAtIndex(parameters.Length);
            }

            EditorGUI.indentLevel--;
        }
Пример #2
0
        void DrawParameters(Dictionary <string, Type> parameterTypes)
        {
            if (parameterTypes == null)
            {
                parameterTypes = new Dictionary <string, Type>();
            }

            EditorGUILayout.LabelField("Parameters");
            EditorGUI.indentLevel++;

            var binderProperties = serializedObject.FindProperty("_eventParameterBinders");

            while (binderProperties.arraySize > parameterTypes.Count)
            {
                binderProperties.DeleteArrayElementAtIndex(parameterTypes.Count);
            }

            if (parameterTypes.Count == 0)
            {
                EditorGUILayout.HelpBox("No parameter data", MessageType.Info);
            }
            else
            {
                var keys = parameterTypes.Keys.ToArray();
                for (var i = 0; i < keys.Length; i++)
                {
                    if (binderProperties.arraySize <= i)
                    {
                        binderProperties.InsertArrayElementAtIndex(i);
                    }

                    var binderProperty = binderProperties.GetArrayElementAtIndex(i);
                    var label          = keys[i];
                    var parameterType  = parameterTypes[label];

                    var requireBinderInfo = BinderUtil.GetRequireBinderInfoByValueType(parameterType);
                    binderProperty.objectReferenceValue = EditorKit.DrawBinderField(
                        label, requireBinderInfo.ValueTypeName, binderProperty.objectReferenceValue, requireBinderInfo.InterfaceType);
                }
            }
            EditorGUI.indentLevel--;
        }
Пример #3
0
        void DrawConditions(Dictionary <string, Type> conditionTypes)
        {
            if (conditionTypes == null)
            {
                conditionTypes = new Dictionary <string, Type>();
            }

            var binderProperties = serializedObject.FindProperty("_registConditionBinders");

            while (binderProperties.arraySize > conditionTypes.Count)
            {
                binderProperties.DeleteArrayElementAtIndex(conditionTypes.Count);
            }

            if (conditionTypes.Count != 0)
            {
                EditorGUILayout.LabelField("Conditions");
                EditorGUI.indentLevel++;

                var keys = conditionTypes.Keys.ToArray();
                for (var i = 0; i < keys.Length; i++)
                {
                    if (binderProperties.arraySize <= i)
                    {
                        binderProperties.InsertArrayElementAtIndex(i);
                    }

                    var binderProperty = binderProperties.GetArrayElementAtIndex(i);
                    var label          = keys[i];
                    var parameterType  = conditionTypes[label];

                    var requireBinderInfo = BinderUtil.GetRequireBinderInfoByValueType(parameterType);
                    binderProperty.objectReferenceValue = EditorKit.DrawBinderField(
                        label, requireBinderInfo.ValueTypeName, binderProperty.objectReferenceValue, requireBinderInfo.InterfaceType);
                }

                EditorGUI.indentLevel--;
            }
        }
        void DrawResponse(PresenterActionInfo action)
        {
            EditorGUILayout.LabelField("Responese");
            EditorGUI.indentLevel++;

            List <Type> retTypeList = new List <Type>();

            if (action.IsAsync)
            {
                var parameters = action.Method.GetParameters();
                var lastParam  = parameters[parameters.Length - 1];
                if (lastParam.ParameterType == typeof(AsyncReturn) || lastParam.ParameterType.IsSubclassOf(typeof(AsyncReturn)))
                {
                    var genericTypes = lastParam.ParameterType.GetGenericArguments();
                    foreach (var gt in genericTypes)
                    {
                        retTypeList.Add(gt);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("it is an async action but the last parameter is not AysncReturn", MessageType.Error);
                    return;
                }
            }
            else if (action.Method.ReturnType != typeof(void))
            {
                retTypeList.Add(action.Method.ReturnType);
            }

            var binderListProperty = serializedObject.FindProperty("_responseDataBinder");

            while (binderListProperty.arraySize > retTypeList.Count)
            {
                binderListProperty.DeleteArrayElementAtIndex(retTypeList.Count);
            }

            if (retTypeList.Count == 0)
            {
                EditorGUILayout.HelpBox("No response data", MessageType.Info);
            }
            else
            {
                for (var i = 0; i < retTypeList.Count; i++)
                {
                    if (binderListProperty.arraySize <= i)
                    {
                        binderListProperty.InsertArrayElementAtIndex(i);
                    }

                    var binderProperty = binderListProperty.GetArrayElementAtIndex(i);
                    var retType        = retTypeList[i];

                    var requireBinderInfo = BinderUtil.GetRequireBinderInfoByValueType(retType);

                    binderProperty.objectReferenceValue = EditorKit.DrawBinderField(
                        "return " + i, requireBinderInfo.ValueTypeName, binderProperty.objectReferenceValue, requireBinderInfo.InterfaceType);
                }
            }

            EditorGUI.indentLevel--;
        }