Value Type: Difference between revisions

From Resonite Wiki
TODO: finish this, but this information being here is better than a redirect
Tag: Removed redirect
ok that's enough info until prime gets me that coder<t> primitive type config list thingy
Line 1: Line 1:
A '''Value Type''' is a delegation of types within the [[FrooxEngine]] [[Data Model]] and [[ProtoFlux]]. In contrast to [[Reference Types]], fields containing a value type store the value directly, rather than a reference to the value.
A '''Value Type''' is a delegation of types within the [[FrooxEngine]] [[Data Model]] and [[ProtoFlux]]. In contrast to [[Reference Types]], fields containing a value type store the value directly, rather than a reference to the value.


For a list of all value types in game, refer to [[Category:Value Types]]
For a list of all value types in game, refer to [[:Category:Value Types]].


== In FrooxEngine ==
== In FrooxEngine ==
It's simple to tell whether a certain type is a value type or not within FrooxEngine. In the [[Scene Inspector]], fields holding a value type are easily identifiable by the ability to directly edit the value within them, rather than needing to drag in a reference to the type. A [[Component:ValueField|ValueField]] component is able to hold any value type, which can be used as a quick reference to tell what is what.
It's simple to tell whether a certain type is a value type or not within FrooxEngine. In the [[Scene Inspector]], fields holding a value type are easily identifiable by the ability to directly edit the value within them, rather than needing to drag in a reference to the type. A [[Component:ValueField|ValueField]] component is able to hold any FrooxEngine value type, which can be used as a quick reference to tell what is what.


== In ProtoFlux ==
== In ProtoFlux ==
Things get a bit trickier in ProtoFlux, as value types are contrasted with [[Object Types]], which are more generally defined than reference types.
In ProtoFlux, in short, if a type can be classified as an [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/unmanaged-types unmanaged type in C#], it is recognized as a value type. Otherwise, it is an [[Object Type]].
 
To expand on the definition, in ProtoFlux, an ''unmanaged type'', or value type, must either (criteria not useful to Resonite excluded):
 
* Be one of <code>sbyte</code>, <code>byte</code>, <code>short</code>, <code>ushort</code>, <code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>, <code>char</code>, <code>float</code>, <code>double</code>, <code>decimal</code>, or <code>bool</code>.
* Be an [[Enum]] type.
* Be defined as a non-nullable <code>struct</code> internally that only contains other value types.
** This encompasses many different types, such as [[Type:float3|float3]], [[Type:DateTime|DateTime]], and [[Type:TangentPointFloat|TangentPointFloat]].
** This <em>excludes</em> [[Type:Nullable|Nullable]] types from being a ProtoFlux value type, such as <code>int?</code>.
 
This discrepency between the definition of a value type in FrooxEngine and in ProtoFlux can cause some confusion. For example, a [[Type:string|string]] is a value type in FrooxEngine, but an object type in ProtoFlux.

Revision as of 03:41, 21 August 2024

A Value Type is a delegation of types within the FrooxEngine Data Model and ProtoFlux. In contrast to Reference Types, fields containing a value type store the value directly, rather than a reference to the value.

For a list of all value types in game, refer to Category:Value Types.

In FrooxEngine

It's simple to tell whether a certain type is a value type or not within FrooxEngine. In the Scene Inspector, fields holding a value type are easily identifiable by the ability to directly edit the value within them, rather than needing to drag in a reference to the type. A ValueField component is able to hold any FrooxEngine value type, which can be used as a quick reference to tell what is what.

In ProtoFlux

In ProtoFlux, in short, if a type can be classified as an unmanaged type in C#, it is recognized as a value type. Otherwise, it is an Object Type.

To expand on the definition, in ProtoFlux, an unmanaged type, or value type, must either (criteria not useful to Resonite excluded):

  • Be one of sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal, or bool.
  • Be an Enum type.
  • Be defined as a non-nullable struct internally that only contains other value types.

This discrepency between the definition of a value type in FrooxEngine and in ProtoFlux can cause some confusion. For example, a string is a value type in FrooxEngine, but an object type in ProtoFlux.