Convert Figma logo to code with AI

Deadcows logoMyBox

MyBox is a set of attributes, tools and extensions for Unity

1,905
241
1,905
22

Top Related Projects

1,957

The solution that allows unity games to update in runtime. 使Unity开发的游戏支持热更新的解决方案。

Attribute Extensions for Unity

A uGUI based console to see debug messages and execute commands during gameplay in Unity

Quick Overview

MyBox is a Unity plugin that provides a collection of tools, attributes, extensions, and scripts to enhance Unity development. It aims to simplify common tasks and improve workflow efficiency for Unity developers.

Pros

  • Extensive collection of utility functions and extensions
  • Easy to integrate into existing Unity projects
  • Regularly updated and maintained
  • Well-documented with examples and explanations

Cons

  • May introduce dependencies in projects
  • Some features might overlap with built-in Unity functionality
  • Learning curve for developers unfamiliar with the library
  • Potential performance impact if overused

Code Examples

  1. Easily get a random item from a list:
List<string> fruits = new List<string> { "Apple", "Banana", "Cherry" };
string randomFruit = fruits.GetRandom();
Debug.Log("Random fruit: " + randomFruit);
  1. Create a singleton MonoBehaviour:
public class GameManager : MonoBehaviourSingleton<GameManager>
{
    public void StartGame()
    {
        Debug.Log("Game started!");
    }
}

// Usage
GameManager.Instance.StartGame();
  1. Easily get components in children, including inactive ones:
public class Example : MonoBehaviour
{
    void Start()
    {
        Renderer[] renderers = gameObject.GetComponentsInChildrenAll<Renderer>();
        Debug.Log("Found " + renderers.Length + " renderers, including inactive ones");
    }
}

Getting Started

  1. Install MyBox in your Unity project:

    • Open the Package Manager (Window > Package Manager)
    • Click the "+" button and choose "Add package from git URL"
    • Enter: https://github.com/Deadcows/MyBox.git
  2. Import MyBox in your scripts:

using MyBox;

public class ExampleScript : MonoBehaviour
{
    [MustBeAssigned]
    public Transform target;

    void Start()
    {
        if (target.position.IsZero())
        {
            Debug.Log("Target is at origin!");
        }
    }
}

Competitor Comparisons

1,957

The solution that allows unity games to update in runtime. 使Unity开发的游戏支持热更新的解决方案。

Pros of JEngine

  • More comprehensive framework for Unity game development
  • Active development with frequent updates and new features
  • Larger community and better documentation

Cons of JEngine

  • Steeper learning curve due to its extensive feature set
  • May be overkill for smaller projects or simpler Unity tasks
  • Potentially higher performance overhead

Code Comparison

MyBox:

[Separator]
public float speed = 5f;
public Vector3 direction = Vector3.forward;

void Update() {
    transform.Translate(direction * speed * Time.deltaTime);
}

JEngine:

public class MoveComponent : JBehaviour
{
    public float speed = 5f;
    public Vector3 direction = Vector3.forward;

    public override void Run() {
        transform.Translate(direction * speed * Time.deltaTime);
    }
}

The code comparison shows that JEngine uses a custom JBehaviour class and Run() method instead of Unity's standard MonoBehaviour and Update(). This demonstrates JEngine's more structured approach to game development, which can lead to better organization but may require additional learning for developers familiar with standard Unity practices.

Attribute Extensions for Unity

Pros of NaughtyAttributes

  • More focused on attribute-based functionality, providing a wider range of custom attributes
  • Offers additional features like conditional hiding and showing of fields in the inspector
  • Actively maintained with more recent updates and contributions

Cons of NaughtyAttributes

  • Limited to attribute-based functionality, lacking the broader utility methods found in MyBox
  • May have a steeper learning curve for users unfamiliar with attribute-based programming
  • Smaller community and fewer total downloads compared to MyBox

Code Comparison

MyBox example:

[MustBeAssigned] public GameObject target;
[PositiveValueOnly] public float speed = 5f;
[MinMaxRange(0, 100)] public Vector2 healthRange;

NaughtyAttributes example:

[Required] public GameObject target;
[MinValue(0)] public float speed = 5f;
[MinMaxSlider(0, 100)] public Vector2 healthRange;
[ShowIf("IsEnabled")] public bool additionalOption;

Both libraries offer similar attribute-based functionality for Unity inspector customization, but NaughtyAttributes provides more specialized attributes and conditional display options. MyBox, on the other hand, includes a broader range of utility methods and extensions beyond just attributes.

A uGUI based console to see debug messages and execute commands during gameplay in Unity

Pros of UnityIngameDebugConsole

  • Focused specifically on in-game debugging and console functionality
  • Provides a ready-to-use debug console with command input and output
  • Supports custom commands and variables for runtime debugging

Cons of UnityIngameDebugConsole

  • Limited to debugging and console features, less versatile than MyBox
  • May require additional setup for integration with existing projects
  • Fewer general-purpose utility functions compared to MyBox

Code Comparison

UnityIngameDebugConsole:

DebugLogConsole.AddCommand("echo", "Echoes the input", (string str) => str);
DebugLogConsole.AddCommand<int, int>("add", "Adds two integers", (int a, int b) => a + b);

MyBox:

[Separator("Debug Section", true)]
[ButtonMethod]
public void DebugMethod() => Debug.Log("Debug button pressed");

UnityIngameDebugConsole focuses on providing a comprehensive in-game debug console with command functionality, while MyBox offers a broader set of utilities and attributes for Unity development. UnityIngameDebugConsole is more suitable for projects requiring extensive runtime debugging capabilities, whereas MyBox provides a wider range of tools for various aspects of Unity development, including debugging, UI, and general programming utilities.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

MyBox

openupm License: MIT

MyBox is a set of tools, features and extensions for Unity.
It is MyBox. Now it's yours too :raised_hands:

Installation

Tons of images in docs below :point_down:

Attributes

AutoProperty — Assign fields automatically
ButtonMethod — Display button in inspector
CharactersRange — Filter string field by the set of characters
ConditionalField — Conditionally display property in inspector, based on some other property value
ConstantsSelection — Popup of const, readonly or static fields and properties
DefinedValues — Display Dropdown with predefined values
DisplayInspector — Display one inspector inside of another
Foldout — Group your fields in inspector
InitializationField — Field that is not editable in playmode
Tag, Layer, SpriteLayer — Dropdown with Tags, Layers or SpriteLayers
MinMaxRange, RangedFloat and RangedInt — Ranged sliders
MaxValue, MinValue and PositiveValueOnly — Validation for numbers and vectors
MustBeAssigned — Automatically checks if field is assigned
OverrideLabel — Change visible in Inspector field name
ReadOnly — Draw property with disabled GUI
RegexString — Filter string field by the Regular Expression
RequireTag and RequireLayer — Automatically set Tag and Layer
Scene — Friendly way to keep Scene name as a string. See also SceneReference type
SearchableEnum — Nice UI for enums with lots of elements
Separator — Draw separator with or without title


Tools and Features

AssetPressetPreprocessor — Conditionally apply Presets to your assets on import
TimeTest — Measure performance with simple api
IPrepare — Easy way to replace caching, calculations and asserts from playmode
Features — Cleanup Empty Directories, AutoSave feature, Hotkeys
UnityEvent Inspector — Allows you to fold and reorder event subscribers


Types

ActivateOnStart Component — Set state of specific GO on game start
AnimationStateReference — Specify AnimationClip on object with Animator
AssetPath and AssetFolderPath — Inspector button to browse for folder or asset under Assets folder
Billboard Component — Force object to always face camera
ColliderGizmo Component — Highlight colliders and triggers in SceneView
ColliderToMesh Component — Generate Mesh from PolygonCollider2D data on the fly
Commentary Component — Add text commentary to your GameObjects
CoroutineGroup — Wraps up bunch of coroutines to know when they all is completed
FPSCounter Component — Display FPS counter on Playmode
Guid Component — Generate unique and persistent IDs
MinMaxInt and MinMaxFloat — Asserts that Max => Min with handy inspector drawer
MyCursor — Nice way to set cursor with hotspot
MyDictionary — Serializable Dictionary
Optional and OptionalMinMax — Optionally assignable values
Reorderable Collections — Reorder your collections in inspector
SceneReference Component — Reference scene with Scene asset in inspector
Singleton — Cache and access instance of MonoBehaviour
TransformData — Type to store and apply position, rotation and scale
UIFollow Component — RectTransform will follow specified Transform
UIImageBasedButton Component — Used to create toggle button behaviour
UIRelativePosition Component — Position one RectTransform relatively to another, regardless of hierarchy
UISizeBy Component — Size one RectTransform relatively to another


//TODO: Extensions, Unfinished tools