diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2ae0888 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,708 @@ + +[*] +charset = utf-8 +end_of_line = crlf +trim_trailing_whitespace = false +insert_final_newline = false +indent_style = space +indent_size = 4 + +# Microsoft .NET properties +csharp_indent_braces = false +csharp_indent_switch_labels = true +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = false +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true +csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion +csharp_preserve_single_line_blocks = true +csharp_space_after_cast = true +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false +csharp_style_var_elsewhere = true:suggestion +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +csharp_using_directive_placement = outside_namespace:silent +dotnet_naming_rule.constants_rule.severity = warning +dotnet_naming_rule.constants_rule.style = upper_camel_case_style +dotnet_naming_rule.constants_rule.symbols = constants_symbols +dotnet_naming_rule.event_rule.severity = warning +dotnet_naming_rule.event_rule.style = upper_camel_case_style +dotnet_naming_rule.event_rule.symbols = event_symbols +dotnet_naming_rule.interfaces_rule.severity = warning +dotnet_naming_rule.interfaces_rule.style = i_upper_camel_case_style +dotnet_naming_rule.interfaces_rule.symbols = interfaces_symbols +dotnet_naming_rule.locals_rule.severity = warning +dotnet_naming_rule.locals_rule.style = lower_camel_case_style +dotnet_naming_rule.locals_rule.symbols = locals_symbols +dotnet_naming_rule.local_constants_rule.severity = warning +dotnet_naming_rule.local_constants_rule.style = lower_camel_case_style +dotnet_naming_rule.local_constants_rule.symbols = local_constants_symbols +dotnet_naming_rule.local_functions_rule.severity = warning +dotnet_naming_rule.local_functions_rule.style = upper_camel_case_style +dotnet_naming_rule.local_functions_rule.symbols = local_functions_symbols +dotnet_naming_rule.method_rule.severity = warning +dotnet_naming_rule.method_rule.style = upper_camel_case_style +dotnet_naming_rule.method_rule.symbols = method_symbols +dotnet_naming_rule.parameters_rule.severity = warning +dotnet_naming_rule.parameters_rule.style = lower_camel_case_style +dotnet_naming_rule.parameters_rule.symbols = parameters_symbols +dotnet_naming_rule.private_constants_rule.severity = warning +dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style +dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols +dotnet_naming_rule.private_instance_fields_rule.severity = warning +dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style_1 +dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols +dotnet_naming_rule.private_static_fields_rule.severity = warning +dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style_1 +dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols +dotnet_naming_rule.private_static_readonly_rule.severity = warning +dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style +dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols +dotnet_naming_rule.property_rule.severity = warning +dotnet_naming_rule.property_rule.style = upper_camel_case_style +dotnet_naming_rule.property_rule.symbols = property_symbols +dotnet_naming_rule.public_fields_rule.severity = warning +dotnet_naming_rule.public_fields_rule.style = lower_camel_case_style +dotnet_naming_rule.public_fields_rule.symbols = public_fields_symbols +dotnet_naming_rule.static_readonly_rule.severity = warning +dotnet_naming_rule.static_readonly_rule.style = upper_camel_case_style +dotnet_naming_rule.static_readonly_rule.symbols = static_readonly_symbols +dotnet_naming_rule.types_and_namespaces_rule.severity = warning +dotnet_naming_rule.types_and_namespaces_rule.style = upper_camel_case_style +dotnet_naming_rule.types_and_namespaces_rule.symbols = types_and_namespaces_symbols +dotnet_naming_rule.type_parameters_rule.severity = warning +dotnet_naming_rule.type_parameters_rule.style = t_upper_camel_case_style +dotnet_naming_rule.type_parameters_rule.symbols = type_parameters_symbols +dotnet_naming_style.i_upper_camel_case_style.capitalization = pascal_case +dotnet_naming_style.i_upper_camel_case_style.required_prefix = I +dotnet_naming_style.lower_camel_case_style.capitalization = camel_case +dotnet_naming_style.lower_camel_case_style_1.capitalization = camel_case +dotnet_naming_style.lower_camel_case_style_1.required_prefix = _ +dotnet_naming_style.t_upper_camel_case_style.capitalization = pascal_case +dotnet_naming_style.t_upper_camel_case_style.required_prefix = T +dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case +dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.constants_symbols.applicable_kinds = field +dotnet_naming_symbols.constants_symbols.required_modifiers = const +dotnet_naming_symbols.event_symbols.applicable_accessibilities = * +dotnet_naming_symbols.event_symbols.applicable_kinds = event +dotnet_naming_symbols.interfaces_symbols.applicable_accessibilities = * +dotnet_naming_symbols.interfaces_symbols.applicable_kinds = interface +dotnet_naming_symbols.locals_symbols.applicable_accessibilities = * +dotnet_naming_symbols.locals_symbols.applicable_kinds = local +dotnet_naming_symbols.local_constants_symbols.applicable_accessibilities = * +dotnet_naming_symbols.local_constants_symbols.applicable_kinds = local +dotnet_naming_symbols.local_constants_symbols.required_modifiers = const +dotnet_naming_symbols.local_functions_symbols.applicable_accessibilities = * +dotnet_naming_symbols.local_functions_symbols.applicable_kinds = local_function +dotnet_naming_symbols.method_symbols.applicable_accessibilities = * +dotnet_naming_symbols.method_symbols.applicable_kinds = method +dotnet_naming_symbols.parameters_symbols.applicable_accessibilities = * +dotnet_naming_symbols.parameters_symbols.applicable_kinds = parameter +dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field +dotnet_naming_symbols.private_constants_symbols.required_modifiers = const +dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static +dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static,readonly +dotnet_naming_symbols.property_symbols.applicable_accessibilities = * +dotnet_naming_symbols.property_symbols.applicable_kinds = property +dotnet_naming_symbols.public_fields_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.public_fields_symbols.applicable_kinds = field +dotnet_naming_symbols.static_readonly_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.static_readonly_symbols.applicable_kinds = field +dotnet_naming_symbols.static_readonly_symbols.required_modifiers = static,readonly +dotnet_naming_symbols.types_and_namespaces_symbols.applicable_accessibilities = * +dotnet_naming_symbols.types_and_namespaces_symbols.applicable_kinds = namespace,class,struct,enum,delegate +dotnet_naming_symbols.type_parameters_symbols.applicable_accessibilities = * +dotnet_naming_symbols.type_parameters_symbols.applicable_kinds = type_parameter +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion +dotnet_style_qualification_for_event = false:suggestion +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion +file_header_template = + +# ReSharper properties +resharper_accessor_owner_body = expression_body +resharper_alignment_tab_fill_style = use_spaces +resharper_align_first_arg_by_paren = false +resharper_align_linq_query = false +resharper_align_multiline_array_and_object_initializer = false +resharper_align_multiline_array_initializer = true +resharper_align_multiline_ctor_init = true +resharper_align_multiline_expression_braces = false +resharper_align_multiline_implements_list = true +resharper_align_multiline_property_pattern = false +resharper_align_multiline_switch_expression = false +resharper_align_multiline_type_argument = true +resharper_align_multiline_type_parameter = true +resharper_align_multline_type_parameter_constrains = false +resharper_align_multline_type_parameter_list = false +resharper_align_ternary = align_not_nested +resharper_align_tuple_components = false +resharper_allow_alias = true +resharper_allow_comment_after_lbrace = false +resharper_allow_far_alignment = false +resharper_always_use_end_of_line_brace_style = false +resharper_anonymous_method_declaration_braces = next_line +resharper_apply_auto_detected_rules = true +resharper_apply_on_completion = false +resharper_arguments_anonymous_function = positional +resharper_arguments_literal = positional +resharper_arguments_named = positional +resharper_arguments_other = positional +resharper_arguments_skip_single = false +resharper_arguments_string_literal = positional +resharper_attribute_style = do_not_touch +resharper_autodetect_indent_settings = true +resharper_blank_lines_after_block_statements = 1 +resharper_blank_lines_after_case = 0 +resharper_blank_lines_after_control_transfer_statements = 0 +resharper_blank_lines_after_imports = 1 +resharper_blank_lines_after_multiline_statements = 0 +resharper_blank_lines_after_options = 1 +resharper_blank_lines_after_start_comment = 1 +resharper_blank_lines_after_using_list = 1 +resharper_blank_lines_around_accessor = 0 +resharper_blank_lines_around_auto_property = 1 +resharper_blank_lines_around_block_case_section = 0 +resharper_blank_lines_around_class_definition = 1 +resharper_blank_lines_around_field = 1 +resharper_blank_lines_around_function_declaration = 0 +resharper_blank_lines_around_function_definition = 1 +resharper_blank_lines_around_global_attribute = 0 +resharper_blank_lines_around_invocable = 1 +resharper_blank_lines_around_local_method = 1 +resharper_blank_lines_around_multiline_case_section = 0 +resharper_blank_lines_around_namespace = 1 +resharper_blank_lines_around_other_declaration = 0 +resharper_blank_lines_around_property = 1 +resharper_blank_lines_around_razor_functions = 1 +resharper_blank_lines_around_razor_helpers = 1 +resharper_blank_lines_around_razor_sections = 1 +resharper_blank_lines_around_region = 1 +resharper_blank_lines_around_single_line_accessor = 0 +resharper_blank_lines_around_single_line_auto_property = 0 +resharper_blank_lines_around_single_line_field = 0 +resharper_blank_lines_around_single_line_function_definition = 0 +resharper_blank_lines_around_single_line_invocable = 0 +resharper_blank_lines_around_single_line_local_method = 0 +resharper_blank_lines_around_single_line_property = 0 +resharper_blank_lines_around_single_line_type = 1 +resharper_blank_lines_around_type = 1 +resharper_blank_lines_before_block_statements = 0 +resharper_blank_lines_before_case = 0 +resharper_blank_lines_before_control_transfer_statements = 0 +resharper_blank_lines_before_multiline_statements = 0 +resharper_blank_lines_before_single_line_comment = 0 +resharper_blank_lines_inside_namespace = 0 +resharper_blank_lines_inside_region = 1 +resharper_blank_lines_inside_type = 0 +resharper_blank_line_after_pi = true +resharper_braces_for_dowhile = required +resharper_braces_for_fixed = required +resharper_braces_for_for = required +resharper_braces_for_foreach = required +resharper_braces_for_ifelse = required +resharper_braces_for_lock = required +resharper_braces_for_using = required +resharper_braces_for_while = required +resharper_braces_redundant = false +resharper_break_template_declaration = line_break +resharper_can_use_global_alias = true +resharper_constructor_or_destructor_body = block_body +resharper_continuous_indent_multiplier = 1 +resharper_continuous_line_indent = single +resharper_cpp_align_multiline_argument = true +resharper_cpp_align_multiline_binary_expressions_chain = false +resharper_cpp_align_multiline_calls_chain = true +resharper_cpp_align_multiline_extends_list = true +resharper_cpp_align_multiline_for_stmt = true +resharper_cpp_align_multiline_parameter = true +resharper_cpp_align_multiple_declaration = true +resharper_cpp_case_block_braces = next_line_shifted_2 +resharper_cpp_indent_switch_labels = false +resharper_cpp_max_line_length = 120 +resharper_cpp_new_line_before_while = true +resharper_cpp_space_after_cast = false +resharper_cpp_space_around_binary_operator = true +resharper_cpp_wrap_lines = true +resharper_csharp_align_multiline_argument = false +resharper_csharp_align_multiline_binary_expressions_chain = true +resharper_csharp_align_multiline_calls_chain = false +resharper_csharp_align_multiline_expression = false +resharper_csharp_align_multiline_extends_list = false +resharper_csharp_align_multiline_for_stmt = false +resharper_csharp_align_multiline_parameter = false +resharper_csharp_align_multiple_declaration = false +resharper_csharp_max_line_length = 120 +resharper_csharp_naming_rule.enum_member = AaBb +resharper_csharp_naming_rule.method_property_event = AaBb +resharper_csharp_naming_rule.other = AaBb +resharper_csharp_naming_rule.public_fields = aaBb, AaBb +resharper_csharp_new_line_before_while = false +resharper_csharp_prefer_qualified_reference = false +resharper_csharp_space_after_unary_operator = false +resharper_csharp_wrap_lines = true +resharper_cxxcli_property_declaration_braces = next_line +resharper_default_exception_variable_name = e +resharper_default_value_when_type_evident = default_literal +resharper_default_value_when_type_not_evident = default_literal +resharper_delete_quotes_from_solid_values = false +resharper_disable_blank_line_changes = false +resharper_disable_formatter = false +resharper_disable_indenter = false +resharper_disable_int_align = false +resharper_disable_line_break_changes = false +resharper_disable_line_break_removal = false +resharper_disable_space_changes = false +resharper_disable_space_changes_before_trailing_comment = false +resharper_dont_remove_extra_blank_lines = false +resharper_empty_block_style = multiline +resharper_enable_wrapping = false +resharper_enforce_line_ending_style = false +resharper_event_handler_pattern_long = $object$On$event$ +resharper_event_handler_pattern_short = On$event$ +resharper_expression_braces = inside +resharper_expression_pars = inside +resharper_extra_spaces = remove_all +resharper_force_attribute_style = separate +resharper_force_chop_compound_do_expression = false +resharper_force_chop_compound_if_expression = false +resharper_force_chop_compound_while_expression = false +resharper_format_leading_spaces_decl = false +resharper_free_block_braces = next_line +resharper_fsharp_align_function_signature_to_indentation = false +resharper_fsharp_alternative_long_member_definitions = false +resharper_fsharp_indent_on_try_with = false +resharper_fsharp_keep_if_then_in_same_line = false +resharper_fsharp_max_array_or_list_width = 40 +resharper_fsharp_max_elmish_width = 40 +resharper_fsharp_max_function_binding_width = 40 +resharper_fsharp_max_if_then_else_short_width = 40 +resharper_fsharp_max_infix_operator_expression = 50 +resharper_fsharp_max_line_length = 120 +resharper_fsharp_max_record_width = 40 +resharper_fsharp_max_value_binding_width = 40 +resharper_fsharp_multiline_block_brackets_on_same_column = false +resharper_fsharp_newline_between_type_definition_and_members = false +resharper_fsharp_semicolon_at_end_of_line = false +resharper_fsharp_single_argument_web_mode = false +resharper_fsharp_space_after_comma = true +resharper_fsharp_space_after_semicolon = true +resharper_fsharp_space_around_delimiter = true +resharper_fsharp_space_before_class_constructor = false +resharper_fsharp_space_before_colon = false +resharper_fsharp_space_before_lowercase_invocation = true +resharper_fsharp_space_before_member = false +resharper_fsharp_space_before_parameter = true +resharper_fsharp_space_before_semicolon = false +resharper_fsharp_space_before_uppercase_invocation = false +resharper_fsharp_wrap_lines = true +resharper_function_declaration_return_type_style = do_not_change +resharper_function_definition_return_type_style = do_not_change +resharper_generator_mode = false +resharper_html_attribute_indent = align_by_first_attribute +resharper_html_linebreak_before_elements = body,div,p,form,h1,h2,h3 +resharper_html_max_blank_lines_between_tags = 2 +resharper_html_max_line_length = 120 +resharper_html_pi_attribute_style = on_single_line +resharper_html_space_before_self_closing = false +resharper_html_wrap_lines = true +resharper_ignore_space_preservation = false +resharper_include_prefix_comment_in_indent = false +resharper_indent_access_specifiers_from_class = false +resharper_indent_aligned_ternary = true +resharper_indent_anonymous_method_block = false +resharper_indent_case_from_select = true +resharper_indent_child_elements = OneIndent +resharper_indent_class_members_from_access_specifiers = false +resharper_indent_comment = true +resharper_indent_inside_namespace = true +resharper_indent_invocation_pars = inside +resharper_indent_method_decl_pars = inside +resharper_indent_nested_fixed_stmt = false +resharper_indent_nested_foreach_stmt = false +resharper_indent_nested_for_stmt = false +resharper_indent_nested_lock_stmt = false +resharper_indent_nested_usings_stmt = false +resharper_indent_nested_while_stmt = false +resharper_indent_pars = inside +resharper_indent_preprocessor_directives = normal +resharper_indent_preprocessor_if = no_indent +resharper_indent_preprocessor_other = no_indent +resharper_indent_preprocessor_region = usual_indent +resharper_indent_statement_pars = inside +resharper_indent_text = OneIndent +resharper_indent_typearg_angles = inside +resharper_indent_typeparam_angles = inside +resharper_indent_type_constraints = true +resharper_indent_wrapped_function_names = false +resharper_instance_members_qualify_declared_in = this_class, base_class +resharper_int_align = false +resharper_int_align_comments = false +resharper_int_align_declaration_names = false +resharper_int_align_eq = false +resharper_int_align_fix_in_adjacent = true +resharper_invocable_declaration_braces = next_line +resharper_keep_blank_lines_in_code = 2 +resharper_keep_blank_lines_in_declarations = 2 +resharper_keep_existing_attribute_arrangement = true +resharper_keep_existing_declaration_block_arrangement = false +resharper_keep_existing_declaration_parens_arrangement = true +resharper_keep_existing_embedded_arrangement = true +resharper_keep_existing_embedded_block_arrangement = false +resharper_keep_existing_enum_arrangement = false +resharper_keep_existing_expr_member_arrangement = true +resharper_keep_existing_invocation_parens_arrangement = true +resharper_keep_existing_property_patterns_arrangement = true +resharper_keep_existing_switch_expression_arrangement = true +resharper_keep_nontrivial_alias = true +resharper_keep_user_linebreaks = true +resharper_keep_user_wrapping = true +resharper_linebreaks_around_razor_statements = true +resharper_linebreaks_inside_tags_for_elements_longer_than = 2147483647 +resharper_linebreaks_inside_tags_for_elements_with_child_elements = true +resharper_linebreaks_inside_tags_for_multiline_elements = true +resharper_linebreak_before_all_elements = false +resharper_linebreak_before_multiline_elements = true +resharper_linebreak_before_singleline_elements = false +resharper_line_break_after_colon_in_member_initializer_lists = do_not_change +resharper_line_break_after_comma_in_member_initializer_lists = false +resharper_line_break_before_comma_in_member_initializer_lists = false +resharper_linkage_specification_braces = end_of_line +resharper_linkage_specification_indentation = none +resharper_local_function_body = block_body +resharper_max_array_initializer_elements_on_line = 10000 +resharper_max_attribute_length_for_same_line = 38 +resharper_max_enum_members_on_line = 3 +resharper_max_formal_parameters_on_line = 10000 +resharper_max_initializer_elements_on_line = 4 +resharper_max_invocation_arguments_on_line = 10000 +resharper_member_initializer_list_style = do_not_change +resharper_method_or_operator_body = block_body +resharper_namespace_declaration_braces = next_line +resharper_namespace_indentation = all +resharper_nested_ternary_style = autodetect +resharper_never_outdent_pipe_operators = true +resharper_new_line_before_catch = true +resharper_new_line_before_else = true +resharper_new_line_before_enumerators = true +resharper_normalize_tag_names = false +resharper_no_indent_inside_elements = html,body,thead,tbody,tfoot +resharper_no_indent_inside_if_element_longer_than = 200 +resharper_object_creation_when_type_evident = target_typed +resharper_object_creation_when_type_not_evident = explicitly_typed +resharper_old_engine = false +resharper_other_braces = next_line +resharper_outdent_binary_operators = true +resharper_outdent_binary_ops = false +resharper_outdent_commas = false +resharper_outdent_dots = false +resharper_outdent_namespace_member = false +resharper_outdent_ternary_ops = false +resharper_parentheses_non_obvious_operations = none, bitwise, bitwise_inclusive_or, bitwise_exclusive_or, shift, bitwise_and +resharper_parentheses_redundancy_style = remove_if_not_clarifies_precedence +resharper_pi_attributes_indent = align_by_first_attribute +resharper_place_attribute_on_same_line = true +resharper_place_comments_at_first_column = false +resharper_place_constructor_initializer_on_same_line = true +resharper_place_event_attribute_on_same_line = false +resharper_place_expr_accessor_on_single_line = if_owner_is_single_line +resharper_place_expr_method_on_single_line = if_owner_is_single_line +resharper_place_expr_property_on_single_line = if_owner_is_single_line +resharper_place_linq_into_on_new_line = true +resharper_place_namespace_definitions_on_same_line = false +resharper_place_property_attribute_on_same_line = false +resharper_place_simple_case_statement_on_same_line = false +resharper_place_simple_embedded_statement_on_same_line = if_owner_is_single_line +resharper_place_simple_initializer_on_single_line = true +resharper_place_simple_property_pattern_on_single_line = true +resharper_place_simple_switch_expression_on_single_line = false +resharper_place_type_constraints_on_same_line = true +resharper_prefer_explicit_discard_declaration = false +resharper_prefer_separate_deconstructed_variables_declaration = false +resharper_preserve_spaces_inside_tags = pre,textarea +resharper_qualified_using_at_nested_scope = false +resharper_quote_style = doublequoted +resharper_razor_prefer_qualified_reference = true +resharper_remove_blank_lines_near_braces = false +resharper_remove_blank_lines_near_braces_in_code = true +resharper_remove_blank_lines_near_braces_in_declarations = true +resharper_remove_this_qualifier = true +resharper_requires_expression_braces = next_line +resharper_resx_attribute_indent = single_indent +resharper_resx_linebreak_before_elements = +resharper_resx_max_blank_lines_between_tags = 0 +resharper_resx_max_line_length = 2147483647 +resharper_resx_pi_attribute_style = do_not_touch +resharper_resx_space_before_self_closing = false +resharper_resx_wrap_lines = false +resharper_resx_wrap_tags_and_pi = false +resharper_resx_wrap_text = false +resharper_shaderlab_brace_style = next_line +resharper_shaderlab_max_line_length = 120 +resharper_shaderlab_wrap_lines = true +resharper_show_autodetect_configure_formatting_tip = true +resharper_simple_block_style = do_not_change +resharper_simple_case_statement_style = do_not_change +resharper_simple_embedded_statement_style = do_not_change +resharper_sort_attributes = false +resharper_sort_class_selectors = false +resharper_sort_usings = true +resharper_sort_usings_lowercase_first = false +resharper_spaces_around_eq_in_attribute = false +resharper_spaces_around_eq_in_pi_attribute = false +resharper_spaces_inside_tags = false +resharper_space_after_attributes = true +resharper_space_after_attribute_target_colon = true +resharper_space_after_colon = true +resharper_space_after_colon_in_case = true +resharper_space_after_colon_in_inheritance_clause = true +resharper_space_after_comma = true +resharper_space_after_for_colon = true +resharper_space_after_keywords_in_control_flow_statements = true +resharper_space_after_last_attribute = false +resharper_space_after_last_pi_attribute = false +resharper_space_after_operator_keyword = true +resharper_space_after_ptr_in_data_member = true +resharper_space_after_ptr_in_data_members = false +resharper_space_after_ptr_in_method = true +resharper_space_after_ref_in_data_member = true +resharper_space_after_ref_in_data_members = false +resharper_space_after_ref_in_method = true +resharper_space_after_semicolon_in_for_statement = true +resharper_space_after_ternary_colon = true +resharper_space_after_ternary_quest = true +resharper_space_after_triple_slash = true +resharper_space_after_type_parameter_constraint_colon = true +resharper_space_around_additive_op = true +resharper_space_around_alias_eq = true +resharper_space_around_assignment_op = true +resharper_space_around_assignment_operator = true +resharper_space_around_deref_in_trailing_return_type = true +resharper_space_around_lambda_arrow = true +resharper_space_around_member_access_operator = false +resharper_space_around_relational_op = true +resharper_space_around_shift_op = true +resharper_space_around_stmt_colon = true +resharper_space_around_ternary_operator = true +resharper_space_before_array_rank_parentheses = false +resharper_space_before_attribute_target_colon = false +resharper_space_before_checked_parentheses = false +resharper_space_before_colon = false +resharper_space_before_colon_in_case = false +resharper_space_before_colon_in_inheritance_clause = true +resharper_space_before_comma = false +resharper_space_before_default_parentheses = false +resharper_space_before_empty_invocation_parentheses = false +resharper_space_before_empty_method_parentheses = false +resharper_space_before_for_colon = true +resharper_space_before_initializer_braces = false +resharper_space_before_invocation_parentheses = false +resharper_space_before_label_colon = false +resharper_space_before_lambda_parentheses = false +resharper_space_before_method_parentheses = false +resharper_space_before_nameof_parentheses = false +resharper_space_before_nullable_mark = false +resharper_space_before_open_square_brackets = false +resharper_space_before_pointer_asterik_declaration = false +resharper_space_before_ptr_in_abstract_decl = false +resharper_space_before_ptr_in_data_member = false +resharper_space_before_ptr_in_data_members = true +resharper_space_before_ptr_in_method = false +resharper_space_before_ref_in_abstract_decl = false +resharper_space_before_ref_in_data_member = false +resharper_space_before_ref_in_data_members = true +resharper_space_before_ref_in_method = false +resharper_space_before_semicolon = false +resharper_space_before_semicolon_in_for_statement = false +resharper_space_before_singleline_accessorholder = true +resharper_space_before_sizeof_parentheses = false +resharper_space_before_template_args = false +resharper_space_before_template_params = true +resharper_space_before_ternary_colon = true +resharper_space_before_ternary_quest = true +resharper_space_before_trailing_comment = true +resharper_space_before_typeof_parentheses = false +resharper_space_before_type_argument_angle = false +resharper_space_before_type_parameter_angle = false +resharper_space_before_type_parameter_constraint_colon = true +resharper_space_before_type_parameter_parentheses = true +resharper_space_between_accessors_in_singleline_property = true +resharper_space_between_attribute_sections = true +resharper_space_between_closing_angle_brackets_in_template_args = false +resharper_space_between_keyword_and_expression = true +resharper_space_between_keyword_and_type = true +resharper_space_between_method_call_empty_parameter_list_parentheses = false +resharper_space_between_method_call_name_and_opening_parenthesis = false +resharper_space_between_method_call_parameter_list_parentheses = false +resharper_space_between_method_declaration_empty_parameter_list_parentheses = false +resharper_space_between_method_declaration_name_and_open_parenthesis = false +resharper_space_between_method_declaration_parameter_list_parentheses = false +resharper_space_between_parentheses_of_control_flow_statements = false +resharper_space_between_square_brackets = false +resharper_space_between_typecast_parentheses = false +resharper_space_in_singleline_accessorholder = true +resharper_space_in_singleline_anonymous_method = true +resharper_space_in_singleline_method = true +resharper_space_near_postfix_and_prefix_op = false +resharper_space_within_array_initialization_braces = false +resharper_space_within_array_rank_empty_parentheses = false +resharper_space_within_array_rank_parentheses = false +resharper_space_within_attribute_angles = false +resharper_space_within_checked_parentheses = false +resharper_space_within_default_parentheses = false +resharper_space_within_empty_braces = true +resharper_space_within_empty_initializer_braces = false +resharper_space_within_empty_invocation_parentheses = false +resharper_space_within_empty_method_parentheses = false +resharper_space_within_empty_template_params = false +resharper_space_within_expression_parentheses = false +resharper_space_within_initializer_braces = false +resharper_space_within_invocation_parentheses = false +resharper_space_within_method_parentheses = false +resharper_space_within_nameof_parentheses = false +resharper_space_within_parentheses = false +resharper_space_within_single_line_array_initializer_braces = false +resharper_space_within_sizeof_parentheses = false +resharper_space_within_template_args = false +resharper_space_within_template_params = false +resharper_space_within_tuple_parentheses = false +resharper_space_within_typeof_parentheses = false +resharper_space_within_type_argument_angles = false +resharper_space_within_type_parameter_angles = false +resharper_space_within_type_parameter_parentheses = false +resharper_special_else_if_treatment = true +resharper_static_members_qualify_members = none +resharper_static_members_qualify_with = declared_type +resharper_stick_comment = true +resharper_support_vs_event_naming_pattern = true +resharper_toplevel_function_declaration_return_type_style = do_not_change +resharper_toplevel_function_definition_return_type_style = do_not_change +resharper_trailing_comma_in_multiline_lists = true +resharper_trailing_comma_in_singleline_lists = true +resharper_type_declaration_braces = next_line +resharper_use_continuous_indent_inside_initializer_braces = true +resharper_use_continuous_indent_inside_parens = true +resharper_use_continuous_line_indent_in_expression_braces = false +resharper_use_continuous_line_indent_in_method_pars = false +resharper_use_heuristics_for_body_style = true +resharper_use_indents_from_main_language_in_file = true +resharper_use_indent_from_previous_element = true +resharper_use_indent_from_vs = false +resharper_use_roslyn_logic_for_evident_types = false +resharper_vb_align_multiline_argument = true +resharper_vb_align_multiline_expression = true +resharper_vb_align_multiline_parameter = true +resharper_vb_align_multiple_declaration = true +resharper_vb_max_line_length = 120 +resharper_vb_place_field_attribute_on_same_line = true +resharper_vb_place_method_attribute_on_same_line = false +resharper_vb_place_type_attribute_on_same_line = false +resharper_vb_prefer_qualified_reference = false +resharper_vb_space_after_unary_operator = true +resharper_vb_space_around_multiplicative_op = false +resharper_vb_wrap_lines = true +resharper_wrap_after_binary_opsign = true +resharper_wrap_after_declaration_lpar = false +resharper_wrap_after_dot = false +resharper_wrap_after_dot_in_method_calls = false +resharper_wrap_after_expression_lbrace = true +resharper_wrap_after_invocation_lpar = false +resharper_wrap_arguments_style = wrap_if_long +resharper_wrap_around_elements = true +resharper_wrap_array_initializer_style = wrap_if_long +resharper_wrap_base_clause_style = wrap_if_long +resharper_wrap_before_arrow_with_expressions = false +resharper_wrap_before_binary_opsign = false +resharper_wrap_before_colon = false +resharper_wrap_before_comma = false +resharper_wrap_before_comma_in_base_clause = false +resharper_wrap_before_declaration_lpar = false +resharper_wrap_before_declaration_rpar = false +resharper_wrap_before_expression_rbrace = true +resharper_wrap_before_extends_colon = false +resharper_wrap_before_first_type_parameter_constraint = false +resharper_wrap_before_invocation_lpar = false +resharper_wrap_before_invocation_rpar = false +resharper_wrap_before_linq_expression = false +resharper_wrap_before_ternary_opsigns = true +resharper_wrap_before_type_parameter_langle = false +resharper_wrap_braced_init_list_style = wrap_if_long +resharper_wrap_chained_binary_expressions = wrap_if_long +resharper_wrap_chained_method_calls = wrap_if_long +resharper_wrap_ctor_initializer_style = wrap_if_long +resharper_wrap_enumeration_style = chop_if_long +resharper_wrap_enum_declaration = chop_always +resharper_wrap_extends_list_style = wrap_if_long +resharper_wrap_for_stmt_header_style = chop_if_long +resharper_wrap_multiple_declaration_style = chop_if_long +resharper_wrap_multiple_type_parameter_constraints_style = chop_if_long +resharper_wrap_object_and_collection_initializer_style = chop_if_long +resharper_wrap_parameters_style = wrap_if_long +resharper_wrap_property_pattern = chop_if_long +resharper_wrap_switch_expression = chop_always +resharper_wrap_ternary_expr_style = chop_if_long +resharper_wrap_verbatim_interpolated_strings = no_wrap +resharper_xmldoc_attribute_indent = single_indent +resharper_xmldoc_linebreak_before_elements = summary,remarks,example,returns,param,typeparam,value,para +resharper_xmldoc_max_blank_lines_between_tags = 0 +resharper_xmldoc_max_line_length = 120 +resharper_xmldoc_pi_attribute_style = do_not_touch +resharper_xmldoc_space_before_self_closing = true +resharper_xmldoc_wrap_lines = true +resharper_xmldoc_wrap_tags_and_pi = true +resharper_xmldoc_wrap_text = true +resharper_xml_attribute_indent = align_by_first_attribute +resharper_xml_linebreak_before_elements = +resharper_xml_max_blank_lines_between_tags = 2 +resharper_xml_max_line_length = 120 +resharper_xml_pi_attribute_style = do_not_touch +resharper_xml_space_before_self_closing = true +resharper_xml_wrap_lines = true +resharper_xml_wrap_tags_and_pi = true +resharper_xml_wrap_text = false + +[*.asmdef] +indent_style = space +indent_size = 2 + +[*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,fs,fsi,fsscript,fsx,hlsl,hlsli,hlslinc,master,ml,mli,nuspec,paml,razor,resw,resx,shader,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}] +indent_style = space +indent_size = 4 +tab_width = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f29edfc --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +*.*~ +*.db +*.sln +*.userprefs +*.csproj +*.pidb +*.unityproj +*.apk +*.stackdump +/Library +/obj +/Temp +/Build* +/Logs/ +/AssetBundles +/Logs/ +.vs +.vscode +.idea +.gradle +*_LEGACY +*.DotSettings.user +/Assets/Plugins/Editor/JetBrains* +/Assets/LEGACY* +/Assets/TextMesh Pro* +/Assets/Plugins/Sirenix* \ No newline at end of file diff --git a/Editor.Extras.meta b/Editor.Extras.meta new file mode 100644 index 0000000..c0e380c --- /dev/null +++ b/Editor.Extras.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a7f4b4fc58f88d3459559029b269259e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor.Extras/Drawers.meta b/Editor.Extras/Drawers.meta new file mode 100644 index 0000000..21d24bd --- /dev/null +++ b/Editor.Extras/Drawers.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 62b6b24478bb48c4acc0f072f2687607 +timeCreated: 1639376870 \ No newline at end of file diff --git a/Editor.Extras/Drawers/BoolDrawer.cs b/Editor.Extras/Drawers/BoolDrawer.cs new file mode 100644 index 0000000..0bebbe6 --- /dev/null +++ b/Editor.Extras/Drawers/BoolDrawer.cs @@ -0,0 +1,41 @@ +using TriInspector; +using TriInspector.Drawers; +using UnityEditor; +using UnityEngine; + +[assembly: RegisterTriDrawer(typeof(BoolDrawer), TriDrawerOrder.Fallback)] + +namespace TriInspector.Drawers +{ + public class BoolDrawer : TriValueDrawer + { + public override TriElement CreateElement(TriValue propertyValue, TriElement next) + { + if (propertyValue.Property.TryGetSerializedProperty(out _)) + { + return next; + } + + return base.CreateElement(propertyValue, next); + } + + public override float GetHeight(float width, TriValue propertyValue, TriElement next) + { + return EditorGUIUtility.singleLineHeight; + } + + public override void OnGUI(Rect position, TriValue propertyValue, TriElement next) + { + var value = propertyValue.Value; + + EditorGUI.BeginChangeCheck(); + + value = EditorGUI.Toggle(position, propertyValue.Property.DisplayNameContent, value); + + if (EditorGUI.EndChangeCheck()) + { + propertyValue.Value = value; + } + } + } +} \ No newline at end of file diff --git a/Editor.Extras/Drawers/BoolDrawer.cs.meta b/Editor.Extras/Drawers/BoolDrawer.cs.meta new file mode 100644 index 0000000..8daeed9 --- /dev/null +++ b/Editor.Extras/Drawers/BoolDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e7795a3fa9734e729f1567c86c4926c5 +timeCreated: 1639317854 \ No newline at end of file diff --git a/Editor.Extras/Drawers/FloatDrawer.cs b/Editor.Extras/Drawers/FloatDrawer.cs new file mode 100644 index 0000000..db1582f --- /dev/null +++ b/Editor.Extras/Drawers/FloatDrawer.cs @@ -0,0 +1,41 @@ +using TriInspector; +using TriInspector.Drawers; +using UnityEditor; +using UnityEngine; + +[assembly: RegisterTriDrawer(typeof(FloatDrawer), TriDrawerOrder.Fallback)] + +namespace TriInspector.Drawers +{ + public class FloatDrawer : TriValueDrawer + { + public override TriElement CreateElement(TriValue propertyValue, TriElement next) + { + if (propertyValue.Property.TryGetSerializedProperty(out _)) + { + return next; + } + + return base.CreateElement(propertyValue, next); + } + + public override float GetHeight(float width, TriValue propertyValue, TriElement next) + { + return EditorGUIUtility.singleLineHeight; + } + + public override void OnGUI(Rect position, TriValue propertyValue, TriElement next) + { + var value = propertyValue.Value; + + EditorGUI.BeginChangeCheck(); + + value = EditorGUI.FloatField(position, propertyValue.Property.DisplayNameContent, value); + + if (EditorGUI.EndChangeCheck()) + { + propertyValue.Value = value; + } + } + } +} \ No newline at end of file diff --git a/Editor.Extras/Drawers/FloatDrawer.cs.meta b/Editor.Extras/Drawers/FloatDrawer.cs.meta new file mode 100644 index 0000000..0e78c8c --- /dev/null +++ b/Editor.Extras/Drawers/FloatDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 519fae04e2154ae69d75d5f131a8678c +timeCreated: 1639384497 \ No newline at end of file diff --git a/Editor.Extras/Drawers/GUIColorDrawer.cs b/Editor.Extras/Drawers/GUIColorDrawer.cs new file mode 100644 index 0000000..6b47473 --- /dev/null +++ b/Editor.Extras/Drawers/GUIColorDrawer.cs @@ -0,0 +1,25 @@ +using TriInspector; +using TriInspector.Drawers; +using UnityEngine; + +[assembly: RegisterTriDrawer(typeof(GUIColorDrawer), TriDrawerOrder.Decorator)] + +namespace TriInspector.Drawers +{ + public class GUIColorDrawer : TriAttributeDrawer + { + public override void OnGUI(Rect position, TriProperty property, TriElement next) + { + var oldColor = GUI.color; + var newColor = new Color(Attribute.R, Attribute.G, Attribute.B, Attribute.A); + + GUI.color = newColor; + GUI.contentColor = newColor; + + next.OnGUI(position); + + GUI.color = oldColor; + GUI.contentColor = oldColor; + } + } +} \ No newline at end of file diff --git a/Editor.Extras/Drawers/GUIColorDrawer.cs.meta b/Editor.Extras/Drawers/GUIColorDrawer.cs.meta new file mode 100644 index 0000000..3f02c4f --- /dev/null +++ b/Editor.Extras/Drawers/GUIColorDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3e34331cbcd3451cb18c9cc11c43f7b3 +timeCreated: 1638943578 \ No newline at end of file diff --git a/Editor.Extras/Drawers/IndentDrawer.cs b/Editor.Extras/Drawers/IndentDrawer.cs new file mode 100644 index 0000000..42e19c2 --- /dev/null +++ b/Editor.Extras/Drawers/IndentDrawer.cs @@ -0,0 +1,19 @@ +using TriInspector; +using TriInspector.Drawers; +using TriInspector.Utilities; +using UnityEngine; + +[assembly: RegisterTriDrawer(typeof(IndentDrawer), TriDrawerOrder.Decorator)] + +namespace TriInspector.Drawers +{ + public class IndentDrawer : TriAttributeDrawer + { + public override void OnGUI(Rect position, TriProperty property, TriElement next) + { + TriGuiHelper.PushIndentLevel(Attribute.Indent); + next.OnGUI(position); + TriGuiHelper.PopIndentLevel(); + } + } +} \ No newline at end of file diff --git a/Editor.Extras/Drawers/IndentDrawer.cs.meta b/Editor.Extras/Drawers/IndentDrawer.cs.meta new file mode 100644 index 0000000..b658fcb --- /dev/null +++ b/Editor.Extras/Drawers/IndentDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 53bdb27623d2437a9af368e1342d9176 +timeCreated: 1638947263 \ No newline at end of file diff --git a/Editor.Extras/Drawers/LabelWidthDrawer.cs b/Editor.Extras/Drawers/LabelWidthDrawer.cs new file mode 100644 index 0000000..3d6d968 --- /dev/null +++ b/Editor.Extras/Drawers/LabelWidthDrawer.cs @@ -0,0 +1,21 @@ +using TriInspector; +using TriInspector.Drawers; +using UnityEditor; +using UnityEngine; + +[assembly: RegisterTriDrawer(typeof(LabelWidthDrawer), TriDrawerOrder.Decorator)] + +namespace TriInspector.Drawers +{ + public class LabelWidthDrawer : TriAttributeDrawer + { + public override void OnGUI(Rect position, TriProperty property, TriElement next) + { + var oldLabelWidth = EditorGUIUtility.labelWidth; + + EditorGUIUtility.labelWidth = Attribute.Width; + next.OnGUI(position); + EditorGUIUtility.labelWidth = oldLabelWidth; + } + } +} \ No newline at end of file diff --git a/Editor.Extras/Drawers/LabelWidthDrawer.cs.meta b/Editor.Extras/Drawers/LabelWidthDrawer.cs.meta new file mode 100644 index 0000000..557e316 --- /dev/null +++ b/Editor.Extras/Drawers/LabelWidthDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d7bb028f84224ec5817b1c807ca5db86 +timeCreated: 1638948103 \ No newline at end of file diff --git a/Editor.Extras/Drawers/PropertySpaceDrawer.cs b/Editor.Extras/Drawers/PropertySpaceDrawer.cs new file mode 100644 index 0000000..70f0934 --- /dev/null +++ b/Editor.Extras/Drawers/PropertySpaceDrawer.cs @@ -0,0 +1,29 @@ +using TriInspector; +using TriInspector.Drawers; +using UnityEngine; + +[assembly: RegisterTriDrawer(typeof(PropertySpaceDrawer), TriDrawerOrder.Inspector)] + +namespace TriInspector.Drawers +{ + public class PropertySpaceDrawer : TriAttributeDrawer + { + public override float GetHeight(float width, TriProperty property, TriElement next) + { + var totalSpace = Attribute.SpaceBefore + Attribute.SpaceAfter; + + return next.GetHeight(width) + totalSpace; + } + + public override void OnGUI(Rect position, TriProperty property, TriElement next) + { + var contentPosition = new Rect(position) + { + yMin = position.yMin + Attribute.SpaceBefore, + yMax = position.yMax - Attribute.SpaceAfter, + }; + + next.OnGUI(contentPosition); + } + } +} \ No newline at end of file diff --git a/Editor.Extras/Drawers/PropertySpaceDrawer.cs.meta b/Editor.Extras/Drawers/PropertySpaceDrawer.cs.meta new file mode 100644 index 0000000..1d4aeb8 --- /dev/null +++ b/Editor.Extras/Drawers/PropertySpaceDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d703a4146e75487aa57e22f375b04c32 +timeCreated: 1638942558 \ No newline at end of file diff --git a/Editor.Extras/Drawers/ShowDrawerChainDrawer.cs b/Editor.Extras/Drawers/ShowDrawerChainDrawer.cs new file mode 100644 index 0000000..e8f546c --- /dev/null +++ b/Editor.Extras/Drawers/ShowDrawerChainDrawer.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using System.Text; +using TriInspector; +using TriInspector.Drawers; +using TriInspector.Elements; + +[assembly: RegisterTriDrawer(typeof(ShowDrawerChainDrawer), TriDrawerOrder.System)] + +namespace TriInspector.Drawers +{ + public class ShowDrawerChainDrawer : TriCustomDrawer + { + public override TriElement CreateElementInternal(TriProperty property, TriElement next) + { + return new TriDrawerChainInfoElement(property.AllDrawers); + } + } + + public class TriDrawerChainInfoElement : TriElement + { + public TriDrawerChainInfoElement(IReadOnlyList drawers) + { + var info = new StringBuilder(); + + info.Append("Drawer Chain:"); + + for (var i = 0; i < drawers.Count; i++) + { + var drawer = drawers[i]; + info.AppendLine(); + info.Append(i).Append(": ").Append(drawer.GetType().Name); + } + + AddChild(new TriInfoBoxElement(info.ToString())); + } + } +} \ No newline at end of file diff --git a/Editor.Extras/Drawers/ShowDrawerChainDrawer.cs.meta b/Editor.Extras/Drawers/ShowDrawerChainDrawer.cs.meta new file mode 100644 index 0000000..f53101f --- /dev/null +++ b/Editor.Extras/Drawers/ShowDrawerChainDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d473213c669247e48e0059471d0b6d2c +timeCreated: 1639215046 \ No newline at end of file diff --git a/Editor.Extras/Drawers/StringDrawer.cs b/Editor.Extras/Drawers/StringDrawer.cs new file mode 100644 index 0000000..4be5220 --- /dev/null +++ b/Editor.Extras/Drawers/StringDrawer.cs @@ -0,0 +1,71 @@ +using TriInspector; +using TriInspector.Drawers; +using UnityEditor; +using UnityEngine; + +[assembly: RegisterTriDrawer(typeof(StringDrawer), TriDrawerOrder.Fallback)] + +namespace TriInspector.Drawers +{ + public class StringDrawer : TriValueDrawer + { + public override TriElement CreateElement(TriValue value, TriElement next) + { + if (value.Property.TryGetSerializedProperty(out var serializedProperty)) + { + return new StringSerializedPropertyDrawerElement(serializedProperty); + } + + return new StringDrawerElement(value); + } + + private class StringDrawerElement : TriElement + { + private readonly TriValue _propertyValue; + + public StringDrawerElement(TriValue propertyValue) + { + _propertyValue = propertyValue; + } + + public override float GetHeight(float width) + { + return EditorGUIUtility.singleLineHeight; + } + + public override void OnGUI(Rect position) + { + var value = _propertyValue.Value; + + EditorGUI.BeginChangeCheck(); + + value = EditorGUI.TextField(position, _propertyValue.Property.DisplayNameContent, value); + + if (EditorGUI.EndChangeCheck()) + { + _propertyValue.Value = value; + } + } + } + + private class StringSerializedPropertyDrawerElement : TriElement + { + private readonly SerializedProperty _serializedProperty; + + public StringSerializedPropertyDrawerElement(SerializedProperty serializedProperty) + { + _serializedProperty = serializedProperty; + } + + public override float GetHeight(float width) + { + return EditorGUIUtility.singleLineHeight; + } + + public override void OnGUI(Rect position) + { + EditorGUI.PropertyField(position, _serializedProperty); + } + } + } +} \ No newline at end of file diff --git a/Editor.Extras/Drawers/StringDrawer.cs.meta b/Editor.Extras/Drawers/StringDrawer.cs.meta new file mode 100644 index 0000000..b20f2bf --- /dev/null +++ b/Editor.Extras/Drawers/StringDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6e5a2105103347338b704022e9a860d4 +timeCreated: 1639316821 \ No newline at end of file diff --git a/Editor.Extras/Drawers/TitleDrawer.cs b/Editor.Extras/Drawers/TitleDrawer.cs new file mode 100644 index 0000000..1e3a206 --- /dev/null +++ b/Editor.Extras/Drawers/TitleDrawer.cs @@ -0,0 +1,53 @@ +using TriInspector; +using TriInspector.Drawers; +using UnityEditor; +using UnityEngine; + +[assembly: RegisterTriDrawer(typeof(TitleDrawer), TriDrawerOrder.Inspector)] + +namespace TriInspector.Drawers +{ + public class TitleDrawer : TriAttributeDrawer + { + private const int SpaceBeforeTitle = 9; + private const int SpaceBeforeLine = 2; + private const int LineHeight = 2; + private const int SpaceBeforeContent = 3; + + public override float GetHeight(float width, TriProperty property, TriElement next) + { + var extraHeight = SpaceBeforeTitle + + EditorGUIUtility.singleLineHeight + + SpaceBeforeLine + + LineHeight + + SpaceBeforeContent; + + return next.GetHeight(width) + extraHeight; + } + + public override void OnGUI(Rect position, TriProperty property, TriElement next) + { + var titleRect = new Rect(position) + { + y = position.y + SpaceBeforeTitle, + height = EditorGUIUtility.singleLineHeight, + }; + + var lineRect = new Rect(position) + { + y = titleRect.yMax + SpaceBeforeLine, + height = LineHeight, + }; + + var contentRect = new Rect(position) + { + yMin = lineRect.yMax + SpaceBeforeContent, + }; + + GUI.Label(titleRect, Attribute.Title, EditorStyles.boldLabel); + EditorGUI.DrawRect(lineRect, Color.gray); + + next.OnGUI(contentRect); + } + } +} \ No newline at end of file diff --git a/Editor.Extras/Drawers/TitleDrawer.cs.meta b/Editor.Extras/Drawers/TitleDrawer.cs.meta new file mode 100644 index 0000000..ad2c342 --- /dev/null +++ b/Editor.Extras/Drawers/TitleDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2ad25a9f98e94ba1aafe184b7fed387d +timeCreated: 1638944499 \ No newline at end of file diff --git a/Editor.Extras/GroupDrawers.meta b/Editor.Extras/GroupDrawers.meta new file mode 100644 index 0000000..c0dc0ed --- /dev/null +++ b/Editor.Extras/GroupDrawers.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f1f781f159fb4215882cf59a6c4cbfa4 +timeCreated: 1639417598 \ No newline at end of file diff --git a/Editor.Extras/GroupDrawers/TriBoxGroupDrawer.cs b/Editor.Extras/GroupDrawers/TriBoxGroupDrawer.cs new file mode 100644 index 0000000..7a7773e --- /dev/null +++ b/Editor.Extras/GroupDrawers/TriBoxGroupDrawer.cs @@ -0,0 +1,90 @@ +using TriInspector; +using TriInspector.Elements; +using TriInspector.GroupDrawers; +using TriInspector.Utilities; +using UnityEditor; +using UnityEngine; + +[assembly: RegisterTriGroupDrawer(typeof(TriBoxGroupDrawer))] + +namespace TriInspector.GroupDrawers +{ + public class TriBoxGroupDrawer : TriGroupDrawer + { + public override TriPropertyCollectionBaseElement CreateElement(DeclareBoxGroupAttribute attribute) + { + return new TriBoxGroupElement(attribute); + } + + private class TriBoxGroupElement : TriPropertyCollectionBaseElement + { + private const float HeaderWidth = 22; + private const float InsetTop = 4; + private const float InsetBottom = 4; + private const float InsetLeft = 4; + private const float InsetRight = 4; + + private readonly GUIContent _headerLabel; + + public TriBoxGroupElement(DeclareBoxGroupAttribute attribute) + { + _headerLabel = attribute.Title == null + ? GUIContent.none + : new GUIContent(attribute.Title); + } + + public override float GetHeight(float width) + { + var height = base.GetHeight(width) + InsetTop + InsetBottom; + + if (_headerLabel != GUIContent.none) + { + height += HeaderWidth; + } + + return height; + } + + public override void OnGUI(Rect position) + { + var headerBgRect = new Rect(position) + { + height = _headerLabel != GUIContent.none ? HeaderWidth : 0, + }; + var headerLabelRect = new Rect(headerBgRect) + { + xMin = headerBgRect.xMin + 6, + xMax = headerBgRect.xMax - 6, + yMin = headerBgRect.yMin + 2, + yMax = headerBgRect.yMax - 2, + }; + var contentBgRect = new Rect(position) + { + yMin = headerBgRect.yMax, + }; + var contentRect = new Rect(contentBgRect) + { + xMin = contentBgRect.xMin + InsetLeft, + xMax = contentBgRect.xMax - InsetRight, + yMin = contentBgRect.yMin + InsetTop, + yMax = contentBgRect.yMax - InsetBottom, + }; + + if (_headerLabel != GUIContent.none) + { + TriEditorGUI.DrawBox(headerBgRect, TriEditorStyles.HeaderBox); + EditorGUI.LabelField(headerLabelRect, _headerLabel); + TriEditorGUI.DrawBox(contentBgRect, TriEditorStyles.ContentBox); + } + else + { + TriEditorGUI.DrawBox(contentBgRect, TriEditorStyles.Box); + } + + TriGuiHelper.PushLabelWidth(EditorGUIUtility.labelWidth - InsetLeft); + base.OnGUI(contentRect); + TriGuiHelper.PopLabelWidth(); + } + } + } +} \ No newline at end of file diff --git a/Editor.Extras/GroupDrawers/TriBoxGroupDrawer.cs.meta b/Editor.Extras/GroupDrawers/TriBoxGroupDrawer.cs.meta new file mode 100644 index 0000000..0a2af20 --- /dev/null +++ b/Editor.Extras/GroupDrawers/TriBoxGroupDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 735d0d9ee1cc4692ac11013b95983551 +timeCreated: 1639417619 \ No newline at end of file diff --git a/Editor.Extras/GroupDrawers/TriHorizontalGroupDrawer.cs b/Editor.Extras/GroupDrawers/TriHorizontalGroupDrawer.cs new file mode 100644 index 0000000..66ad502 --- /dev/null +++ b/Editor.Extras/GroupDrawers/TriHorizontalGroupDrawer.cs @@ -0,0 +1,63 @@ +using TriInspector; +using TriInspector.Elements; +using TriInspector.GroupDrawers; +using UnityEngine; + +[assembly: RegisterTriGroupDrawer(typeof(TriHorizontalGroupDrawer))] + +namespace TriInspector.GroupDrawers +{ + public class TriHorizontalGroupDrawer : TriGroupDrawer + { + public override TriPropertyCollectionBaseElement CreateElement(DeclareHorizontalGroupAttribute attribute) + { + return new TriBoxGroupElement(); + } + + private class TriBoxGroupElement : TriPropertyCollectionBaseElement + { + public override float GetHeight(float width) + { + if (ChildrenCount == 0) + { + return 0f; + } + + var height = 0f; + + for (var i = 0; i < ChildrenCount; i++) + { + var child = GetChild(i); + var childWidth = width / ChildrenCount; + var childHeight = child.GetHeight(childWidth); + + height = Mathf.Max(height, childHeight); + } + + return height; + } + + public override void OnGUI(Rect position) + { + if (ChildrenCount == 0) + { + return; + } + + var childWidth = position.width / ChildrenCount; + + for (var i = 0; i < ChildrenCount; i++) + { + var child = GetChild(i); + var childRect = new Rect(position) + { + width = childWidth, + x = position.x + i * childWidth, + }; + + child.OnGUI(childRect); + } + } + } + } +} \ No newline at end of file diff --git a/Editor.Extras/GroupDrawers/TriHorizontalGroupDrawer.cs.meta b/Editor.Extras/GroupDrawers/TriHorizontalGroupDrawer.cs.meta new file mode 100644 index 0000000..af3cf70 --- /dev/null +++ b/Editor.Extras/GroupDrawers/TriHorizontalGroupDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 866eb8cc0f46446b8ceb1b2cb78b344c +timeCreated: 1640871674 \ No newline at end of file diff --git a/Editor.Extras/TriInspector.Editor.Extras.asmdef b/Editor.Extras/TriInspector.Editor.Extras.asmdef new file mode 100644 index 0000000..cb9fffb --- /dev/null +++ b/Editor.Extras/TriInspector.Editor.Extras.asmdef @@ -0,0 +1,19 @@ +{ + "name": "TriInspector.Editor.Extras", + "rootNamespace": "", + "references": [ + "TriInspector", + "TriInspector.Editor" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": false, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Editor.Extras/TriInspector.Editor.Extras.asmdef.meta b/Editor.Extras/TriInspector.Editor.Extras.asmdef.meta new file mode 100644 index 0000000..be9a032 --- /dev/null +++ b/Editor.Extras/TriInspector.Editor.Extras.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7be4600869ec09d4ca9a37d1dbfbf1a2 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor.meta b/Editor.meta new file mode 100644 index 0000000..d72f06a --- /dev/null +++ b/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 992bfd855a98c4f45b7f93c37256f4ce +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Attributes.cs b/Editor/Attributes.cs new file mode 100644 index 0000000..4076a3e --- /dev/null +++ b/Editor/Attributes.cs @@ -0,0 +1,29 @@ +using System; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] + public class RegisterTriDrawerAttribute : Attribute + { + public RegisterTriDrawerAttribute(Type drawerType, int order) + { + DrawerType = drawerType; + Order = order; + } + + public Type DrawerType { get; } + public int Order { get; } + public bool ApplyOnArrayElement { get; set; } + } + + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] + public class RegisterTriGroupDrawerAttribute : Attribute + { + public RegisterTriGroupDrawerAttribute(Type drawerType) + { + DrawerType = drawerType; + } + + public Type DrawerType { get; } + } +} \ No newline at end of file diff --git a/Editor/Attributes.cs.meta b/Editor/Attributes.cs.meta new file mode 100644 index 0000000..9907c83 --- /dev/null +++ b/Editor/Attributes.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 83289a1468a54453b62573925bc0635a +timeCreated: 1639581370 \ No newline at end of file diff --git a/Editor/Editors.meta b/Editor/Editors.meta new file mode 100644 index 0000000..9fae034 --- /dev/null +++ b/Editor/Editors.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d685f31e94904c5d9319405aa8b775f9 +timeCreated: 1638856449 \ No newline at end of file diff --git a/Editor/Editors/MonoBehaviourEditor.cs b/Editor/Editors/MonoBehaviourEditor.cs new file mode 100644 index 0000000..03ad818 --- /dev/null +++ b/Editor/Editors/MonoBehaviourEditor.cs @@ -0,0 +1,13 @@ +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Editors +{ +#if TRI_INSPECTOR + [CanEditMultipleObjects] + [CustomEditor(typeof(MonoBehaviour), true, isFallback = true)] + internal sealed class MonoBehaviourEditor : TriEditor + { + } +#endif +} \ No newline at end of file diff --git a/Editor/Editors/MonoBehaviourEditor.cs.meta b/Editor/Editors/MonoBehaviourEditor.cs.meta new file mode 100644 index 0000000..914fdde --- /dev/null +++ b/Editor/Editors/MonoBehaviourEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1c8274dd1fc8462c81ee2518b617d0f4 +timeCreated: 1638716636 \ No newline at end of file diff --git a/Editor/Editors/ScriptableObjectEditor.cs b/Editor/Editors/ScriptableObjectEditor.cs new file mode 100644 index 0000000..07ce8cf --- /dev/null +++ b/Editor/Editors/ScriptableObjectEditor.cs @@ -0,0 +1,13 @@ +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Editors +{ +#if TRI_INSPECTOR + [CanEditMultipleObjects] + [CustomEditor(typeof(ScriptableObject), true, isFallback = true)] + internal sealed class ScriptableObjectEditor : TriEditor + { + } +#endif +} \ No newline at end of file diff --git a/Editor/Editors/ScriptableObjectEditor.cs.meta b/Editor/Editors/ScriptableObjectEditor.cs.meta new file mode 100644 index 0000000..326fce0 --- /dev/null +++ b/Editor/Editors/ScriptableObjectEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 821b3e07ed6e47bfb89586d61fcaa8fc +timeCreated: 1638716639 \ No newline at end of file diff --git a/Editor/Editors/TriMonoBehaviourEditor.cs b/Editor/Editors/TriMonoBehaviourEditor.cs new file mode 100644 index 0000000..821fcc0 --- /dev/null +++ b/Editor/Editors/TriMonoBehaviourEditor.cs @@ -0,0 +1,10 @@ +using UnityEditor; + +namespace TriInspector.Editors +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(TriMonoBehaviour), true, isFallback = true)] + internal sealed class TriMonoBehaviourEditor : TriEditor + { + } +} \ No newline at end of file diff --git a/Editor/Editors/TriMonoBehaviourEditor.cs.meta b/Editor/Editors/TriMonoBehaviourEditor.cs.meta new file mode 100644 index 0000000..b67fd73 --- /dev/null +++ b/Editor/Editors/TriMonoBehaviourEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 223f94884b20464e911c7837f76dd64a +timeCreated: 1638856605 \ No newline at end of file diff --git a/Editor/Editors/TriScriptableObjectEditor.cs b/Editor/Editors/TriScriptableObjectEditor.cs new file mode 100644 index 0000000..ff70fb0 --- /dev/null +++ b/Editor/Editors/TriScriptableObjectEditor.cs @@ -0,0 +1,10 @@ +using UnityEditor; + +namespace TriInspector.Editors +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(TriScriptableObject), true, isFallback = true)] + internal sealed class TriScriptableObjectEditor : TriEditor + { + } +} \ No newline at end of file diff --git a/Editor/Editors/TriScriptableObjectEditor.cs.meta b/Editor/Editors/TriScriptableObjectEditor.cs.meta new file mode 100644 index 0000000..57fc7c6 --- /dev/null +++ b/Editor/Editors/TriScriptableObjectEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4ed91dbccd1a4cff924be75c33af13a5 +timeCreated: 1638856403 \ No newline at end of file diff --git a/Editor/Elements.meta b/Editor/Elements.meta new file mode 100644 index 0000000..a98609e --- /dev/null +++ b/Editor/Elements.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 99d0fe2f9d1c4cb88cf46ba5813c091f +timeCreated: 1638772919 \ No newline at end of file diff --git a/Editor/Elements/TriBuiltInPropertyElement.cs b/Editor/Elements/TriBuiltInPropertyElement.cs new file mode 100644 index 0000000..8aeeb32 --- /dev/null +++ b/Editor/Elements/TriBuiltInPropertyElement.cs @@ -0,0 +1,33 @@ +using TriInspector.Utilities; +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Elements +{ + internal class TriBuiltInPropertyElement : TriElement + { + private readonly TriProperty _property; + private readonly PropertyHandlerProxy _propertyHandler; + private readonly SerializedProperty _serializedProperty; + + public TriBuiltInPropertyElement( + TriProperty property, + SerializedProperty serializedProperty, + PropertyHandlerProxy propertyHandler) + { + _property = property; + _serializedProperty = serializedProperty; + _propertyHandler = propertyHandler; + } + + public override float GetHeight(float width) + { + return _propertyHandler.GetHeight(_serializedProperty, _property.DisplayNameContent, true); + } + + public override void OnGUI(Rect position) + { + _propertyHandler.OnGUI(position, _serializedProperty, _property.DisplayNameContent, true); + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriBuiltInPropertyElement.cs.meta b/Editor/Elements/TriBuiltInPropertyElement.cs.meta new file mode 100644 index 0000000..17ec368 --- /dev/null +++ b/Editor/Elements/TriBuiltInPropertyElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cb76597978d84d19a27f6e8596e1a4bf +timeCreated: 1638774260 \ No newline at end of file diff --git a/Editor/Elements/TriFoldoutElement.cs b/Editor/Elements/TriFoldoutElement.cs new file mode 100644 index 0000000..6db8048 --- /dev/null +++ b/Editor/Elements/TriFoldoutElement.cs @@ -0,0 +1,100 @@ +using TriInspector.Utilities; +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Elements +{ + internal class TriFoldoutElement : TriPropertyCollectionBaseElement + { + private readonly TriProperty _property; + + public TriFoldoutElement(TriProperty property) + { + _property = property; + + DeclareGroups(property.ValueType); + } + + public override bool Update() + { + var dirty = false; + + if (_property.IsExpanded) + { + dirty |= GenerateChildren(); + } + else + { + dirty |= ClearChildren(); + } + + dirty |= base.Update(); + + return dirty; + } + + public override float GetHeight(float width) + { + var height = EditorGUIUtility.singleLineHeight; + + if (!_property.IsExpanded) + { + return height; + } + + height += base.GetHeight(width); + + return height; + } + + public override void OnGUI(Rect position) + { + var headerRect = new Rect(position) + { + height = EditorGUIUtility.singleLineHeight, + }; + var contentRect = new Rect(position) + { + yMin = position.yMin + headerRect.height, + }; + + TriEditorGUI.Foldout(headerRect, _property); + + if (!_property.IsExpanded) + { + return; + } + + TriGuiHelper.PushIndentLevel(); + base.OnGUI(contentRect); + TriGuiHelper.PopIndentLevel(); + } + + private bool GenerateChildren() + { + if (ChildrenCount != 0) + { + return false; + } + + foreach (var childProperty in _property.ChildrenProperties) + { + AddProperty(childProperty); + } + + return true; + } + + private bool ClearChildren() + { + if (ChildrenCount == 0) + { + return false; + } + + RemoveAllChildren(); + + return true; + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriFoldoutElement.cs.meta b/Editor/Elements/TriFoldoutElement.cs.meta new file mode 100644 index 0000000..abdd1c2 --- /dev/null +++ b/Editor/Elements/TriFoldoutElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 90b64b1805694cf8999a0380d4ca70b6 +timeCreated: 1638772042 \ No newline at end of file diff --git a/Editor/Elements/TriInfoBoxElement.cs b/Editor/Elements/TriInfoBoxElement.cs new file mode 100644 index 0000000..4ec77c6 --- /dev/null +++ b/Editor/Elements/TriInfoBoxElement.cs @@ -0,0 +1,45 @@ +using TriInspector.Utilities; +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Elements +{ + public class TriInfoBoxElement : TriElement + { + private readonly GUIContent _message; + private readonly Color _color; + + public TriInfoBoxElement(string message, MessageType type = MessageType.None, Color? color = null) + { + _message = new GUIContent(message, EditorGUIUtilityProxy.GetHelpIcon(type)); + _color = color ?? GetColor(type); + } + + public override float GetHeight(float width) + { + return EditorStyles.helpBox.CalcHeight(_message, width); + } + + public override void OnGUI(Rect position) + { + TriGuiHelper.PushColor(_color); + GUI.Label(position, _message, EditorStyles.helpBox); + TriGuiHelper.PopColor(); + } + + private static Color GetColor(MessageType type) + { + switch (type) + { + case MessageType.Error: + return Color.red; + + case MessageType.Warning: + return Color.yellow; + + default: + return Color.white; + } + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriInfoBoxElement.cs.meta b/Editor/Elements/TriInfoBoxElement.cs.meta new file mode 100644 index 0000000..420392a --- /dev/null +++ b/Editor/Elements/TriInfoBoxElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f64a66d501c34a808686c834530dd9a9 +timeCreated: 1638860979 \ No newline at end of file diff --git a/Editor/Elements/TriInlineGenericElement.cs b/Editor/Elements/TriInlineGenericElement.cs new file mode 100644 index 0000000..8f85630 --- /dev/null +++ b/Editor/Elements/TriInlineGenericElement.cs @@ -0,0 +1,41 @@ +using TriInspector.Utilities; +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Elements +{ + internal class TriInlineGenericElement : TriPropertyCollectionBaseElement + { + private readonly bool _drawPrefixLabel; + private readonly float _labelWidth; + private readonly TriProperty _property; + + public TriInlineGenericElement(TriProperty property, + bool drawPrefixLabel = false, float labelWidth = 0f) + { + _property = property; + _drawPrefixLabel = drawPrefixLabel; + _labelWidth = labelWidth; + + DeclareGroups(property.ValueType); + + foreach (var childProperty in property.ChildrenProperties) + { + AddProperty(childProperty); + } + } + + public override void OnGUI(Rect position) + { + if (_drawPrefixLabel) + { + var controlId = GUIUtility.GetControlID(FocusType.Passive); + position = EditorGUI.PrefixLabel(position, controlId, _property.DisplayNameContent); + } + + TriGuiHelper.PushLabelWidth(_labelWidth); + base.OnGUI(position); + TriGuiHelper.PopLabelWidth(); + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriInlineGenericElement.cs.meta b/Editor/Elements/TriInlineGenericElement.cs.meta new file mode 100644 index 0000000..e59f850 --- /dev/null +++ b/Editor/Elements/TriInlineGenericElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a5124d0a8d93488a858723d80fe69e69 +timeCreated: 1638788657 \ No newline at end of file diff --git a/Editor/Elements/TriInspectorElement.cs b/Editor/Elements/TriInspectorElement.cs new file mode 100644 index 0000000..2511520 --- /dev/null +++ b/Editor/Elements/TriInspectorElement.cs @@ -0,0 +1,15 @@ +namespace TriInspector.Elements +{ + internal class TriInspectorElement : TriPropertyCollectionBaseElement + { + public TriInspectorElement(TriPropertyTree propertyTree) + { + DeclareGroups(propertyTree.TargetObjectType); + + foreach (var childProperty in propertyTree.Properties) + { + AddProperty(childProperty); + } + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriInspectorElement.cs.meta b/Editor/Elements/TriInspectorElement.cs.meta new file mode 100644 index 0000000..709b161 --- /dev/null +++ b/Editor/Elements/TriInspectorElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4795377c7a0741c0a7de210cf2b3554e +timeCreated: 1638771141 \ No newline at end of file diff --git a/Editor/Elements/TriLabelElement.cs b/Editor/Elements/TriLabelElement.cs new file mode 100644 index 0000000..eb0c163 --- /dev/null +++ b/Editor/Elements/TriLabelElement.cs @@ -0,0 +1,24 @@ +using UnityEngine; + +namespace TriInspector.Elements +{ + public class TriLabelElement : TriElement + { + private readonly GUIContent _label; + + public TriLabelElement(string label) + { + _label = new GUIContent(label); + } + + public override float GetHeight(float width) + { + return GUI.skin.label.CalcHeight(_label, width); + } + + public override void OnGUI(Rect position) + { + GUI.Label(position, _label); + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriLabelElement.cs.meta b/Editor/Elements/TriLabelElement.cs.meta new file mode 100644 index 0000000..1922633 --- /dev/null +++ b/Editor/Elements/TriLabelElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a193f4236257483a8d5a10f0025b3d4f +timeCreated: 1638771650 \ No newline at end of file diff --git a/Editor/Elements/TriListElement.cs b/Editor/Elements/TriListElement.cs new file mode 100644 index 0000000..0dd96f3 --- /dev/null +++ b/Editor/Elements/TriListElement.cs @@ -0,0 +1,226 @@ +using System; +using System.Collections; +using TriInspector.Utilities; +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; + +namespace TriInspector.Elements +{ + internal class TriListElement : TriElement + { + private static readonly Action ReorderableListDrawHeaderMethod; + private static readonly Action ReorderableListClearCacheRecursiveMethod; + + private readonly TriProperty _property; + private readonly ReorderableList _reorderableListGui; + + private float _lastContentWidth; + private bool _scheduleRemove; + + static TriListElement() + { + ReorderableListDrawHeaderMethod = typeof(ReorderableList) + .CompileVoidInstanceMethod("DoListHeader"); + + ReorderableListClearCacheRecursiveMethod = typeof(ReorderableList) + .CompileVoidInstanceMethod("ClearCacheRecursive"); + } + + public TriListElement(TriProperty property) + { + _property = property; + + if (_property.TryGetSerializedProperty(out var serializedProperty) && serializedProperty.isArray) + { + _reorderableListGui = new ReorderableList(serializedProperty.serializedObject, serializedProperty, + true, true, true, false); + } + else + { + _reorderableListGui = new ReorderableList((IList) _property.Value, + _property.ArrayElementType, + false, true, false, false); + } + + _reorderableListGui.drawHeaderCallback = DrawHeaderCallback; + _reorderableListGui.elementHeightCallback = ElementHeightCallback; + _reorderableListGui.drawElementCallback = DrawElementCallback; + _reorderableListGui.drawElementBackgroundCallback = DrawElementBackgroundCallback; + } + + public override bool Update() + { + var dirty = false; + + if (_property.IsExpanded) + { + dirty |= GenerateChildren(); + } + else + { + dirty |= ClearChildren(); + } + + dirty |= base.Update(); + + if (dirty) + { + ReorderableListClearCacheRecursiveMethod(_reorderableListGui); + } + + return dirty; + } + + public override float GetHeight(float width) + { + if (!_property.IsExpanded) + { + return _reorderableListGui.headerHeight + 4f; + } + + _lastContentWidth = width; + + return _reorderableListGui.GetHeight(); + } + + public override void OnGUI(Rect position) + { + if (!_property.IsExpanded) + { + ReorderableListDrawHeaderMethod(_reorderableListGui, new Rect(position) + { + yMax = position.yMax - 4, + }); + return; + } + + var labelWidthExtra = 6f + (_reorderableListGui.draggable ? 15f : 0f); + + TriGuiHelper.PushLabelWidth(EditorGUIUtility.labelWidth - labelWidthExtra); + _reorderableListGui.DoList(position); + TriGuiHelper.PopLabelWidth(); + + if (_scheduleRemove) + { + _scheduleRemove = false; + ReorderableList.defaultBehaviours.DoRemoveButton(_reorderableListGui); + ReorderableListClearCacheRecursiveMethod(_reorderableListGui); + GUI.changed = true; + } + } + + private bool GenerateChildren() + { + var count = _reorderableListGui.count; + + if (ChildrenCount == count) + { + return false; + } + + while (ChildrenCount < count) + { + var property = _property.ArrayElementProperties[ChildrenCount]; + AddChild(new TriPropertyElement(property, true)); + } + + while (ChildrenCount > count) + { + RemoveChildAt(ChildrenCount - 1); + } + + return true; + } + + private bool ClearChildren() + { + if (ChildrenCount == 0) + { + return false; + } + + RemoveAllChildren(); + + return true; + } + + private void DrawElementBackgroundCallback(Rect rect, int index, bool isActive, bool isFocused) + { + if (index % 2 == 1) + { + TriEditorGUI.DrawBox(rect, GUI.skin.box); + } + } + + private void DrawHeaderCallback(Rect rect) + { + var labelRect = new Rect(rect) + { + xMin = rect.xMin + 10, + xMax = rect.xMax, + }; + + var arraySizeRect = new Rect(rect) + { + xMin = rect.xMax - 100, + }; + + TriEditorGUI.Foldout(labelRect, _property); + GUI.Label(arraySizeRect, $"{_reorderableListGui.count} items", Styles.ItemsCount); + } + + private void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused) + { + var contentRect = new Rect(rect) + { + xMax = rect.xMax - 28, + }; + var deleteRect = new Rect(rect) + { + xMin = rect.xMax - 22, + }; + + GetChild(index).OnGUI(contentRect); + + if (GUI.Button(deleteRect, Styles.IconToolbarMinus, Styles.RemoveItemButton)) + { + _reorderableListGui.index = index; + _scheduleRemove = true; + } + } + + private float ElementHeightCallback(int index) + { + return GetChild(index).GetHeight(_lastContentWidth); + } + + private static class Styles + { + public static readonly GUIStyle ItemsCount; + public static readonly GUIStyle RemoveItemButton; + + public static readonly GUIContent IconToolbarMinus = + EditorGUIUtility.TrIconContent("Toolbar Minus", "Remove selection from the list"); + + static Styles() + { + RemoveItemButton = new GUIStyle("RL FooterButton") + { + fixedHeight = 0f, + alignment = TextAnchor.MiddleCenter, + }; + ItemsCount = new GUIStyle(GUI.skin.label) + { + alignment = TextAnchor.MiddleRight, + normal = + { + textColor = EditorGUIUtility.isProSkin + ? new Color(0.6f, 0.6f, 0.6f) + : new Color(0.3f, 0.3f, 0.3f), + }, + }; + } + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriListElement.cs.meta b/Editor/Elements/TriListElement.cs.meta new file mode 100644 index 0000000..44881ae --- /dev/null +++ b/Editor/Elements/TriListElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c9ed87465ed54b039d11e455c4aa3efc +timeCreated: 1638776402 \ No newline at end of file diff --git a/Editor/Elements/TriMultiEditNotSupportedElement.cs b/Editor/Elements/TriMultiEditNotSupportedElement.cs new file mode 100644 index 0000000..2bb9906 --- /dev/null +++ b/Editor/Elements/TriMultiEditNotSupportedElement.cs @@ -0,0 +1,27 @@ +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Elements +{ + public class TriMultiEditNotSupportedElement : TriElement + { + private readonly TriProperty _property; + private readonly GUIContent _message; + + public TriMultiEditNotSupportedElement(TriProperty property) + { + _property = property; + _message = new GUIContent("Multi edit not supported"); + } + + public override float GetHeight(float width) + { + return EditorGUIUtility.singleLineHeight; + } + + public override void OnGUI(Rect position) + { + EditorGUI.LabelField(position, _property.DisplayNameContent, _message); + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriMultiEditNotSupportedElement.cs.meta b/Editor/Elements/TriMultiEditNotSupportedElement.cs.meta new file mode 100644 index 0000000..9b8c48e --- /dev/null +++ b/Editor/Elements/TriMultiEditNotSupportedElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 575bf0dafd7f459fb09451ec5a83c427 +timeCreated: 1641382168 \ No newline at end of file diff --git a/Editor/Elements/TriNoDrawerElement.cs b/Editor/Elements/TriNoDrawerElement.cs new file mode 100644 index 0000000..ed0f421 --- /dev/null +++ b/Editor/Elements/TriNoDrawerElement.cs @@ -0,0 +1,27 @@ +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Elements +{ + public class TriNoDrawerElement : TriElement + { + private readonly GUIContent _message; + private readonly TriProperty _property; + + public TriNoDrawerElement(TriProperty property) + { + _property = property; + _message = new GUIContent($"No drawer for {property.FieldType}"); + } + + public override float GetHeight(float width) + { + return EditorGUIUtility.singleLineHeight; + } + + public override void OnGUI(Rect position) + { + EditorGUI.LabelField(position, _property.DisplayNameContent, _message); + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriNoDrawerElement.cs.meta b/Editor/Elements/TriNoDrawerElement.cs.meta new file mode 100644 index 0000000..6afb796 --- /dev/null +++ b/Editor/Elements/TriNoDrawerElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e6cc0cc1449a4af4b8d435b87ef20378 +timeCreated: 1639319113 \ No newline at end of file diff --git a/Editor/Elements/TriPropertyCollectionBaseElement.cs b/Editor/Elements/TriPropertyCollectionBaseElement.cs new file mode 100644 index 0000000..c632a31 --- /dev/null +++ b/Editor/Elements/TriPropertyCollectionBaseElement.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using TriInspector.Utilities; + +namespace TriInspector.Elements +{ + public abstract class TriPropertyCollectionBaseElement : TriElement + { + private List _declarations = new List(); + + private Dictionary _groups; + + [PublicAPI] + public void DeclareGroups([CanBeNull] Type type) + { + if (type == null) + { + return; + } + + foreach (var attribute in TriReflectionUtilities.GetAttributesCached(type)) + { + if (attribute is DeclareGroupBaseAttribute declareAttribute) + { + _declarations.Add(declareAttribute); + } + } + } + + [PublicAPI] + public void AddProperty(TriProperty property) + { + var propertyElement = new TriPropertyElement(property); + + if (property.TryGetAttribute(out GroupAttribute groupAttribute)) + { + IEnumerable path = groupAttribute.Path.Split('/'); + + var remaining = path.GetEnumerator(); + if (remaining.MoveNext()) + { + AddGroupedChild(propertyElement, remaining.Current, remaining.Current, remaining); + } + else + { + AddChild(propertyElement); + } + } + else + { + AddChild(propertyElement); + } + } + + private void AddGroupedChild(TriElement child, string currentPath, string currentName, + IEnumerator remainingPath) + { + if (_groups == null) + { + _groups = new Dictionary(); + } + + var groupElement = CreateSubGroup(currentPath, currentName); + + if (remainingPath.MoveNext()) + { + var nextPath = currentPath + "/" + remainingPath.Current; + var nextName = remainingPath.Current; + + groupElement.AddGroupedChild(child, nextPath, nextName, remainingPath); + } + else + { + groupElement.AddChild(child); + } + } + + private TriPropertyCollectionBaseElement CreateSubGroup(string groupPath, string groupName) + { + if (!_groups.TryGetValue(groupName, out var groupElement)) + { + var declaration = _declarations.FirstOrDefault(it => it.Path == groupPath); + + if (declaration != null) + { + groupElement = TriDrawersUtilities.TryCreateGroupElementFor(declaration); + } + + if (groupElement == null) + { + groupElement = new DefaultGroupElement(); + } + + groupElement._declarations = _declarations; + + _groups.Add(groupName, groupElement); + + AddChild(groupElement); + } + + return groupElement; + } + + private class DefaultGroupElement : TriPropertyCollectionBaseElement + { + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriPropertyCollectionBaseElement.cs.meta b/Editor/Elements/TriPropertyCollectionBaseElement.cs.meta new file mode 100644 index 0000000..f9f02d3 --- /dev/null +++ b/Editor/Elements/TriPropertyCollectionBaseElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1373b681c88a425c943ea5e6d149a217 +timeCreated: 1639412705 \ No newline at end of file diff --git a/Editor/Elements/TriPropertyElement.cs b/Editor/Elements/TriPropertyElement.cs new file mode 100644 index 0000000..25538fa --- /dev/null +++ b/Editor/Elements/TriPropertyElement.cs @@ -0,0 +1,133 @@ +using TriInspector.Utilities; +using UnityEngine; + +namespace TriInspector.Elements +{ + internal class TriPropertyElement : TriElement + { + private readonly TriProperty _property; + + public TriPropertyElement(TriProperty property, bool inline = false) + { + _property = property; + + var element = CreateElement(property, inline); + + var drawers = property.AllDrawers; + for (var index = drawers.Count - 1; index >= 0; index--) + { + if (drawers[index].ApplyOnArrayElement != _property.IsArrayElement) + { + continue; + } + + element = drawers[index].CreateElementInternal(property, element); + } + + AddChild(element); + } + + public override float GetHeight(float width) + { + if (!_property.IsVisible) + { + return 0f; + } + + return base.GetHeight(width); + } + + public override void OnGUI(Rect position) + { + if (!_property.IsVisible) + { + return; + } + + var oldEnabled = GUI.enabled; + + GUI.enabled = _property.IsEnabled; + base.OnGUI(position); + GUI.enabled = oldEnabled; + } + + private static TriElement CreateElement(TriProperty property, bool inline = false) + { + var isSerializedProperty = property.TryGetSerializedProperty(out var serializedProperty); + + if (!isSerializedProperty && property.PropertyTree.TargetObjects.Length > 1) + { + return new TriMultiEditNotSupportedElement(property); + } + + var handler = isSerializedProperty + ? ScriptAttributeUtilityProxy.GetHandler(serializedProperty) + : default(PropertyHandlerProxy?); + + if (!handler.HasValue || !handler.Value.hasPropertyDrawer) + { + var propertyType = property.PropertyType; + + switch (propertyType) + { + case TriPropertyType.Array: + { + return CreateArrayElement(property); + } + + case TriPropertyType.Reference: + { + return CreateReferenceElement(property, inline); + } + + case TriPropertyType.Generic: + { + return CreateGenericElement(property, inline); + } + } + } + + if (isSerializedProperty) + { + return new TriBuiltInPropertyElement(property, serializedProperty, handler.Value); + } + + return new TriNoDrawerElement(property); + } + + private static TriElement CreateArrayElement(TriProperty property) + { + return new TriListElement(property); + } + + private static TriElement CreateReferenceElement(TriProperty property, bool inline) + { + if (inline) + { + return new TriReferenceElement(property, true); + } + + if (property.TryGetAttribute(out InlinePropertyAttribute inlineAttribute)) + { + return new TriReferenceElement(property, true, true, inlineAttribute.LabelWidth); + } + + return new TriReferenceElement(property); + } + + private static TriElement CreateGenericElement(TriProperty property, bool inline) + { + if (inline) + { + return new TriInlineGenericElement(property); + } + + if (property.TryGetAttribute(out InlinePropertyAttribute inlineAttribute)) + { + return new TriInlineGenericElement(property, true, inlineAttribute.LabelWidth); + } + + return new TriFoldoutElement(property); + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriPropertyElement.cs.meta b/Editor/Elements/TriPropertyElement.cs.meta new file mode 100644 index 0000000..44bfd98 --- /dev/null +++ b/Editor/Elements/TriPropertyElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f57a61ef6fe34b51939950c6b9597f88 +timeCreated: 1638776439 \ No newline at end of file diff --git a/Editor/Elements/TriReferenceElement.cs b/Editor/Elements/TriReferenceElement.cs new file mode 100644 index 0000000..59f1214 --- /dev/null +++ b/Editor/Elements/TriReferenceElement.cs @@ -0,0 +1,141 @@ +using System; +using TriInspector.Utilities; +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Elements +{ + internal class TriReferenceElement : TriPropertyCollectionBaseElement + { + private readonly bool _drawPrefixLabel; + private readonly bool _inline; + private readonly float _labelWidth; + private readonly TriProperty _property; + + private Type _referenceType; + + public TriReferenceElement(TriProperty property, + bool inline = false, bool drawPrefixLabel = false, float labelWidth = 0f) + { + _property = property; + _inline = inline; + _drawPrefixLabel = drawPrefixLabel; + _labelWidth = labelWidth; + + DeclareGroups(property.ValueType); + } + + public override bool Update() + { + var dirty = false; + + if (_inline || _property.IsExpanded) + { + dirty |= GenerateChildren(); + } + else + { + dirty |= ClearChildren(); + } + + dirty |= base.Update(); + + return dirty; + } + + public override float GetHeight(float width) + { + var height = EditorGUIUtility.singleLineHeight; + + if (_inline || _property.IsExpanded) + { + height += base.GetHeight(width); + } + + return height; + } + + public override void OnGUI(Rect position) + { + if (_drawPrefixLabel) + { + var controlId = GUIUtility.GetControlID(FocusType.Passive); + position = EditorGUI.PrefixLabel(position, controlId, _property.DisplayNameContent); + } + + var headerRect = new Rect(position) + { + height = EditorGUIUtility.singleLineHeight, + }; + var headerLabelRect = new Rect(position) + { + height = EditorGUIUtility.singleLineHeight, + width = EditorGUIUtility.labelWidth, + }; + var headerFieldRect = new Rect(position) + { + height = EditorGUIUtility.singleLineHeight, + xMin = headerRect.xMin + EditorGUIUtility.labelWidth, + }; + var contentRect = new Rect(position) + { + yMin = position.yMin + headerRect.height, + }; + + if (_inline) + { + TriManagedReferenceGui.DrawTypeSelector(headerRect, _property); + + TriGuiHelper.PushLabelWidth(_labelWidth); + base.OnGUI(contentRect); + TriGuiHelper.PopLabelWidth(); + } + else + { + TriEditorGUI.Foldout(headerLabelRect, _property); + TriManagedReferenceGui.DrawTypeSelector(headerFieldRect, _property); + + if (_property.IsExpanded) + { + TriGuiHelper.PushIndentLevel(); + TriGuiHelper.PushLabelWidth(_labelWidth); + base.OnGUI(contentRect); + TriGuiHelper.PopLabelWidth(); + TriGuiHelper.PopIndentLevel(); + } + } + } + + private bool GenerateChildren() + { + if (_property.ValueType == _referenceType) + { + return false; + } + + _referenceType = _property.ValueType; + + RemoveAllChildren(); + + foreach (var childProperty in _property.ChildrenProperties) + { + AddProperty(childProperty); + } + + return true; + } + + private bool ClearChildren() + { + if (ChildrenCount == 0) + { + return false; + } + + _referenceType = null; + RemoveAllChildren(); + + return true; + } + } +} \ No newline at end of file diff --git a/Editor/Elements/TriReferenceElement.cs.meta b/Editor/Elements/TriReferenceElement.cs.meta new file mode 100644 index 0000000..e8c6ae8 --- /dev/null +++ b/Editor/Elements/TriReferenceElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7dd13898e07a45afacca03cc86c0e24c +timeCreated: 1638789498 \ No newline at end of file diff --git a/Editor/Resources.meta b/Editor/Resources.meta new file mode 100644 index 0000000..6ae5eb5 --- /dev/null +++ b/Editor/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d8d4d0876dcc071428509b59e2f78e29 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Resources/TriInspector_Box_Bg.png b/Editor/Resources/TriInspector_Box_Bg.png new file mode 100644 index 0000000..1874596 Binary files /dev/null and b/Editor/Resources/TriInspector_Box_Bg.png differ diff --git a/Editor/Resources/TriInspector_Box_Bg.png.meta b/Editor/Resources/TriInspector_Box_Bg.png.meta new file mode 100644 index 0000000..1dc183c --- /dev/null +++ b/Editor/Resources/TriInspector_Box_Bg.png.meta @@ -0,0 +1,108 @@ +fileFormatVersion: 2 +guid: 7a524300faaf5aa40a2ff59c25b28b71 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Resources/TriInspector_Box_Bg_Dark.png b/Editor/Resources/TriInspector_Box_Bg_Dark.png new file mode 100644 index 0000000..618cbcb Binary files /dev/null and b/Editor/Resources/TriInspector_Box_Bg_Dark.png differ diff --git a/Editor/Resources/TriInspector_Box_Bg_Dark.png.meta b/Editor/Resources/TriInspector_Box_Bg_Dark.png.meta new file mode 100644 index 0000000..8168880 --- /dev/null +++ b/Editor/Resources/TriInspector_Box_Bg_Dark.png.meta @@ -0,0 +1,108 @@ +fileFormatVersion: 2 +guid: 6c3f6c6cd431e8e4e87094572f59d524 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Resources/TriInspector_Content_Bg.png b/Editor/Resources/TriInspector_Content_Bg.png new file mode 100644 index 0000000..8c56155 Binary files /dev/null and b/Editor/Resources/TriInspector_Content_Bg.png differ diff --git a/Editor/Resources/TriInspector_Content_Bg.png.meta b/Editor/Resources/TriInspector_Content_Bg.png.meta new file mode 100644 index 0000000..2802077 --- /dev/null +++ b/Editor/Resources/TriInspector_Content_Bg.png.meta @@ -0,0 +1,108 @@ +fileFormatVersion: 2 +guid: 372e4831c9374244aafdd096c36bb645 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Resources/TriInspector_Content_Bg_Dark.png b/Editor/Resources/TriInspector_Content_Bg_Dark.png new file mode 100644 index 0000000..5436eec Binary files /dev/null and b/Editor/Resources/TriInspector_Content_Bg_Dark.png differ diff --git a/Editor/Resources/TriInspector_Content_Bg_Dark.png.meta b/Editor/Resources/TriInspector_Content_Bg_Dark.png.meta new file mode 100644 index 0000000..333176f --- /dev/null +++ b/Editor/Resources/TriInspector_Content_Bg_Dark.png.meta @@ -0,0 +1,108 @@ +fileFormatVersion: 2 +guid: d73be6aba60ae5b41887b4116facc353 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Resources/TriInspector_Header_Bg.png b/Editor/Resources/TriInspector_Header_Bg.png new file mode 100644 index 0000000..0b890b6 Binary files /dev/null and b/Editor/Resources/TriInspector_Header_Bg.png differ diff --git a/Editor/Resources/TriInspector_Header_Bg.png.meta b/Editor/Resources/TriInspector_Header_Bg.png.meta new file mode 100644 index 0000000..ca8fd54 --- /dev/null +++ b/Editor/Resources/TriInspector_Header_Bg.png.meta @@ -0,0 +1,108 @@ +fileFormatVersion: 2 +guid: 527fefefcbb0e3e4289bf8c5e0be5cd4 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Resources/TriInspector_Header_Bg_Dark.png b/Editor/Resources/TriInspector_Header_Bg_Dark.png new file mode 100644 index 0000000..fbd01b9 Binary files /dev/null and b/Editor/Resources/TriInspector_Header_Bg_Dark.png differ diff --git a/Editor/Resources/TriInspector_Header_Bg_Dark.png.meta b/Editor/Resources/TriInspector_Header_Bg_Dark.png.meta new file mode 100644 index 0000000..ef8775c --- /dev/null +++ b/Editor/Resources/TriInspector_Header_Bg_Dark.png.meta @@ -0,0 +1,108 @@ +fileFormatVersion: 2 +guid: ee1f3c29d1186ca43bf0eb4cc9d90ee5 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: 3 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/TriAttributeDrawer.cs b/Editor/TriAttributeDrawer.cs new file mode 100644 index 0000000..e4afcef --- /dev/null +++ b/Editor/TriAttributeDrawer.cs @@ -0,0 +1,68 @@ +using System; +using JetBrains.Annotations; +using UnityEngine; + +namespace TriInspector +{ + public abstract class TriAttributeDrawer : TriCustomDrawer + { + internal Attribute RawAttribute { get; set; } + } + + public abstract class TriAttributeDrawer : TriAttributeDrawer + where TAttribute : Attribute + { + [PublicAPI] + public TAttribute Attribute => (TAttribute) RawAttribute; + + public sealed override TriElement CreateElementInternal(TriProperty property, TriElement next) + { + return CreateElement(property, next); + } + + [PublicAPI] + public virtual TriElement CreateElement(TriProperty property, TriElement next) + { + return new DefaultAttributeDrawerElement(this, property, next); + } + + [PublicAPI] + public virtual float GetHeight(float width, TriProperty property, TriElement next) + { + return next.GetHeight(width); + } + + [PublicAPI] + public virtual void OnGUI(Rect position, TriProperty property, TriElement next) + { + next.OnGUI(position); + } + + internal class DefaultAttributeDrawerElement : TriElement + { + private readonly TriAttributeDrawer _drawer; + private readonly TriElement _next; + private readonly TriProperty _property; + + public DefaultAttributeDrawerElement(TriAttributeDrawer drawer, TriProperty property, + TriElement next) + { + _drawer = drawer; + _property = property; + _next = next; + + AddChild(next); + } + + public override float GetHeight(float width) + { + return _drawer.GetHeight(width, _property, _next); + } + + public override void OnGUI(Rect position) + { + _drawer.OnGUI(position, _property, _next); + } + } + } +} \ No newline at end of file diff --git a/Editor/TriAttributeDrawer.cs.meta b/Editor/TriAttributeDrawer.cs.meta new file mode 100644 index 0000000..e135edf --- /dev/null +++ b/Editor/TriAttributeDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 31f59a1db97a4d389263665aaf9bccf1 +timeCreated: 1639381350 \ No newline at end of file diff --git a/Editor/TriCustomDrawer.cs b/Editor/TriCustomDrawer.cs new file mode 100644 index 0000000..9509cf8 --- /dev/null +++ b/Editor/TriCustomDrawer.cs @@ -0,0 +1,10 @@ +namespace TriInspector +{ + public abstract class TriCustomDrawer + { + internal int Order { get; set; } + internal bool ApplyOnArrayElement { get; set; } + + public abstract TriElement CreateElementInternal(TriProperty property, TriElement next); + } +} \ No newline at end of file diff --git a/Editor/TriCustomDrawer.cs.meta b/Editor/TriCustomDrawer.cs.meta new file mode 100644 index 0000000..f2b4ff8 --- /dev/null +++ b/Editor/TriCustomDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 896bcecdfc7048de8375841799d14ecc +timeCreated: 1638885450 \ No newline at end of file diff --git a/Editor/TriDrawerOrder.cs b/Editor/TriDrawerOrder.cs new file mode 100644 index 0000000..2b070a9 --- /dev/null +++ b/Editor/TriDrawerOrder.cs @@ -0,0 +1,11 @@ +namespace TriInspector +{ + public static class TriDrawerOrder + { + public const int System = -9999; + public const int Inspector = -2000; + public const int Decorator = -1000; + public const int Drawer = 0; + public const int Fallback = 9999; + } +} \ No newline at end of file diff --git a/Editor/TriDrawerOrder.cs.meta b/Editor/TriDrawerOrder.cs.meta new file mode 100644 index 0000000..6f2c83b --- /dev/null +++ b/Editor/TriDrawerOrder.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2db5b837fe8643de8e5be9eaee10f509 +timeCreated: 1639384181 \ No newline at end of file diff --git a/Editor/TriEditor.cs b/Editor/TriEditor.cs new file mode 100644 index 0000000..8f4eb57 --- /dev/null +++ b/Editor/TriEditor.cs @@ -0,0 +1,96 @@ +using TriInspector.Utilities; +using UnityEditor; +using UnityEngine; +using UnityEngine.Profiling; + +namespace TriInspector +{ + public abstract class TriEditor : Editor + { + private bool _drawDefaultInspector; + private TriPropertyTree _inspector; + + private void OnEnable() + { + if (serializedObject.targetObject != null) + { + _inspector = TriPropertyTree.Create(serializedObject); + } + } + + private void OnDisable() + { + _inspector?.Destroy(); + } + + public override void OnInspectorGUI() + { + if (_inspector == null) + { + DrawDefaultInspector(); + return; + } + + serializedObject.UpdateIfRequiredOrScript(); + + DrawInspectorModeHeader(); + + if (_drawDefaultInspector) + { + DrawDefaultInspector(); + } + else + { + Profiler.BeginSample("TriInspector.Update()"); + try + { + _inspector.Update(); + } + finally + { + Profiler.EndSample(); + } + + TriGuiHelper.PushEditor(this); + Profiler.BeginSample("TriInspector.DoLayout()"); + try + { + _inspector.DoLayout(); + } + finally + { + Profiler.EndSample(); + TriGuiHelper.PopEditor(this); + } + } + + serializedObject.ApplyModifiedProperties(); + } + + private void DrawInspectorModeHeader() + { + GUILayout.Space(5); + + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + if (GUILayout.Toggle(!_drawDefaultInspector, "Tri Inspector", EditorStyles.miniButtonLeft)) + { + _drawDefaultInspector = false; + } + + if (GUILayout.Toggle(_drawDefaultInspector, "Default Inspector", EditorStyles.miniButtonRight)) + { + _drawDefaultInspector = true; + } + + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + + GUILayout.Space(5); + + var rect = EditorGUILayout.GetControlRect(false, 1); + EditorGUI.DrawRect(rect, Color.gray); + GUILayout.Space(10); + } + } +} \ No newline at end of file diff --git a/Editor/TriEditor.cs.meta b/Editor/TriEditor.cs.meta new file mode 100644 index 0000000..5ad10f4 --- /dev/null +++ b/Editor/TriEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7985f723508b7434183568ca5c8436bd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/TriEditorStyles.cs b/Editor/TriEditorStyles.cs new file mode 100644 index 0000000..087cd60 --- /dev/null +++ b/Editor/TriEditorStyles.cs @@ -0,0 +1,83 @@ +using UnityEditor; +using UnityEngine; + +namespace TriInspector +{ + public static class TriEditorStyles + { + private const string BaseResourcesPath = "Packages/com.triinspector/Editor/Resources/"; + + private static GUIStyle _headerBox; + private static GUIStyle _contentBox; + private static GUIStyle _box; + + public static GUIStyle HeaderBox + { + get + { + if (_headerBox == null) + { + _headerBox = new GUIStyle + { + border = new RectOffset(2, 2, 2, 2), + normal = + { + background = LoadTexture("TriInspector_Header_Bg"), + }, + }; + } + + return _headerBox; + } + } + + public static GUIStyle ContentBox + { + get + { + if (_contentBox == null) + { + _contentBox = new GUIStyle + { + border = new RectOffset(2, 2, 2, 2), + normal = + { + background = LoadTexture("TriInspector_Content_Bg"), + }, + }; + } + + return _contentBox; + } + } + + public static GUIStyle Box + { + get + { + if (_box == null) + { + _box = new GUIStyle + { + border = new RectOffset(2, 2, 2, 2), + normal = + { + background = LoadTexture("TriInspector_Box_Bg"), + }, + }; + } + + return _box; + } + } + + private static Texture2D LoadTexture(string name) + { + var path = EditorGUIUtility.isProSkin + ? BaseResourcesPath + name + "_Dark.png" + : BaseResourcesPath + name + ".png"; + + return (Texture2D) EditorGUIUtility.Load(path); + } + } +} \ No newline at end of file diff --git a/Editor/TriEditorStyles.cs.meta b/Editor/TriEditorStyles.cs.meta new file mode 100644 index 0000000..73b75fe --- /dev/null +++ b/Editor/TriEditorStyles.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6f23eb6fd2f644a0a718543287192636 +timeCreated: 1639462144 \ No newline at end of file diff --git a/Editor/TriElement.cs b/Editor/TriElement.cs new file mode 100644 index 0000000..061c48c --- /dev/null +++ b/Editor/TriElement.cs @@ -0,0 +1,197 @@ +using System.Collections.Generic; +using JetBrains.Annotations; +using UnityEditor; +using UnityEngine; + +namespace TriInspector +{ + public class TriElement + { + private static readonly List Empty = new List(); + + private bool _attached; + private List _children = Empty; + + [PublicAPI] + public int ChildrenCount => _children.Count; + + [PublicAPI] + public virtual bool Update() + { + if (!_attached) + { + Debug.LogError($"{GetType().Name} not attached"); + } + + var dirty = false; + + foreach (var child in _children) + { + dirty |= child.Update(); + } + + return dirty; + } + + [PublicAPI] + public virtual float GetHeight(float width) + { + if (!_attached) + { + Debug.LogError($"{GetType().Name} not attached"); + } + + switch (_children.Count) + { + case 0: + return 0f; + + case 1: + return _children[0].GetHeight(width); + + default: + { + var height = (_children.Count - 1) * EditorGUIUtility.standardVerticalSpacing; + + foreach (var child in _children) + { + height += child.GetHeight(width); + } + + return height; + } + } + } + + [PublicAPI] + public virtual void OnGUI(Rect position) + { + if (!_attached) + { + Debug.LogError($"{GetType().Name} not attached"); + } + + switch (_children.Count) + { + case 0: + break; + + case 1: + _children[0].OnGUI(position); + break; + + default: + { + var offset = 0f; + var spacing = EditorGUIUtility.standardVerticalSpacing; + + foreach (var child in _children) + { + var childHeight = child.GetHeight(position.width); + + child.OnGUI(new Rect(position.x, position.y + offset, position.width, childHeight)); + + offset += childHeight + spacing; + } + + break; + } + } + } + + [PublicAPI] + public TriElement GetChild(int index) + { + return _children[index]; + } + + [PublicAPI] + public void RemoveChildAt(int index) + { + if (_children.Count < index) + { + return; + } + + var child = _children[index]; + _children.RemoveAt(index); + + if (_attached) + { + child.DetachInternal(); + } + } + + [PublicAPI] + public void RemoveAllChildren() + { + if (_attached) + { + foreach (var child in _children) + { + child.DetachInternal(); + } + } + + _children.Clear(); + } + + [PublicAPI] + public void AddChild(TriElement child) + { + if (_children == Empty) + { + _children = new List(); + } + + _children.Add(child); + + if (_attached) + { + child.AttachInternal(); + } + } + + internal void AttachInternal() + { + if (_attached) + { + Debug.LogError($"{GetType().Name} already attached"); + } + + _attached = true; + + OnAttachToPanel(); + + foreach (var child in _children) + { + child.AttachInternal(); + } + } + + internal void DetachInternal() + { + if (!_attached) + { + Debug.LogError($"{GetType().Name} not attached"); + } + + _attached = false; + + foreach (var child in _children) + { + child.DetachInternal(); + } + + OnDetachFromPanel(); + } + + protected virtual void OnAttachToPanel() + { + } + + protected virtual void OnDetachFromPanel() + { + } + } +} \ No newline at end of file diff --git a/Editor/TriElement.cs.meta b/Editor/TriElement.cs.meta new file mode 100644 index 0000000..92d3914 --- /dev/null +++ b/Editor/TriElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 543813bc0e9e4045904a35ef56ea6abe +timeCreated: 1638771508 \ No newline at end of file diff --git a/Editor/TriGroupDrawer.cs b/Editor/TriGroupDrawer.cs new file mode 100644 index 0000000..dc87a4d --- /dev/null +++ b/Editor/TriGroupDrawer.cs @@ -0,0 +1,23 @@ +using System; +using JetBrains.Annotations; +using TriInspector.Elements; + +namespace TriInspector +{ + public abstract class TriGroupDrawer + { + public abstract TriPropertyCollectionBaseElement CreateElementInternal(Attribute attribute); + } + + public abstract class TriGroupDrawer : TriGroupDrawer + where TAttribute : Attribute + { + public sealed override TriPropertyCollectionBaseElement CreateElementInternal(Attribute attribute) + { + return CreateElement((TAttribute) attribute); + } + + [PublicAPI] + public abstract TriPropertyCollectionBaseElement CreateElement(TAttribute attribute); + } +} \ No newline at end of file diff --git a/Editor/TriGroupDrawer.cs.meta b/Editor/TriGroupDrawer.cs.meta new file mode 100644 index 0000000..2819940 --- /dev/null +++ b/Editor/TriGroupDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c7337ea7305e4a5681ff404a041dc93e +timeCreated: 1639417787 \ No newline at end of file diff --git a/Editor/TriInspector.Editor.asmdef b/Editor/TriInspector.Editor.asmdef new file mode 100644 index 0000000..5908600 --- /dev/null +++ b/Editor/TriInspector.Editor.asmdef @@ -0,0 +1,18 @@ +{ + "name": "TriInspector.Editor", + "rootNamespace": "", + "references": [ + "TriInspector" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Editor/TriInspector.Editor.asmdef.meta b/Editor/TriInspector.Editor.asmdef.meta new file mode 100644 index 0000000..446630e --- /dev/null +++ b/Editor/TriInspector.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e851236b9ac2b9b4eaaa99506366edea +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/TriProperty.cs b/Editor/TriProperty.cs new file mode 100644 index 0000000..5db8d16 --- /dev/null +++ b/Editor/TriProperty.cs @@ -0,0 +1,373 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using JetBrains.Annotations; +using TriInspector.Utilities; +using UnityEditor; +using UnityEngine; + +namespace TriInspector +{ + public sealed class TriProperty : ITriPropertyParent + { + private static readonly IList EmptyList = new List(); + + private readonly TriPropertyDefinition _definition; + private readonly ITriPropertyParent _parent; + [CanBeNull] private readonly SerializedProperty _serializedProperty; + private List _arrayElementProperties; + private List _childrenProperties; + + private GUIContent _displayNameBackingField; + private bool? _isReadOnlyBackingField; + + internal TriProperty( + TriPropertyTree propertyTree, + ITriPropertyParent parent, + TriPropertyDefinition definition, + [CanBeNull] SerializedProperty serializedProperty) + { + _parent = parent; + _definition = definition; + _serializedProperty = serializedProperty?.Copy(); + + PropertyTree = propertyTree; + PropertyType = GetPropertyType(this); + + Update(); + } + + [PublicAPI] + public GUIContent DisplayNameContent + { + get + { + if (_displayNameBackingField == null) + { + _displayNameBackingField = TryGetAttribute(out HideLabelAttribute _) + ? GUIContent.none + : new GUIContent(ObjectNames.NicifyVariableName(_definition.Name)); + } + + if (_displayNameBackingField != GUIContent.none) + { + if (TryGetAttribute(out LabelTextAttribute labelTextAttribute)) + { + _displayNameBackingField.text = labelTextAttribute.Text; + } + + if (TryGetAttribute(out PropertyTooltipAttribute tooltipAttribute)) + { + _displayNameBackingField.tooltip = tooltipAttribute.Tooltip; + } + } + + return _displayNameBackingField; + } + } + + [PublicAPI] + public bool IsVisible => true; + + [PublicAPI] + public bool IsEnabled + { + get + { + if (IsReadOnly) + { + return false; + } + + return true; + } + } + + + [PublicAPI] + public Type FieldType => _definition.FieldType; + + [PublicAPI] + public Type ArrayElementType => _definition.ArrayElementType; + + [PublicAPI] + public bool IsArrayElement => _definition.IsArrayElement; + + public IReadOnlyList AllDrawers => _definition.Drawers; + + [PublicAPI] + public bool IsExpanded + { + get + { + if (_serializedProperty != null) + { + return _serializedProperty.isExpanded; + } + + // add saves + return true; + } + set + { + if (IsExpanded == value) + { + return; + } + + if (_serializedProperty != null) + { + _serializedProperty.isExpanded = value; + } + } + } + + [PublicAPI] + [CanBeNull] + public Type ValueType { get; private set; } + + [PublicAPI] + public TriPropertyType PropertyType { get; } + + [PublicAPI] + public IReadOnlyList ChildrenProperties => + PropertyType == TriPropertyType.Generic || PropertyType == TriPropertyType.Reference + ? _childrenProperties + : throw new InvalidOperationException("Cannot read ChildrenProperties for " + PropertyType); + + [PublicAPI] + public IReadOnlyList ArrayElementProperties => PropertyType == TriPropertyType.Array + ? _arrayElementProperties + : throw new InvalidOperationException("Cannot read ArrayElementProperties for " + PropertyType); + + [PublicAPI] + public TriPropertyTree PropertyTree { get; } + + [PublicAPI] + public bool IsReadOnly + { + get + { + if (_isReadOnlyBackingField == null) + { + _isReadOnlyBackingField = _definition.IsReadOnly || _parent.IsReadOnly; + } + + return _isReadOnlyBackingField.Value; + } + } + + public void ApplyChildValueModifications(int targetIndex) + { + var parentValue = _parent.GetValue(targetIndex); + var value = _definition.GetValue(parentValue); + _definition.SetValue(parentValue, value); + + _parent.ApplyChildValueModifications(targetIndex); + } + + [PublicAPI] + [CanBeNull] + public object Value { get; private set; } + + object ITriPropertyParent.GetValue(int targetIndex) + { + return _definition.GetValue(_parent.GetValue(targetIndex)); + } + + [PublicAPI] + public void SetValue(object value) + { + Undo.RegisterCompleteObjectUndo(PropertyTree.TargetObjects, "Inspector"); + Undo.FlushUndoRecordObjects(); + + for (var i = 0; i < PropertyTree.TargetObjects.Length; i++) + { + _definition.SetValue(_parent.GetValue(i), value); + } + + _serializedProperty?.serializedObject.Update(); + + if (_serializedProperty != null) + { + _serializedProperty.serializedObject.ApplyModifiedProperties(); + } + else + { + for (var i = 0; i < PropertyTree.TargetObjects.Length; i++) + { + _parent.ApplyChildValueModifications(i); + } + } + + Update(); + } + + internal void Update() + { + var newValue = _definition.GetValue(_parent.GetValue(0)); + var valueChanged = !ReferenceEquals(Value, newValue); + + var newValueType = valueChanged ? newValue?.GetType() : ValueType; + var valueTypeChanged = ValueType != newValueType; + + Value = newValue; + ValueType = newValueType; + + switch (PropertyType) + { + case TriPropertyType.Generic: + case TriPropertyType.Reference: + if (_childrenProperties == null || valueTypeChanged) + { + _childrenProperties ??= new List(); + _childrenProperties.Clear(); + + var selfType = PropertyType == TriPropertyType.Reference ? ValueType : FieldType; + if (selfType != null) + { + foreach (var childDefinition in TriTypeDefinition.GetCached(selfType).Properties) + { + var childSerializedProperty = + _serializedProperty?.FindPropertyRelative(childDefinition.Name); + var childProperty = + new TriProperty(PropertyTree, this, childDefinition, childSerializedProperty); + + _childrenProperties.Add(childProperty); + } + } + } + + foreach (var childrenProperty in _childrenProperties) + { + childrenProperty.Update(); + } + + break; + + case TriPropertyType.Array: + _arrayElementProperties ??= new List(); + + var list = (IList) Value ?? EmptyList; + + while (_arrayElementProperties.Count < list.Count) + { + var index = _arrayElementProperties.Count; + var elementDefinition = _definition.GetArrayElementDefinition(index); + var elementSerializedReference = _serializedProperty?.GetArrayElementAtIndex(index); + + var elementProperty = + new TriProperty(PropertyTree, this, elementDefinition, elementSerializedReference); + + _arrayElementProperties.Add(elementProperty); + } + + while (_arrayElementProperties.Count > list.Count) + { + _arrayElementProperties.RemoveAt(_arrayElementProperties.Count - 1); + } + + foreach (var arrayElementProperty in _arrayElementProperties) + { + arrayElementProperty.Update(); + } + + break; + } + } + + [PublicAPI] + public bool TryGetSerializedProperty(out SerializedProperty serializedProperty) + { + serializedProperty = _serializedProperty; + return serializedProperty != null; + } + + [PublicAPI] + public bool TryGetAttribute(out TAttribute attribute) + where TAttribute : Attribute + { + if (ValueType != null) + { + foreach (var attr in TriReflectionUtilities.GetAttributesCached(ValueType)) + { + if (attr is TAttribute typedAttr) + { + attribute = typedAttr; + return true; + } + } + } + + foreach (var attr in _definition.Attributes) + { + if (attr is TAttribute typedAttr) + { + attribute = typedAttr; + return true; + } + } + + attribute = null; + return false; + } + + private static TriPropertyType GetPropertyType(TriProperty property) + { + if (property._serializedProperty != null) + { + if (property._serializedProperty.isArray && + property._serializedProperty.propertyType != SerializedPropertyType.String) + { + return TriPropertyType.Array; + } + + if (property._serializedProperty.propertyType == SerializedPropertyType.ManagedReference) + { + return TriPropertyType.Reference; + } + + if (property._serializedProperty.propertyType == SerializedPropertyType.Generic) + { + return TriPropertyType.Generic; + } + + return TriPropertyType.Primitive; + } + + if (property._definition.FieldType.IsPrimitive || + property._definition.FieldType == typeof(string)) + { + return TriPropertyType.Primitive; + } + + if (property._definition.FieldType.IsValueType) + { + return TriPropertyType.Generic; + } + + if (property._definition.IsArray) + { + return TriPropertyType.Array; + } + + return TriPropertyType.Reference; + } + } + + public interface ITriPropertyParent + { + object GetValue(int targetIndex); + bool IsReadOnly { get; } + + void ApplyChildValueModifications(int targetIndex); + } + + public enum TriPropertyType + { + Array, + Reference, + Generic, + Primitive, + } +} \ No newline at end of file diff --git a/Editor/TriProperty.cs.meta b/Editor/TriProperty.cs.meta new file mode 100644 index 0000000..05e51ec --- /dev/null +++ b/Editor/TriProperty.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4db12eccd9e84863a9b3b445ce3ac85e +timeCreated: 1638862848 \ No newline at end of file diff --git a/Editor/TriPropertyDefinition.cs b/Editor/TriPropertyDefinition.cs new file mode 100644 index 0000000..2d45c04 --- /dev/null +++ b/Editor/TriPropertyDefinition.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using JetBrains.Annotations; +using TriInspector.Utilities; +using UnityEngine; + +namespace TriInspector +{ + internal class TriPropertyDefinition + { + private readonly Func _valueGetter; + [CanBeNull] private readonly Action _valueSetter; + + private IReadOnlyList _drawersBackingField; + + internal TriPropertyDefinition(int order, FieldInfo fi) + : this(order, fi.Name, fi.FieldType, fi.GetValue, fi.SetValue, fi.GetCustomAttributes(), false) + { + } + + internal TriPropertyDefinition(int order, PropertyInfo pi) + : this(order, pi.Name, pi.PropertyType, MakeGetter(pi), MakeSetter(pi), pi.GetCustomAttributes(), false) + { + } + + private TriPropertyDefinition( + int order, + string fieldName, + Type fieldType, + Func valueGetter, + Action valueSetter, + IEnumerable fieldAttributes, + bool isArrayElement) + { + Name = fieldName; + FieldType = fieldType; + IsArrayElement = isArrayElement; + + _valueGetter = valueGetter; + _valueSetter = valueSetter; + + Attributes = fieldAttributes.ToList(); + Order = Attributes.TryGet(out PropertyOrderAttribute orderAttribute) ? orderAttribute.Order : order; + IsReadOnly = _valueSetter == null || Attributes.TryGet(out ReadOnlyAttribute _); + + if (TriReflectionUtilities.IsArrayOrList(FieldType, out var elementType)) + { + IsArray = true; + ArrayElementType = elementType; + } + } + + public Type FieldType { get; } + + public string Name { get; } + + public int Order { get; } + + public IReadOnlyList Attributes { get; } + + public bool IsReadOnly { get; } + + public bool IsArrayElement { get; } + public Type ArrayElementType { get; } + + public bool IsArray { get; } + + public IReadOnlyList Drawers + { + get + { + if (_drawersBackingField == null) + { + var valueDrawers = + from drawer in TriDrawersUtilities.AllValueDrawerTypes + where TriDrawersUtilities.IsValueDrawerFor(drawer.DrawerType, FieldType) + select CreateValueDrawer(drawer); + + var attributeDrawers = + from attribute in Attributes + from drawer in TriDrawersUtilities.AllAttributeDrawerTypes + where TriDrawersUtilities.IsAttributeDrawerFor(drawer.DrawerType, attribute) + select CreateAttributeDrawer(drawer, attribute); + + _drawersBackingField = Enumerable.Empty() + .Concat(valueDrawers) + .Concat(attributeDrawers) + .OrderBy(it => it.Order) + .ToList(); + + static TriValueDrawer CreateValueDrawer(RegisterTriDrawerAttribute drawer) + { + var instance = (TriValueDrawer) Activator.CreateInstance(drawer.DrawerType); + instance.ApplyOnArrayElement = drawer.ApplyOnArrayElement; + instance.Order = drawer.Order; + return instance; + } + + static TriAttributeDrawer CreateAttributeDrawer(RegisterTriDrawerAttribute drawer, + Attribute attribute) + { + var instance = (TriAttributeDrawer) Activator.CreateInstance(drawer.DrawerType); + instance.ApplyOnArrayElement = drawer.ApplyOnArrayElement; + instance.Order = drawer.Order; + instance.RawAttribute = attribute; + return instance; + } + } + + return _drawersBackingField; + } + } + + public object GetValue(object obj) + { + return _valueGetter(obj); + } + + public void SetValue(object obj, object value) + { + if (IsReadOnly) + { + Debug.LogError("Cannot set value for readonly property"); + return; + } + + _valueSetter?.Invoke(obj, value); + } + + public TriPropertyDefinition GetArrayElementDefinition(int index) + { + if (!IsArray) + { + throw new InvalidOperationException( + $"Cannot get array element definition for non array property: {FieldType}"); + } + + var elementName = $"Element {index}"; + var elementGetter = new Func(obj => ((IList) obj)[index]); + var elementSetter = new Action((obj, value) => ((IList) obj)[index] = value); + var elementOrder = index; + var elementAttributes = Attributes; + + var definition = new TriPropertyDefinition(elementOrder, elementName, ArrayElementType, + elementGetter, elementSetter, elementAttributes, true); + + return definition; + } + + private static Func MakeGetter(PropertyInfo pi) + { + var method = pi.GetMethod; + return obj => method.Invoke(obj, null); + } + + private static Action MakeSetter(PropertyInfo pi) + { + var method = pi.SetMethod; + if (method == null) + { + return null; + } + + return (obj, value) => method.Invoke(obj, new[] {value,}); + } + } +} \ No newline at end of file diff --git a/Editor/TriPropertyDefinition.cs.meta b/Editor/TriPropertyDefinition.cs.meta new file mode 100644 index 0000000..2380340 --- /dev/null +++ b/Editor/TriPropertyDefinition.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4feaa123e82e4c93846c94ebd3af253e +timeCreated: 1638873323 \ No newline at end of file diff --git a/Editor/TriPropertyTree.cs b/Editor/TriPropertyTree.cs new file mode 100644 index 0000000..e4d6d16 --- /dev/null +++ b/Editor/TriPropertyTree.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using TriInspector.Elements; +using UnityEditor; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace TriInspector +{ + public sealed class TriPropertyTree : ITriPropertyParent + { + private readonly TriInspectorElement _inspectorElement; + + private TriPropertyTree(SerializedObject serializedObject) + { + TargetObjects = serializedObject.targetObjects; + TargetObjectType = TargetObjects[0].GetType(); + Root = this; + + Properties = TriTypeDefinition.GetCached(TargetObjectType) + .Properties + .Select(propertyDefinition => + { + var serializedProperty = serializedObject.FindProperty(propertyDefinition.Name); + return new TriProperty(this, this, propertyDefinition, serializedProperty); + }) + .ToList(); + + _inspectorElement = new TriInspectorElement(this); + _inspectorElement.AttachInternal(); + } + + [PublicAPI] + public IReadOnlyList Properties { get; } + + [PublicAPI] + public Object[] TargetObjects { get; } + + [PublicAPI] + public Type TargetObjectType { get; } + + public TriPropertyTree Root { get; } + + object ITriPropertyParent.GetValue(int targetIndex) => TargetObjects[targetIndex]; + bool ITriPropertyParent.IsReadOnly => false; + + void ITriPropertyParent.ApplyChildValueModifications(int targetIndex) + { + EditorUtility.SetDirty(TargetObjects[targetIndex]); + } + + internal static TriPropertyTree Create(SerializedObject scriptableObject) + { + return new TriPropertyTree(scriptableObject); + } + + internal void Destroy() + { + _inspectorElement.DetachInternal(); + } + + internal void Update() + { + foreach (var property in Properties) + { + property.Update(); + } + + _inspectorElement.Update(); + } + + internal void DoLayout() + { + var width = EditorGUIUtility.currentViewWidth; + var height = _inspectorElement.GetHeight(width); + var rect = GUILayoutUtility.GetRect(width, height); + _inspectorElement.OnGUI(rect); + } + } +} \ No newline at end of file diff --git a/Editor/TriPropertyTree.cs.meta b/Editor/TriPropertyTree.cs.meta new file mode 100644 index 0000000..20102fd --- /dev/null +++ b/Editor/TriPropertyTree.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 468b264c3e164c0681760c3d98451466 +timeCreated: 1638857169 \ No newline at end of file diff --git a/Editor/TriTypeDefinition.cs b/Editor/TriTypeDefinition.cs new file mode 100644 index 0000000..ca66d06 --- /dev/null +++ b/Editor/TriTypeDefinition.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using TriInspector.Utilities; + +namespace TriInspector +{ + internal class TriTypeDefinition + { + private static readonly Dictionary Cache = + new Dictionary(); + + private TriTypeDefinition(Type type) + { + var fields = TriReflectionUtilities + .GetAllInstanceFieldsInDeclarationOrder(type) + .Where(IsSerialized) + .Select((it, ind) => new TriPropertyDefinition(ind + 1, it)) + .ToList(); + + var properties = TriReflectionUtilities + .GetAllInstancePropertiesInDeclarationOrder(type) + .Where(IsSerialized) + .Select((it, ind) => new TriPropertyDefinition(ind + fields.Count + 1, it)) + .ToList(); + + Properties = Enumerable.Empty() + .Concat(fields) + .Concat(properties) + .OrderBy(it => it.Order) + .ToList(); + } + + public IReadOnlyList Properties { get; } + + private static bool IsSerialized(FieldInfo fieldInfo) + { + return TriUnitySerializationUtilities.IsSerializableByUnity(fieldInfo); + } + + private static bool IsSerialized(PropertyInfo propertyInfo) + { + return propertyInfo.GetCustomAttribute() != null; + } + + public static TriTypeDefinition GetCached(Type type) + { + if (Cache.TryGetValue(type, out var definition)) + { + return definition; + } + + return Cache[type] = new TriTypeDefinition(type); + } + } +} \ No newline at end of file diff --git a/Editor/TriTypeDefinition.cs.meta b/Editor/TriTypeDefinition.cs.meta new file mode 100644 index 0000000..83ec168 --- /dev/null +++ b/Editor/TriTypeDefinition.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 034ca4c8b571472fb71db422a48cfe07 +timeCreated: 1638870763 \ No newline at end of file diff --git a/Editor/TriValue.cs b/Editor/TriValue.cs new file mode 100644 index 0000000..eed500f --- /dev/null +++ b/Editor/TriValue.cs @@ -0,0 +1,18 @@ +namespace TriInspector +{ + public readonly struct TriValue + { + internal TriValue(TriProperty property) + { + Property = property; + } + + public TriProperty Property { get; } + + public T Value + { + get => (T) Property.Value; + set => Property.SetValue(value); + } + } +} \ No newline at end of file diff --git a/Editor/TriValue.cs.meta b/Editor/TriValue.cs.meta new file mode 100644 index 0000000..ec13054 --- /dev/null +++ b/Editor/TriValue.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a925dd69982048009ab567f0b75ec326 +timeCreated: 1639381003 \ No newline at end of file diff --git a/Editor/TriValueDrawer.cs b/Editor/TriValueDrawer.cs new file mode 100644 index 0000000..930c579 --- /dev/null +++ b/Editor/TriValueDrawer.cs @@ -0,0 +1,61 @@ +using JetBrains.Annotations; +using UnityEngine; + +namespace TriInspector +{ + public abstract class TriValueDrawer : TriCustomDrawer + { + } + + public abstract class TriValueDrawer : TriValueDrawer + { + public sealed override TriElement CreateElementInternal(TriProperty property, TriElement next) + { + return CreateElement(new TriValue(property), next); + } + + [PublicAPI] + public virtual TriElement CreateElement(TriValue propertyValue, TriElement next) + { + return new DefaultValueDrawerElement(this, propertyValue, next); + } + + [PublicAPI] + public virtual float GetHeight(float width, TriValue propertyValue, TriElement next) + { + return next.GetHeight(width); + } + + [PublicAPI] + public virtual void OnGUI(Rect position, TriValue propertyValue, TriElement next) + { + next.OnGUI(position); + } + + internal class DefaultValueDrawerElement : TriElement + { + private readonly TriValueDrawer _drawer; + private readonly TriElement _next; + private readonly TriValue _propertyValue; + + public DefaultValueDrawerElement(TriValueDrawer drawer, TriValue propertyValue, TriElement next) + { + _drawer = drawer; + _propertyValue = propertyValue; + _next = next; + + AddChild(next); + } + + public override float GetHeight(float width) + { + return _drawer.GetHeight(width, _propertyValue, _next); + } + + public override void OnGUI(Rect position) + { + _drawer.OnGUI(position, _propertyValue, _next); + } + } + } +} \ No newline at end of file diff --git a/Editor/TriValueDrawer.cs.meta b/Editor/TriValueDrawer.cs.meta new file mode 100644 index 0000000..9c15ece --- /dev/null +++ b/Editor/TriValueDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: dfd7988d91ca4f879f888735018e9116 +timeCreated: 1639381337 \ No newline at end of file diff --git a/Editor/Utilities.meta b/Editor/Utilities.meta new file mode 100644 index 0000000..48d773d --- /dev/null +++ b/Editor/Utilities.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 52ef049660d64f2f9b2966acfb8d3447 +timeCreated: 1638773133 \ No newline at end of file diff --git a/Editor/Utilities/EditorGUIUtilityProxy.cs b/Editor/Utilities/EditorGUIUtilityProxy.cs new file mode 100644 index 0000000..6df166a --- /dev/null +++ b/Editor/Utilities/EditorGUIUtilityProxy.cs @@ -0,0 +1,23 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Utilities +{ + public class EditorGUIUtilityProxy + { + private static Func _getHelpIcon; + + public static Texture2D GetHelpIcon(MessageType type) + { + if (_getHelpIcon == null) + { + _getHelpIcon = TriReflectionUtilities + .GetUnityEditorTypeByName("EditorGUIUtility") + .CompileStaticMethod("GetHelpIcon"); + } + + return _getHelpIcon(type); + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/EditorGUIUtilityProxy.cs.meta b/Editor/Utilities/EditorGUIUtilityProxy.cs.meta new file mode 100644 index 0000000..e15f1b3 --- /dev/null +++ b/Editor/Utilities/EditorGUIUtilityProxy.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0c34c0be768944a3ad89255c85434802 +timeCreated: 1641381655 \ No newline at end of file diff --git a/Editor/Utilities/ScriptAttributeUtilityProxy.cs b/Editor/Utilities/ScriptAttributeUtilityProxy.cs new file mode 100644 index 0000000..8bb9357 --- /dev/null +++ b/Editor/Utilities/ScriptAttributeUtilityProxy.cs @@ -0,0 +1,84 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Utilities +{ + internal static class ScriptAttributeUtilityProxy + { + private static Func _getHandler; + + public static PropertyHandlerProxy GetHandler(SerializedProperty property) + { + if (_getHandler == null) + { + _getHandler = TriReflectionUtilities + .GetUnityEditorTypeByName("ScriptAttributeUtility") + .CompileStaticMethod("GetHandler"); + } + + return new PropertyHandlerProxy(_getHandler(property)); + } + } + + public readonly struct PropertyHandlerProxy + { + private static Func _hasPropertyDrawerProperty; + private static Func _getHeightMethod; + private static Func _onGuiMethod; + + private readonly object _self; + + internal PropertyHandlerProxy(object self) + { + _self = self; + } + + // ReSharper disable once InconsistentNaming + public bool hasPropertyDrawer + { + get + { + if (_hasPropertyDrawerProperty == null) + { + _hasPropertyDrawerProperty = TriReflectionUtilities + .GetUnityEditorTypeByName("PropertyHandler") + .CompileInstanceProperty("hasPropertyDrawer"); + } + + return _hasPropertyDrawerProperty(_self); + } + } + + public float GetHeight( + SerializedProperty property, + GUIContent label, + bool includeChildren) + { + if (_getHeightMethod == null) + { + _getHeightMethod = TriReflectionUtilities + .GetUnityEditorTypeByName("PropertyHandler") + .CompileInstanceMethod("GetHeight"); + } + + return _getHeightMethod(_self, property, label, includeChildren); + } + + public bool OnGUI( + Rect position, + SerializedProperty property, + GUIContent label, + bool includeChildren) + { + if (_onGuiMethod == null) + { + _onGuiMethod = TriReflectionUtilities + .GetUnityEditorTypeByName("PropertyHandler") + .CompileInstanceMethod("OnGUI"); + } + + return _onGuiMethod(_self, position, property, label, includeChildren); + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/ScriptAttributeUtilityProxy.cs.meta b/Editor/Utilities/ScriptAttributeUtilityProxy.cs.meta new file mode 100644 index 0000000..247d266 --- /dev/null +++ b/Editor/Utilities/ScriptAttributeUtilityProxy.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9d3310787ea648a18e32a0da39a292c2 +timeCreated: 1638773139 \ No newline at end of file diff --git a/Editor/Utilities/TriAttributeUtilities.cs b/Editor/Utilities/TriAttributeUtilities.cs new file mode 100644 index 0000000..52168dd --- /dev/null +++ b/Editor/Utilities/TriAttributeUtilities.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; + +namespace TriInspector.Utilities +{ + internal static class TriAttributeUtilities + { + public static bool TryGet(this IReadOnlyList attributes, out T it) + where T : Attribute + { + foreach (var attribute in attributes) + { + if (attribute is T typeAttribute) + { + it = typeAttribute; + return true; + } + } + + it = null; + return false; + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/TriAttributeUtilities.cs.meta b/Editor/Utilities/TriAttributeUtilities.cs.meta new file mode 100644 index 0000000..ee5d3d5 --- /dev/null +++ b/Editor/Utilities/TriAttributeUtilities.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ff3eb732102046b0b36e76f9d17cab4e +timeCreated: 1638876778 \ No newline at end of file diff --git a/Editor/Utilities/TriDrawersUtilities.cs b/Editor/Utilities/TriDrawersUtilities.cs new file mode 100644 index 0000000..3c46246 --- /dev/null +++ b/Editor/Utilities/TriDrawersUtilities.cs @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using TriInspector.Elements; + +namespace TriInspector.Utilities +{ + internal class TriDrawersUtilities + { + private static IDictionary _allGroupDrawersCacheBackingField; + private static IReadOnlyList _allAttributeDrawerTypesBackingField; + private static IReadOnlyList _allValueDrawerTypesBackingField; + + private static IDictionary AllGroupDrawersCache + { + get + { + if (_allGroupDrawersCacheBackingField == null) + { + _allGroupDrawersCacheBackingField = ( + from asm in TriReflectionUtilities.Assemblies + from attr in asm.GetCustomAttributes() + let groupAttributeType = IsGroupDrawerType(attr.DrawerType, out var t) ? t : null + where groupAttributeType != null + select new KeyValuePair(groupAttributeType, attr) + ).ToDictionary( + it => it.Key, + it => (TriGroupDrawer) Activator.CreateInstance(it.Value.DrawerType)); + } + + return _allGroupDrawersCacheBackingField; + } + } + + public static IReadOnlyList AllValueDrawerTypes + { + get + { + if (_allValueDrawerTypesBackingField == null) + { + _allValueDrawerTypesBackingField = ( + from asm in TriReflectionUtilities.Assemblies + from attr in asm.GetCustomAttributes() + where IsValueDrawerType(attr.DrawerType, out _) + select attr + ).ToList(); + } + + return _allValueDrawerTypesBackingField; + } + } + + public static IReadOnlyList AllAttributeDrawerTypes + { + get + { + if (_allAttributeDrawerTypesBackingField == null) + { + _allAttributeDrawerTypesBackingField = ( + from asm in TriReflectionUtilities.Assemblies + from attr in asm.GetCustomAttributes() + where IsAttributeDrawerType(attr.DrawerType, out _) + select attr + ).ToList(); + } + + return _allAttributeDrawerTypesBackingField; + } + } + + public static TriPropertyCollectionBaseElement TryCreateGroupElementFor(DeclareGroupBaseAttribute attribute) + { + if (!AllGroupDrawersCache.TryGetValue(attribute.GetType(), out var attr)) + { + return null; + } + + return attr.CreateElementInternal(attribute); + } + + private static bool IsGroupDrawerType(Type type, out Type groupAttributeType) + { + groupAttributeType = null; + + if (type.IsAbstract) + { + return false; + } + + if (type.GetConstructor(Type.EmptyTypes) == null) + { + return false; + } + + var drawerType = type.BaseType; + + if (drawerType == null) + { + return false; + } + + if (!drawerType.IsGenericType) + { + return false; + } + + if (drawerType.GetGenericTypeDefinition() != typeof(TriGroupDrawer<>)) + { + return false; + } + + groupAttributeType = drawerType.GetGenericArguments()[0]; + return true; + } + + private static bool IsValueDrawerType(Type type, out Type valueType) + { + valueType = null; + + if (type.IsAbstract) + { + return false; + } + + if (type.GetConstructor(Type.EmptyTypes) == null) + { + return false; + } + + var drawerType = type.BaseType; + + if (drawerType == null) + { + return false; + } + + if (!drawerType.IsGenericType) + { + return false; + } + + if (drawerType.GetGenericTypeDefinition() != typeof(TriValueDrawer<>)) + { + return false; + } + + valueType = drawerType.GetGenericArguments()[0]; + return true; + } + + private static bool IsAttributeDrawerType(Type type, out Type attributeType) + { + attributeType = null; + + if (type.IsAbstract) + { + return false; + } + + if (type.GetConstructor(Type.EmptyTypes) == null) + { + return false; + } + + var drawerType = type.BaseType; + + if (drawerType == null) + { + return false; + } + + if (!drawerType.IsGenericType) + { + return false; + } + + if (drawerType.GetGenericTypeDefinition() != typeof(TriAttributeDrawer<>)) + { + return false; + } + + attributeType = drawerType.GetGenericArguments()[0]; + return true; + } + + public static bool IsValueDrawerFor(Type drawerType, Type valueType) + { + if (IsValueDrawerType(drawerType, out var valType)) + { + return valType == valueType; + } + + return false; + } + + public static bool IsAttributeDrawerFor(Type drawerType, Attribute attribute) + { + if (IsAttributeDrawerType(drawerType, out var attributeType)) + { + return attributeType == attribute.GetType(); + } + + return false; + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/TriDrawersUtilities.cs.meta b/Editor/Utilities/TriDrawersUtilities.cs.meta new file mode 100644 index 0000000..93435c0 --- /dev/null +++ b/Editor/Utilities/TriDrawersUtilities.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fbb9d9e8efd64dedb3b04ab3f90317f7 +timeCreated: 1638886023 \ No newline at end of file diff --git a/Editor/Utilities/TriEditorGUI.cs b/Editor/Utilities/TriEditorGUI.cs new file mode 100644 index 0000000..8b70b84 --- /dev/null +++ b/Editor/Utilities/TriEditorGUI.cs @@ -0,0 +1,23 @@ +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Utilities +{ + public static class TriEditorGUI + { + public static void Foldout(Rect rect, TriProperty property) + { + var content = property.DisplayNameContent; + property.IsExpanded = EditorGUI.Foldout(rect, property.IsExpanded, content, true); + } + + public static void DrawBox(Rect position, GUIStyle style, + bool isHover = false, bool isActive = false, bool on = false, bool hasKeyboardFocus = false) + { + if (Event.current.type == EventType.Repaint) + { + style.Draw(position, GUIContent.none, isHover, isActive, on, hasKeyboardFocus); + } + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/TriEditorGUI.cs.meta b/Editor/Utilities/TriEditorGUI.cs.meta new file mode 100644 index 0000000..fd97d81 --- /dev/null +++ b/Editor/Utilities/TriEditorGUI.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 59bc827ebe19464ea936ff5cf8ae1b7f +timeCreated: 1638864333 \ No newline at end of file diff --git a/Editor/Utilities/TriGuiHelper.cs b/Editor/Utilities/TriGuiHelper.cs new file mode 100644 index 0000000..5ecefa8 --- /dev/null +++ b/Editor/Utilities/TriGuiHelper.cs @@ -0,0 +1,128 @@ +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Utilities +{ + public static class TriGuiHelper + { + private static readonly Stack EditorStack = new Stack(); + private static readonly Stack LabelWidthStack = new Stack(); + private static readonly Stack IndentLevelStack = new Stack(); + private static readonly Stack ColorStack = new Stack(); + + private static void CleanUp() + { + EditorStack.Clear(); + LabelWidthStack.Clear(); + IndentLevelStack.Clear(); + } + + public static void PushEditor(Editor editor) + { + EditorStack.Push(new EditorData + { + editor = editor, + labelWidthStackSize = LabelWidthStack.Count, + indentLevelStackSize = IndentLevelStack.Count, + ColorStackSize = ColorStack.Count, + }); + } + + public static void PopEditor(Editor editor) + { + if (EditorStack.Count == 0) + { + Debug.LogError("No editor in stack"); + return; + } + + var data = EditorStack.Pop(); + + if (data.editor != editor) + { + Debug.LogError($"Editor pop mismatch: {editor}"); + } + + CheckSizeMismatch(data.labelWidthStackSize, LabelWidthStack, nameof(LabelWidthStack), editor); + CheckSizeMismatch(data.indentLevelStackSize, IndentLevelStack, nameof(IndentLevelStack), editor); + CheckSizeMismatch(data.ColorStackSize, ColorStack, nameof(ColorStack), editor); + + if (EditorStack.Count == 0) + { + CleanUp(); + } + } + + public static void PushLabelWidth(float labelWidth) + { + LabelWidthStack.Push(EditorGUIUtility.labelWidth); + + if (labelWidth > 0) + { + EditorGUIUtility.labelWidth = labelWidth; + } + } + + public static void PopLabelWidth() + { + if (LabelWidthStack.Count == 0) + { + Debug.LogError("No label width in stack"); + return; + } + + EditorGUIUtility.labelWidth = LabelWidthStack.Pop(); + } + + public static void PushIndentLevel(int indent = 1) + { + IndentLevelStack.Push(EditorGUI.indentLevel); + EditorGUI.indentLevel += indent; + } + + public static void PopIndentLevel() + { + if (IndentLevelStack.Count == 0) + { + Debug.LogError("No indent level in stack"); + return; + } + + EditorGUI.indentLevel = IndentLevelStack.Pop(); + } + + public static void PushColor(Color color) + { + ColorStack.Push(GUI.color); + GUI.color = color; + } + + public static void PopColor() + { + if (ColorStack.Count == 0) + { + Debug.LogError("No color in stack"); + return; + } + + GUI.color = ColorStack.Pop(); + } + + private static void CheckSizeMismatch(int expectedSize, Stack stack, string stackName, Editor editor) + { + if (expectedSize != stack.Count) + { + Debug.LogError($"{stackName} size mismatch in {editor.name} editor"); + } + } + + private struct EditorData + { + public Editor editor; + public int labelWidthStackSize; + public int indentLevelStackSize; + public int ColorStackSize; + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/TriGuiHelper.cs.meta b/Editor/Utilities/TriGuiHelper.cs.meta new file mode 100644 index 0000000..87a0066 --- /dev/null +++ b/Editor/Utilities/TriGuiHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 787c857ae9a64fdbb01e6ced9309a09e +timeCreated: 1639377094 \ No newline at end of file diff --git a/Editor/Utilities/TriManagedReferenceGui.cs b/Editor/Utilities/TriManagedReferenceGui.cs new file mode 100644 index 0000000..7b31d40 --- /dev/null +++ b/Editor/Utilities/TriManagedReferenceGui.cs @@ -0,0 +1,54 @@ +using System; +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace TriInspector.Utilities +{ + internal static class TriManagedReferenceGui + { + public static void DrawTypeSelector(Rect rect, TriProperty property) + { + var typeNameContent = new GUIContent(property.ValueType?.Name ?? "[None]"); + + if (EditorGUI.DropdownButton(rect, typeNameContent, FocusType.Passive)) + { + CreateSelectorMenu(property); + Event.current.Use(); + } + } + + private static void CreateSelectorMenu(TriProperty property) + { + var types = TriReflectionUtilities + .AllNonAbstractTypes + .Where(type => property.FieldType.IsAssignableFrom(type)) + .Where(type => type.GetConstructor(Type.EmptyTypes) != null) + .ToList(); + + var context = new GenericMenu(); + + // None + { + var on = property.ValueType == null; + context.AddItem(new GUIContent("[None]"), on, () => property.SetValue(null)); + } + + context.AddSeparator(""); + + foreach (var itemType in types) + { + var type = itemType; + + var on = property.ValueType == type; + context.AddItem(new GUIContent(type.Name), on, () => + { + var instance = Activator.CreateInstance(type); + property.SetValue(instance); + }); + } + + context.ShowAsContext(); + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/TriManagedReferenceGui.cs.meta b/Editor/Utilities/TriManagedReferenceGui.cs.meta new file mode 100644 index 0000000..ecc8e1a --- /dev/null +++ b/Editor/Utilities/TriManagedReferenceGui.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d625706e14d8480a9ab71980d1eb1e48 +timeCreated: 1638804204 \ No newline at end of file diff --git a/Editor/Utilities/TriReflectionCompileExtensions.cs b/Editor/Utilities/TriReflectionCompileExtensions.cs new file mode 100644 index 0000000..a77ede1 --- /dev/null +++ b/Editor/Utilities/TriReflectionCompileExtensions.cs @@ -0,0 +1,102 @@ +using System; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; + +namespace TriInspector.Utilities +{ + internal static class TriReflectionCompileExtensions + { + public static Func CompileInstanceProperty(this Type type, string name) + { + const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + var property = GetProperty(type, name, flags); + + var target = Expression.Parameter(typeof(object)); + var body = Expression.Call(Expression.Convert(target, type), property.GetMethod); + var lambda = Expression.Lambda>(body, target); + return lambda.Compile(); + } + + public static Action CompileVoidInstanceMethod(this Type type, string name) + { + const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + var method = GetMethod(type, name, 0, flags); + + var target = Expression.Parameter(typeof(object)); + var body = Expression.Call(Expression.Convert(target, type), method); + var lambda = Expression.Lambda>(body, target); + return lambda.Compile(); + } + + public static Action CompileVoidInstanceMethod(this Type type, string name) + { + const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + var method = GetMethod(type, name, 1, flags); + + var target = Expression.Parameter(typeof(object)); + var a1 = Expression.Parameter(typeof(T1)); + var body = Expression.Call(Expression.Convert(target, type), method, a1); + var lambda = Expression.Lambda>(body, target, a1); + return lambda.Compile(); + } + + public static Func CompileInstanceMethod( + this Type type, string name) + { + const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + var method = GetMethod(type, name, 3, flags); + + var target = Expression.Parameter(typeof(object)); + var a1 = Expression.Parameter(typeof(T1)); + var a2 = Expression.Parameter(typeof(T2)); + var a3 = Expression.Parameter(typeof(T3)); + var body = Expression.Call(Expression.Convert(target, type), method, a1, a2, a3); + var lambda = Expression.Lambda>(body, target, a1, a2, a3); + return lambda.Compile(); + } + + public static Func CompileInstanceMethod( + this Type type, string name) + { + const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + var method = GetMethod(type, name, 4, flags); + + var target = Expression.Parameter(typeof(object)); + var a1 = Expression.Parameter(typeof(T1)); + var a2 = Expression.Parameter(typeof(T2)); + var a3 = Expression.Parameter(typeof(T3)); + var a4 = Expression.Parameter(typeof(T4)); + var body = Expression.Call(Expression.Convert(target, type), method, a1, a2, a3, a4); + var lambda = Expression.Lambda>(body, target, a1, a2, a3, a4); + return lambda.Compile(); + } + + public static Func CompileStaticMethod( + this Type type, string name) + { + const BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; + var method = GetMethod(type, name, 1, flags); + + var a1 = Expression.Parameter(typeof(T1)); + var body = Expression.Call(method, a1); + var lambda = Expression.Lambda>(body, a1); + return lambda.Compile(); + } + + private static PropertyInfo GetProperty(this Type type, string name, BindingFlags flags) + { + var property = type.GetProperties(flags).SingleOrDefault(it => it.Name == name); + return property ?? throw new InvalidOperationException($"Property {name} of type {type} not found"); + } + + private static MethodInfo GetMethod(Type type, string name, int parametersCount, BindingFlags flags) + { + var method = type.GetMethods(flags) + .SingleOrDefault(it => it.Name == name && it.GetParameters().Length == parametersCount); + + return method ?? throw new InvalidOperationException( + $"Method {name} of type {type} with {parametersCount} args not found"); + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/TriReflectionCompileExtensions.cs.meta b/Editor/Utilities/TriReflectionCompileExtensions.cs.meta new file mode 100644 index 0000000..4a1f8fb --- /dev/null +++ b/Editor/Utilities/TriReflectionCompileExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d558661b36c94968ac0e2f704da4f6cb +timeCreated: 1639241554 \ No newline at end of file diff --git a/Editor/Utilities/TriReflectionUtilities.cs b/Editor/Utilities/TriReflectionUtilities.cs new file mode 100644 index 0000000..4b234da --- /dev/null +++ b/Editor/Utilities/TriReflectionUtilities.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEditor; + +namespace TriInspector.Utilities +{ + internal static class TriReflectionUtilities + { + private static readonly Dictionary> AttributesCache = + new Dictionary>(); + + private static IReadOnlyList _assemblies; + private static IReadOnlyList _allNonAbstractTypesBackingField; + + public static IReadOnlyList Assemblies + { + get + { + if (_assemblies == null) + { + _assemblies = AppDomain.CurrentDomain.GetAssemblies(); + } + + return _assemblies; + } + } + + public static IReadOnlyList AllNonAbstractTypes + { + get + { + if (_allNonAbstractTypesBackingField == null) + { + _allNonAbstractTypesBackingField = Assemblies + .SelectMany(asm => asm.GetTypes()) + .Where(type => !type.IsAbstract) + .ToList(); + } + + return _allNonAbstractTypesBackingField; + } + } + + public static IReadOnlyList GetAttributesCached(Type type) + { + if (AttributesCache.TryGetValue(type, out var attributes)) + { + return attributes; + } + + return AttributesCache[type] = type.GetCustomAttributes().ToList(); + } + + public static IReadOnlyList GetCustomAttributes(this Assembly asm) + { + return asm.GetCustomAttributes(typeof(T)).Cast().ToList(); + } + + public static IReadOnlyList GetAllInstanceFieldsInDeclarationOrder(Type type) + { + var result = new List(); + var typeTree = new Stack(); + + while (type != null) + { + typeTree.Push(type); + type = type.BaseType; + } + + foreach (var t in typeTree) + { + const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | + BindingFlags.Instance | BindingFlags.DeclaredOnly; + + var fields = t.GetFields(flags); + result.AddRange(fields); + } + + return result; + } + + public static IReadOnlyList GetAllInstancePropertiesInDeclarationOrder(Type type) + { + var result = new List(); + var typeTree = new Stack(); + + while (type != null) + { + typeTree.Push(type); + type = type.BaseType; + } + + foreach (var t in typeTree) + { + const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | + BindingFlags.Instance | BindingFlags.DeclaredOnly; + + var fields = t.GetProperties(flags); + result.AddRange(fields); + } + + return result; + } + + public static bool IsArrayOrList(Type type, out Type elementType) + { + if (type.IsArray) + { + elementType = type.GetElementType(); + return true; + } + + if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>)) + { + elementType = type.GetGenericArguments().Single(); + return true; + } + + elementType = null; + return false; + } + + public static Type GetUnityEditorTypeByName(string name) + { + return GetTypeByName(name, typeof(Editor).Assembly); + } + + public static Type GetTypeByName(string name, Assembly assembly) + { + return assembly + .GetTypes() + .Single(it => it.Name == name); + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/TriReflectionUtilities.cs.meta b/Editor/Utilities/TriReflectionUtilities.cs.meta new file mode 100644 index 0000000..cfd3571 --- /dev/null +++ b/Editor/Utilities/TriReflectionUtilities.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5e3f587ee2e04832bc8cd5cfcd937f32 +timeCreated: 1638857968 \ No newline at end of file diff --git a/Editor/Utilities/TriUnitySerializationUtilities.cs b/Editor/Utilities/TriUnitySerializationUtilities.cs new file mode 100644 index 0000000..3a3bab7 --- /dev/null +++ b/Editor/Utilities/TriUnitySerializationUtilities.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace TriInspector.Utilities +{ + internal static class TriUnitySerializationUtilities + { + public static bool IsSerializableByUnity(FieldInfo fieldInfo) + { + if (fieldInfo.GetCustomAttribute() != null || + fieldInfo.GetCustomAttribute() != null) + { + return false; + } + + if (fieldInfo.GetCustomAttribute() != null) + { + return true; + } + + if (fieldInfo.IsPublic || fieldInfo.GetCustomAttribute() != null) + { + return IsTypeSerializable(fieldInfo.FieldType); + } + + return false; + } + + private static bool IsTypeSerializable(Type type) + { + if (type == typeof(string) || + type == typeof(bool) || + type == typeof(char) || + type == typeof(int) || + type == typeof(float) || + type == typeof(Vector2) || + type == typeof(Vector2Int) || + type == typeof(Vector3) || + type == typeof(Vector3Int) || + type == typeof(Vector4) || + type == typeof(Color) || + type == typeof(LayerMask) || + type == typeof(Rect) || + type == typeof(RectInt) || + type == typeof(AnimationCurve) || + type == typeof(Bounds) || + type == typeof(BoundsInt) || + type == typeof(Gradient) || + type == typeof(Quaternion)) + { + return true; + } + + if (typeof(Object).IsAssignableFrom(type)) + { + return true; + } + + if (type.IsEnum) + { + return true; + } + + if (type.IsPrimitive) + { + return true; + } + + if (type.IsArray) + { + var elementType = type.GetElementType(); + return IsTypeSerializable(elementType); + } + + if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>)) + { + var elementType = type.GetGenericArguments()[0]; + return IsTypeSerializable(elementType); + } + + if (type.GetCustomAttribute() != null) + { + return true; + } + + // any other cases? + + return false; + } + } +} \ No newline at end of file diff --git a/Editor/Utilities/TriUnitySerializationUtilities.cs.meta b/Editor/Utilities/TriUnitySerializationUtilities.cs.meta new file mode 100644 index 0000000..f48d76f --- /dev/null +++ b/Editor/Utilities/TriUnitySerializationUtilities.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: eadfe6520116444e8da02fcd54916d85 +timeCreated: 1639381952 \ No newline at end of file diff --git a/Runtime.meta b/Runtime.meta new file mode 100644 index 0000000..37f6074 --- /dev/null +++ b/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e0eb7988fa380c4c90c94d3ba0a282f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Attributes.meta b/Runtime/Attributes.meta new file mode 100644 index 0000000..5b8e6c0 --- /dev/null +++ b/Runtime/Attributes.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2898ff4f810f468ab3ad610520d4305a +timeCreated: 1638868804 \ No newline at end of file diff --git a/Runtime/Attributes/DeclareBoxGroupAttribute.cs b/Runtime/Attributes/DeclareBoxGroupAttribute.cs new file mode 100644 index 0000000..77868a0 --- /dev/null +++ b/Runtime/Attributes/DeclareBoxGroupAttribute.cs @@ -0,0 +1,16 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)] + [Conditional("UNITY_EDITOR")] + public class DeclareBoxGroupAttribute : DeclareGroupBaseAttribute + { + public DeclareBoxGroupAttribute(string path) : base(path) + { + } + + public string Title { get; set; } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/DeclareBoxGroupAttribute.cs.meta b/Runtime/Attributes/DeclareBoxGroupAttribute.cs.meta new file mode 100644 index 0000000..3e4fe6c --- /dev/null +++ b/Runtime/Attributes/DeclareBoxGroupAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3b8ef8105f574de2b66a434ad3318390 +timeCreated: 1639417269 \ No newline at end of file diff --git a/Runtime/Attributes/DeclareGroupBaseAttribute.cs b/Runtime/Attributes/DeclareGroupBaseAttribute.cs new file mode 100644 index 0000000..bc6491c --- /dev/null +++ b/Runtime/Attributes/DeclareGroupBaseAttribute.cs @@ -0,0 +1,14 @@ +using System; + +namespace TriInspector +{ + public abstract class DeclareGroupBaseAttribute : Attribute + { + protected DeclareGroupBaseAttribute(string path) + { + Path = path ?? "None"; + } + + public string Path { get; } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/DeclareGroupBaseAttribute.cs.meta b/Runtime/Attributes/DeclareGroupBaseAttribute.cs.meta new file mode 100644 index 0000000..6363fd6 --- /dev/null +++ b/Runtime/Attributes/DeclareGroupBaseAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 29196c90aab84065a58211f71c9e280e +timeCreated: 1639419849 \ No newline at end of file diff --git a/Runtime/Attributes/DeclareHorizontalGroupAttribute.cs b/Runtime/Attributes/DeclareHorizontalGroupAttribute.cs new file mode 100644 index 0000000..eeed889 --- /dev/null +++ b/Runtime/Attributes/DeclareHorizontalGroupAttribute.cs @@ -0,0 +1,14 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)] + [Conditional("UNITY_EDITOR")] + public class DeclareHorizontalGroupAttribute : DeclareGroupBaseAttribute + { + public DeclareHorizontalGroupAttribute(string path) : base(path) + { + } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/DeclareHorizontalGroupAttribute.cs.meta b/Runtime/Attributes/DeclareHorizontalGroupAttribute.cs.meta new file mode 100644 index 0000000..95b4888 --- /dev/null +++ b/Runtime/Attributes/DeclareHorizontalGroupAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9b5d0fa1c34e46bbb34e0ceb78a1e999 +timeCreated: 1640871509 \ No newline at end of file diff --git a/Runtime/Attributes/GUIColorAttribute.cs b/Runtime/Attributes/GUIColorAttribute.cs new file mode 100644 index 0000000..768be21 --- /dev/null +++ b/Runtime/Attributes/GUIColorAttribute.cs @@ -0,0 +1,24 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method | + AttributeTargets.Class | AttributeTargets.Struct)] + [Conditional("UNITY_EDITOR")] + public sealed class GUIColorAttribute : Attribute + { + public float R { get; } + public float G { get; } + public float B { get; } + public float A { get; } + + public GUIColorAttribute(float r, float g, float b, float a = 1f) + { + R = r; + G = g; + B = b; + A = a; + } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/GUIColorAttribute.cs.meta b/Runtime/Attributes/GUIColorAttribute.cs.meta new file mode 100644 index 0000000..1cc2658 --- /dev/null +++ b/Runtime/Attributes/GUIColorAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e9a20bec5b2a495e9a4035e1585ebfda +timeCreated: 1638943497 \ No newline at end of file diff --git a/Runtime/Attributes/GroupAttribute.cs b/Runtime/Attributes/GroupAttribute.cs new file mode 100644 index 0000000..dcd0e73 --- /dev/null +++ b/Runtime/Attributes/GroupAttribute.cs @@ -0,0 +1,17 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] + [Conditional("UNITY_EDITOR")] + public class GroupAttribute : Attribute + { + public GroupAttribute(string path) + { + Path = path; + } + + public string Path { get; } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/GroupAttribute.cs.meta b/Runtime/Attributes/GroupAttribute.cs.meta new file mode 100644 index 0000000..256c962 --- /dev/null +++ b/Runtime/Attributes/GroupAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 34f746736a9e4b8db6093924652cf405 +timeCreated: 1639412551 \ No newline at end of file diff --git a/Runtime/Attributes/HideLabelAttribute.cs b/Runtime/Attributes/HideLabelAttribute.cs new file mode 100644 index 0000000..4cd4cc4 --- /dev/null +++ b/Runtime/Attributes/HideLabelAttribute.cs @@ -0,0 +1,11 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + [Conditional("UNITY_EDITOR")] + public sealed class HideLabelAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/Runtime/Attributes/HideLabelAttribute.cs.meta b/Runtime/Attributes/HideLabelAttribute.cs.meta new file mode 100644 index 0000000..d100b1c --- /dev/null +++ b/Runtime/Attributes/HideLabelAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 16ab42968e5c4f86ab9a607cb983508f +timeCreated: 1638868812 \ No newline at end of file diff --git a/Runtime/Attributes/IndentAttribute.cs b/Runtime/Attributes/IndentAttribute.cs new file mode 100644 index 0000000..f034be4 --- /dev/null +++ b/Runtime/Attributes/IndentAttribute.cs @@ -0,0 +1,17 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + [Conditional("UNITY_EDITOR")] + public sealed class IndentAttribute : Attribute + { + public int Indent { get; } + + public IndentAttribute(int indent = 1) + { + Indent = indent; + } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/IndentAttribute.cs.meta b/Runtime/Attributes/IndentAttribute.cs.meta new file mode 100644 index 0000000..5c7c8a7 --- /dev/null +++ b/Runtime/Attributes/IndentAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0f021bed86024c529a5a265fea051a9f +timeCreated: 1638947073 \ No newline at end of file diff --git a/Runtime/Attributes/InlinePropertyAttribute.cs b/Runtime/Attributes/InlinePropertyAttribute.cs new file mode 100644 index 0000000..a6b4c2e --- /dev/null +++ b/Runtime/Attributes/InlinePropertyAttribute.cs @@ -0,0 +1,13 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | + AttributeTargets.Class | AttributeTargets.Struct)] + [Conditional("UNITY_EDITOR")] + public sealed class InlinePropertyAttribute : Attribute + { + public float LabelWidth { get; set; } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/InlinePropertyAttribute.cs.meta b/Runtime/Attributes/InlinePropertyAttribute.cs.meta new file mode 100644 index 0000000..0df315a --- /dev/null +++ b/Runtime/Attributes/InlinePropertyAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e788cb72a55a4a69a703dd857b408ace +timeCreated: 1638947526 \ No newline at end of file diff --git a/Runtime/Attributes/LabelTextAttribute.cs b/Runtime/Attributes/LabelTextAttribute.cs new file mode 100644 index 0000000..4358c7f --- /dev/null +++ b/Runtime/Attributes/LabelTextAttribute.cs @@ -0,0 +1,17 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + [Conditional("UNITY_EDITOR")] + public sealed class LabelTextAttribute : Attribute + { + public string Text { get; } + + public LabelTextAttribute(string text) + { + Text = text; + } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/LabelTextAttribute.cs.meta b/Runtime/Attributes/LabelTextAttribute.cs.meta new file mode 100644 index 0000000..8e664f7 --- /dev/null +++ b/Runtime/Attributes/LabelTextAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c7dff14e608f492abd5a4e4c26d4fb5a +timeCreated: 1638876608 \ No newline at end of file diff --git a/Runtime/Attributes/LabelWidthAttribute.cs b/Runtime/Attributes/LabelWidthAttribute.cs new file mode 100644 index 0000000..aee578e --- /dev/null +++ b/Runtime/Attributes/LabelWidthAttribute.cs @@ -0,0 +1,17 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + [Conditional("UNITY_EDITOR")] + public sealed class LabelWidthAttribute : Attribute + { + public float Width { get; } + + public LabelWidthAttribute(float width) + { + Width = width; + } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/LabelWidthAttribute.cs.meta b/Runtime/Attributes/LabelWidthAttribute.cs.meta new file mode 100644 index 0000000..3b0d754 --- /dev/null +++ b/Runtime/Attributes/LabelWidthAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cb503940335041fd804649c32f07ab14 +timeCreated: 1638948051 \ No newline at end of file diff --git a/Runtime/Attributes/PropertyOrderAttribute.cs b/Runtime/Attributes/PropertyOrderAttribute.cs new file mode 100644 index 0000000..7c0e0db --- /dev/null +++ b/Runtime/Attributes/PropertyOrderAttribute.cs @@ -0,0 +1,17 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] + [Conditional("UNITY_EDITOR")] + public sealed class PropertyOrderAttribute : Attribute + { + public int Order { get; } + + public PropertyOrderAttribute(int order) + { + Order = order; + } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/PropertyOrderAttribute.cs.meta b/Runtime/Attributes/PropertyOrderAttribute.cs.meta new file mode 100644 index 0000000..2a8b8ef --- /dev/null +++ b/Runtime/Attributes/PropertyOrderAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e6de09475a1c44b38ce070f556f5f44d +timeCreated: 1638941803 \ No newline at end of file diff --git a/Runtime/Attributes/PropertySpaceAttribute.cs b/Runtime/Attributes/PropertySpaceAttribute.cs new file mode 100644 index 0000000..fc3b293 --- /dev/null +++ b/Runtime/Attributes/PropertySpaceAttribute.cs @@ -0,0 +1,20 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method | + AttributeTargets.Class | AttributeTargets.Struct)] + [Conditional("UNITY_EDITOR")] + public sealed class PropertySpaceAttribute : Attribute + { + public float SpaceBefore { get; set; } + public float SpaceAfter { get; set; } + + public PropertySpaceAttribute(float spaceBefore = 0, float spaceAfter = 0) + { + SpaceBefore = spaceBefore; + SpaceAfter = spaceAfter; + } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/PropertySpaceAttribute.cs.meta b/Runtime/Attributes/PropertySpaceAttribute.cs.meta new file mode 100644 index 0000000..cde24c5 --- /dev/null +++ b/Runtime/Attributes/PropertySpaceAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 27a1f5f498a04cc0b7ffedc2d2e6a8ff +timeCreated: 1638942425 \ No newline at end of file diff --git a/Runtime/Attributes/PropertyTooltipAttribute.cs b/Runtime/Attributes/PropertyTooltipAttribute.cs new file mode 100644 index 0000000..5c1a263 --- /dev/null +++ b/Runtime/Attributes/PropertyTooltipAttribute.cs @@ -0,0 +1,17 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + [Conditional("UNITY_EDITOR")] + public sealed class PropertyTooltipAttribute : Attribute + { + public string Tooltip { get; } + + public PropertyTooltipAttribute(string tooltip) + { + Tooltip = tooltip; + } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/PropertyTooltipAttribute.cs.meta b/Runtime/Attributes/PropertyTooltipAttribute.cs.meta new file mode 100644 index 0000000..ae5548a --- /dev/null +++ b/Runtime/Attributes/PropertyTooltipAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a8086d3692f24b48b221ddf74c77bad6 +timeCreated: 1638948288 \ No newline at end of file diff --git a/Runtime/Attributes/ReadOnlyAttribute.cs b/Runtime/Attributes/ReadOnlyAttribute.cs new file mode 100644 index 0000000..afb3f0a --- /dev/null +++ b/Runtime/Attributes/ReadOnlyAttribute.cs @@ -0,0 +1,12 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | + AttributeTargets.Class | AttributeTargets.Struct)] + [Conditional("UNITY_EDITOR")] + public sealed class ReadOnlyAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/Runtime/Attributes/ReadOnlyAttribute.cs.meta b/Runtime/Attributes/ReadOnlyAttribute.cs.meta new file mode 100644 index 0000000..67a1b31 --- /dev/null +++ b/Runtime/Attributes/ReadOnlyAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 07201e1119294874acfd8417ba34199e +timeCreated: 1638885262 \ No newline at end of file diff --git a/Runtime/Attributes/ShowDrawerChainAttribute.cs b/Runtime/Attributes/ShowDrawerChainAttribute.cs new file mode 100644 index 0000000..6392fa7 --- /dev/null +++ b/Runtime/Attributes/ShowDrawerChainAttribute.cs @@ -0,0 +1,11 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] + [Conditional("UNITY_EDITOR")] + public sealed class ShowDrawerChainAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/Runtime/Attributes/ShowDrawerChainAttribute.cs.meta b/Runtime/Attributes/ShowDrawerChainAttribute.cs.meta new file mode 100644 index 0000000..1a2cd23 --- /dev/null +++ b/Runtime/Attributes/ShowDrawerChainAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a2856c1dc9ed40ffbe250bf652baf8bb +timeCreated: 1638949439 \ No newline at end of file diff --git a/Runtime/Attributes/ShowInInspector.cs b/Runtime/Attributes/ShowInInspector.cs new file mode 100644 index 0000000..55571f8 --- /dev/null +++ b/Runtime/Attributes/ShowInInspector.cs @@ -0,0 +1,11 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Property)] + [Conditional("UNITY_EDITOR")] + public class ShowInInspector : Attribute + { + } +} \ No newline at end of file diff --git a/Runtime/Attributes/ShowInInspector.cs.meta b/Runtime/Attributes/ShowInInspector.cs.meta new file mode 100644 index 0000000..8f68e2b --- /dev/null +++ b/Runtime/Attributes/ShowInInspector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4d9e5878061041bfa097dda3756bc478 +timeCreated: 1639243448 \ No newline at end of file diff --git a/Runtime/Attributes/TitleAttribute.cs b/Runtime/Attributes/TitleAttribute.cs new file mode 100644 index 0000000..6a408a6 --- /dev/null +++ b/Runtime/Attributes/TitleAttribute.cs @@ -0,0 +1,17 @@ +using System; +using System.Diagnostics; + +namespace TriInspector +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] + [Conditional("UNITY_EDITOR")] + public sealed class TitleAttribute : Attribute + { + public string Title { get; } + + public TitleAttribute(string title) + { + Title = title; + } + } +} \ No newline at end of file diff --git a/Runtime/Attributes/TitleAttribute.cs.meta b/Runtime/Attributes/TitleAttribute.cs.meta new file mode 100644 index 0000000..ac6bb5e --- /dev/null +++ b/Runtime/Attributes/TitleAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 03c62d6e9c5c4b55bd2bf199b9745d95 +timeCreated: 1638944189 \ No newline at end of file diff --git a/Runtime/TriInspector.asmdef b/Runtime/TriInspector.asmdef new file mode 100644 index 0000000..5870982 --- /dev/null +++ b/Runtime/TriInspector.asmdef @@ -0,0 +1,14 @@ +{ + "name": "TriInspector", + "rootNamespace": "", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Runtime/TriInspector.asmdef.meta b/Runtime/TriInspector.asmdef.meta new file mode 100644 index 0000000..dfd4f83 --- /dev/null +++ b/Runtime/TriInspector.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 324caed91501a9c47a04ebfd87b68794 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/TriMonoBehaviour.cs b/Runtime/TriMonoBehaviour.cs new file mode 100644 index 0000000..e1043ac --- /dev/null +++ b/Runtime/TriMonoBehaviour.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace TriInspector +{ + public abstract class TriMonoBehaviour : MonoBehaviour + { + + } +} \ No newline at end of file diff --git a/Runtime/TriMonoBehaviour.cs.meta b/Runtime/TriMonoBehaviour.cs.meta new file mode 100644 index 0000000..4b95504 --- /dev/null +++ b/Runtime/TriMonoBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9001245cba574d9b895aa9553cefafe5 +timeCreated: 1638856560 \ No newline at end of file diff --git a/Runtime/TriScriptableObject.cs b/Runtime/TriScriptableObject.cs new file mode 100644 index 0000000..d200b1b --- /dev/null +++ b/Runtime/TriScriptableObject.cs @@ -0,0 +1,8 @@ +using UnityEngine; + +namespace TriInspector +{ + public abstract class TriScriptableObject : ScriptableObject + { + } +} \ No newline at end of file diff --git a/Runtime/TriScriptableObject.cs.meta b/Runtime/TriScriptableObject.cs.meta new file mode 100644 index 0000000..ba8c501 --- /dev/null +++ b/Runtime/TriScriptableObject.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8258c9ad5f2848af90fba2da3e53a99f +timeCreated: 1638856255 \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..bd8d9e8 --- /dev/null +++ b/package.json @@ -0,0 +1,10 @@ +{ + "name": "com.triinspector", + "displayName": "Tri Inspector", + "description": "Better inspector and validator for Unity", + "version": "0.0.1", + "unity": "2020.3", + "author": "Vlad Vanifatov (https://github.com/vanifatovvlad)", + "homepage": "https://github.com/codewriter-packages/TriInspector#readme", + "dependencies": {} +} \ No newline at end of file diff --git a/package.json.meta b/package.json.meta new file mode 100644 index 0000000..3ea29d9 --- /dev/null +++ b/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 14114efa999fca2429a33e86c159f70b +PackageManifestImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: