Complex Types in Components

From Resonite Wiki
Revision as of 15:02, 1 May 2024 by 989onan (talk | contribs) (update to new parser)

Some components require you to specify a type when you create them. They can be identified by the <T> at the end of their name -- e.g. ValueField<T>.

Selecting a type from the list

When you attach one of these components, a menu will appear to ask for what type you want. In many cases, a list of commonly-used types will be shown. If you see the type you'd like to use, just select it from the list:

A list of custom generic types.

Manually Specifying a Type

If the type you need is not listed, you can enter the type's name into the field at the top of the window:

You'll usually need simple types, such as:

  • Slot
  • User

The Invalid Type label will change to the final type of the component when you enter a valid type.

Specifying Complex Types

Sometimes, you will need to use a type that takes another type, just like how the component itself needs you to pick a type. These are generic types, which is a type that takes an argument followed by the number of types they want separated by commas (usually just one type with no commas).

For example, IAssetProvider is the type for many Assets you might use. What it is a reference to depends on its type parameter. If it is a reference to a Material, then it will appear in the inspector as AssetRef<Material>, and be typed out as IAssetProvider<Material>.

Common Complex Types

The syntax for doing this is unusual, so here are some commonly used type strings.

Assets

  • Materials - IAssetProvider<Material>
  • Textures - IAssetProvider<ITexture>
  • IAssetProvider<ITexture2D>
  • AudioClip - IAssetProvider<AudioClip>
  • Mesh - IAssetProvider<Mesh>

Public Class Members

Note: Below is currently broken.

Sometimes a C# class may have classes or Enums etc inside it. Referring to these in the text input box is challenging to remember but not impossible. To do this use a +. This can be a little hard to explain without an example so here are a few examples:

  • The style of the outline on Xiexe's Toon Material can be created using: FrooxEngine.XiexeToonMaterial+OutlineStyle
  • An individual AvatarExpression within the ExpressionDriver can be created using FrooxEngine.ExpressionDriver+AvatarExpression

Background

Generic types can be customized to work with many other types. This is how ValueField<T> components are constructed: you specify the type that it will hold, such as bool, float3, or String. The game doesn't need to keep a separate copy of every kind of ValueField lying around!

Type parameters are provided in a pair of square brackets. They are comma separated, in the rare situation where you have more than one generic type.

Type parameters very rarely need to be qualified, meaning that you need to specify where they come from. Since update Beta_2024.4.30.495 This is not the case for almost every type, which is why the prefix is not used before IAssetProvider. You can almost always go without a qualifier like FrooxEngine, System, or Core.Assets to name a few. If it does not work, usually the name is typed wrong, and a qualifier is not needed. A few exceptions are listed below:


This article or section is a Stub. You can help the Resonite Wiki by expanding it.


Further reading

This article or section is a Stub. You can help the Resonite Wiki by expanding it.