Skip to content

About

a simple inspector extension to create flexible expressions.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Unity Inspector Expressions

(title image)

a simple inspector extension to create flexible expressions.

About • Installation • Features • Documentation •

About

This originates from a SoA usage in mind. often you find yourself in the need to adjust a Variable stored in a SoA Asset. E.g. "This Value times 2".

This Package itself is not a SoA, but it provides a set of custom drawers to create expression logic for most common types.

There is also an inteded way to make it work with (hopefully) any SoA architecture out there.

Installation

using Unity Package Manager:

add a package to

https://github.com/soraphis/UnityInspectorExpressions.git

Features

A set of custom drawers to create expression logic for most common types.

Using a Context

Expressions are generic over a TCtx type parameter, which represents the context passed to Evaluate(ctx). You can use any type as a context — a plain struct, a class, or a ScriptableObject.

To use FromContext expressions, the context type must:

  1. Be annotated with [GeneratePropertyBag] (from Unity.Properties).
  2. Expose properties with the [CreateProperty] attribute so they are accessible via PropertyContainer.

Example:

using Unity.Properties;

[GeneratePropertyBag]
public class MyContext
{
    [CreateProperty] public float Speed { get; set; }
    [CreateProperty] public int Health { get; set; }
}

Numeric expressions can read either int or float properties. The Inspector records the selected property's type and reads it through PropertyContainer; the expression itself always evaluates as a float. Use IntExpression<TCtx> when an integer result is required; it rounds the final numeric result to the nearest integer.

TODO

  • Tutorials to:

About

a simple inspector extension to create flexible expressions.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages