uimgui

repository·main·Indexed 19 days ago

https://github.com/psydack/uimgui

Dear ImGui integration for Unity using ImGui.NET. Version 7.1.0 provides support for Built-in, URP, HDRP, Unity Input Manager, Unity Input System, FreeType, textures, docking, ImPlot, ImNodes, and ImGuizmo.

Tokens
2.5K
Snippets
6
Records
6
Agent score
18%

What's inside uimgui

  1. Use predefined type names and implicit typing

    main

    Type Declarations

    • Predefined Aliases: Use int, float, string, and bool for local, parameter, and member declarations.
    • .NET Framework Names: Use Int32, Single, String, etc., only when accessing static members (e.g., Int32.Parse).

    Implicit Typing

    • Use var: Use var for local variable declarations to reduce clutter, especially with complex generic types.
    • Exception: Do not use var for primitive types; use the predefined names (e.g., int index = 100;).
    // Correct
    string firstName;
    int lastIndex;
    string commaSeparatedNames = String.Join(", ", names);
    
    // Use var for complex types
    var stream = File.Create(path);
    var customers = new Dictionary<string, string>();
    
    // Exception: Use explicit types for primitives
    int index = 100;
    string timeSheet;
  2. Implement Events, Exceptions, and Booleans correctly

    main

    Events

    • EventArgs: Suffix new classes containing event information with EventArgs (e.g., BarcodeReadEventArgs).
    • Event Handlers: Name delegates used as event types with the EventHandler suffix (e.g., ReadBarcodeEventHandler).
    • Handler Parameters: Use exactly two parameters in event handlers: object sender and [Type]EventArgs e.

    Exceptions

    • Exception Suffix: Suffix new exception classes with Exception (e.g., BarcodeReadException).

    Booleans

    • Prefixes: Use prefixes like Any, Is, or Have for boolean identifiers (e.g., IsNullOrEmpty).
    // Event implementation
    public class BarcodeReadEventArgs : System.EventArgs { }
    public delegate void ReadBarcodeEventHandler(object sender, ReadBarcodeEventArgs e);
    
    // Exception implementation
    public class BarcodeReadException : System.Exception { }
    
    // Boolean naming
    public static bool IsNullOrEmpty(string value) { ... }
  3. Follow Enum and Interface conventions

    main

    Enums

    • Naming: Use singular names for enums (e.g., Color).
    • Exceptions: Use plural names for bit field enums marked with [Flags] (e.g., Dockings).
    • No Suffixes: Do not use Enum, Flag, or Flags as suffixes in the type name.
    • No Explicit Values: Do not explicitly specify the type or values of enums unless they are bit fields.

    Interfaces

    • Prefix: Always prefix interface names with the letter I (e.g., IShape).
    • Naming: Interface names should be nouns or adjectives.
    // Correct Enum
    public enum Color
    {
      Red,
      Green
    }
    
    // Correct Bit Field Enum
    [Flags]
    public enum Dockings
    {
      None = 0,
      Top = 1,
      Right = 2
    }
    
    // Correct Interface
    public interface IShape
    {
    }
  4. Use proper casing and avoid type identification

    main

    Casing Rules

    • PascalCase: Use for class names, method names, constructors, constants, public fields, properties, delegates, and enum types.
    • camelCase: Use for method arguments and local variables.
    • _camelCase: Use for private fields (prefix with an underscore).

    Identifier Best Practices

    • No Hungarian Notation: Do not include type information in identifiers (e.g., avoid strName or iCounter).
    • No Screaming Caps: Do not use all-caps for constants or readonly variables.
    • Meaningful Names: Use descriptive names (e.g., seattleCustomers instead of c).
    • Avoid Abbreviations: Use full words unless the abbreviation is standard (e.g., Id, Xml, Ftp, Uri). For abbreviations of 3+ characters, use PascalCase or camelCase (e.g., HtmlHelper, uiControl).
    • No Underscores: Do not use underscores in identifiers except for the private field prefix.
    // Correct
    int counter;
    string name;
    
    // Avoid
    int iCounter;
    string strName;
    
    // Correct Constants
    public const string ShippingType = "DropShip";
    
    // Correct Private Fields
    private DateTime _registrationDate;
  5. Use Named Arguments in method calls

    main

    When calling methods, use Named Arguments to improve readability and allow passing arguments in any order. This is done by providing the parameter name followed by a colon and the value.

    // Method definition
    public void DoSomething(string foo, int bar) { ... }
    
    // Avoid positional arguments
    DoSomething("someString", 1);
    
    // Correct: Use Named Arguments
    DoSomething(foo: "someString", bar: 1);
  6. C# Naming Conventions Reference

    main

    Follow these naming conventions for different C# identifiers to maintain consistency with the project's coding standards.

    Object NameNotationPrefixSuffixChar Mask
    Namespace namePascalCaseYesNo[A-z][0-9]
    Class namePascalCaseNoYes[A-z][0-9]
    Constructor namePascalCaseNoYes[A-z][0-9]
    Method namePascalCaseNoNo[A-z][0-9]
    Method argumentscamelCaseNoNo[A-z][0-9]
    Local variablescamelCaseNoNo[A-z][0-9]
    Constants namePascalCaseNoNo[A-z][0-9]
    Field name PublicPascalCaseNoNo[A-z][0-9]
    Field name Private_camelCaseNoNo_[A-z][0-9]
    Properties namePascalCaseNoNo[A-z][0-9]
    Delegate namePascalCaseNoYes[A-z]
    Enum type namePascalCaseNoNo[A-z]
    | Object Name               | Notation   | Length | Plural | Prefix | Suffix | Abbreviation | Char Mask          | Underscores |
    |:--------------------------|:-----------|-------:|:-------|:-------|:-------|:-------------|:-------------------|:------------|
    | Namespace name            | PascalCase |    128 | Yes    | Yes    | No     | No           | [A-z][0-9]         | No          |
    | Class name                | PascalCase |    128 | No     | No     | Yes    | No           | [A-z][0-9]         | No          |
    | Constructor name          | PascalCase |    128 | No     | No     | Yes    | No           | [A-z][0-9]         | No          |
    | Method name               | PascalCase |    128 | Yes    | No     | No     | No           | [A-z][0-9]         | No          |
    | Method arguments          | camelCase  |    128 | Yes    | No     | No     | Yes          | [A-z][0-9]         | No          |
    | Local variables           | camelCase  |     50 | Yes    | No     | No     | Yes          | [A-z][0-9]         | No          |
    | Constants name            | PascalCase |     50 | No     | No     | No     | No           | [A-z][0-9]         | No          |
    | Field name Public         | PascalCase |     50 | Yes    | No     | No     | Yes          | [A-z][0-9]         | No          |
    | Field name Private        | _camelCase |     50 | Yes    | No     | No     | Yes          | _[A-z][0-9]        | Yes         |
    | Properties name           | PascalCase |     50 | Yes    | No     | No     | Yes          | [A-z][0-9]         | No          |
    | Delegate name             | PascalCase |    128 | No     | No     | Yes    | Yes          | [A-z]              | No          |
    | Enum type name            | PascalCase |    128 | Yes    | No     | No     | No           | [A-z]              | No          |