Skip to content

unity

Models for Unity data types.

JSON Schema and C# models are not generated for these models since they are built-in Unity types.

Color

Bases: BaseModel

RGBA color.

Range for each component is 0 to 1.

Attributes:

Name Type Description
r float

Red component.

g float

Green component.

b float

Blue component.

a float

Alpha component.

Source code in src/vbl_aquarium/models/unity.py
class Color(BaseModel):
    """RGBA color.

    Range for each component is 0 to 1.

    Attributes:
        r: Red component.
        g: Green component.
        b: Blue component.
        a: Alpha component.
    """

    r: float = Field(default=1, ge=0, le=1)
    g: float = Field(default=1, ge=0, le=1)
    b: float = Field(default=1, ge=0, le=1)
    a: float = Field(default=1, ge=0, le=1)

Vector2

Bases: BaseModel

2D vector.

Attributes:

Name Type Description
x float

X component.

y float

Y component.

Source code in src/vbl_aquarium/models/unity.py
class Vector2(BaseModel):
    """2D vector.

    Attributes:
        x: X component.
        y: Y component.
    """

    x: float = 0.0
    y: float = 0.0

Vector3

Bases: BaseModel

3D vector.

Attributes:

Name Type Description
x float

X component.

y float

Y component.

z float

Z component.

Source code in src/vbl_aquarium/models/unity.py
class Vector3(BaseModel):
    """3D vector.

    Attributes:
        x: X component.
        y: Y component.
        z: Z component.
    """

    x: float = 0.0
    y: float = 0.0
    z: float = 0.0

Vector4

Bases: BaseModel

4D vector.

Attributes:

Name Type Description
x float

X component.

y float

Y component.

z float

Z component.

w float

W component.

Source code in src/vbl_aquarium/models/unity.py
class Vector4(BaseModel):
    """4D vector.

    Attributes:
        x: X component.
        y: Y component.
        z: Z component.
        w: W component.
    """

    x: float = 0.0
    y: float = 0.0
    z: float = 0.0
    w: float = 0.0

    def __add__(self, other: Any) -> Vector4:
        """Add two vectors together.

        Args:
            other: The other vector to add.

        Returns:
            The sum of the two vectors.

        Raises:
            TypeError: If the other object is not a Vector4.
        """
        if not isinstance(other, Vector4):
            error = f"Unsupported operand type(s) for +: 'Vector4' and '{type(other)}'"
            raise TypeError(error)
        return Vector4(x=self.x + other.x, y=self.y + other.y, z=self.z + other.z, w=self.w + other.w)

    def __sub__(self, other: Any) -> Vector4:
        """Subtract one vector from another.

        Args:
            other: The other vector to subtract.

        Returns:
            The difference of the two vectors.

        Raises:
            TypeError: If the other object is not a Vector4.
        """
        if not isinstance(other, Vector4):
            error = f"Unsupported operand type(s) for -: 'Vector4' and '{type(other)}'"
            raise TypeError(error)
        return Vector4(x=self.x - other.x, y=self.y - other.y, z=self.z - other.z, w=self.w - other.w)

    def __mul__(self, other: Any) -> Vector4:
        """Multiply a vector by a scalar.

        Args:
            other: The scalar to multiply by.

        Returns:
            The product of the vector and scalar.

        Raises:
            TypeError: If the other object is not an int or float.
        """
        if not isinstance(other, (int, float)):
            error = f"Unsupported operand type(s) for *: 'Vector4' and '{type(other)}'"
            raise TypeError(error)
        return Vector4(x=self.x * other, y=self.y * other, z=self.z * other, w=self.w * other)

    def __truediv__(self, other: Any) -> Vector4:
        """Divide a vector by a scalar.

        Args:
            other: The scalar to divide by.

        Returns:
            The quotient of the vector and scalar.

        Raises:
            TypeError: If the other object is not an int or float.
        """
        if not isinstance(other, (int, float)):
            error = f"Unsupported operand type(s) for /: 'Vector4' and '{type(other)}'"
            raise TypeError(error)
        return Vector4(x=self.x / other, y=self.y / other, z=self.z / other, w=self.w / other)

__add__(other)

Add two vectors together.

Parameters:

Name Type Description Default
other Any

The other vector to add.

required

Returns:

Type Description
Vector4

The sum of the two vectors.

Raises:

Type Description
TypeError

If the other object is not a Vector4.

Source code in src/vbl_aquarium/models/unity.py
def __add__(self, other: Any) -> Vector4:
    """Add two vectors together.

    Args:
        other: The other vector to add.

    Returns:
        The sum of the two vectors.

    Raises:
        TypeError: If the other object is not a Vector4.
    """
    if not isinstance(other, Vector4):
        error = f"Unsupported operand type(s) for +: 'Vector4' and '{type(other)}'"
        raise TypeError(error)
    return Vector4(x=self.x + other.x, y=self.y + other.y, z=self.z + other.z, w=self.w + other.w)

__mul__(other)

Multiply a vector by a scalar.

Parameters:

Name Type Description Default
other Any

The scalar to multiply by.

required

Returns:

Type Description
Vector4

The product of the vector and scalar.

Raises:

Type Description
TypeError

If the other object is not an int or float.

Source code in src/vbl_aquarium/models/unity.py
def __mul__(self, other: Any) -> Vector4:
    """Multiply a vector by a scalar.

    Args:
        other: The scalar to multiply by.

    Returns:
        The product of the vector and scalar.

    Raises:
        TypeError: If the other object is not an int or float.
    """
    if not isinstance(other, (int, float)):
        error = f"Unsupported operand type(s) for *: 'Vector4' and '{type(other)}'"
        raise TypeError(error)
    return Vector4(x=self.x * other, y=self.y * other, z=self.z * other, w=self.w * other)

__sub__(other)

Subtract one vector from another.

Parameters:

Name Type Description Default
other Any

The other vector to subtract.

required

Returns:

Type Description
Vector4

The difference of the two vectors.

Raises:

Type Description
TypeError

If the other object is not a Vector4.

Source code in src/vbl_aquarium/models/unity.py
def __sub__(self, other: Any) -> Vector4:
    """Subtract one vector from another.

    Args:
        other: The other vector to subtract.

    Returns:
        The difference of the two vectors.

    Raises:
        TypeError: If the other object is not a Vector4.
    """
    if not isinstance(other, Vector4):
        error = f"Unsupported operand type(s) for -: 'Vector4' and '{type(other)}'"
        raise TypeError(error)
    return Vector4(x=self.x - other.x, y=self.y - other.y, z=self.z - other.z, w=self.w - other.w)

__truediv__(other)

Divide a vector by a scalar.

Parameters:

Name Type Description Default
other Any

The scalar to divide by.

required

Returns:

Type Description
Vector4

The quotient of the vector and scalar.

Raises:

Type Description
TypeError

If the other object is not an int or float.

Source code in src/vbl_aquarium/models/unity.py
def __truediv__(self, other: Any) -> Vector4:
    """Divide a vector by a scalar.

    Args:
        other: The scalar to divide by.

    Returns:
        The quotient of the vector and scalar.

    Raises:
        TypeError: If the other object is not an int or float.
    """
    if not isinstance(other, (int, float)):
        error = f"Unsupported operand type(s) for /: 'Vector4' and '{type(other)}'"
        raise TypeError(error)
    return Vector4(x=self.x / other, y=self.y / other, z=self.z / other, w=self.w / other)