Complex Types in Components: Difference between revisions

From Resonite Wiki
Zandario (talk | contribs)
m BaseX -> Elements.Core and Translation stuff
 
stop being big, images!
 
(4 intermediate revisions by 3 users not shown)
Line 2: Line 2:
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. <code>ValueField&lt;T&gt;</code>.  
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. <code>ValueField&lt;T&gt;</code>.  


= Selecting a type from the list = <!--T:2-->
= 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:
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:
 
[[File:DynamicValueVariable Custom Generic Arguments.webp|alt=A list of custom generic types.|center|thumb|577x577px]]
<!--T:3-->
[[File:SelectGenericType.jpg]]


= Manually Specifying a Type = <!--T:4-->
= Manually Specifying a Type = <!--T:4-->
Line 12: Line 10:


<!--T:5-->
<!--T:5-->
[[File:TypeType.jpg]]
[[File:TypeType.jpg|577x577px]]


<!--T:6-->
<!--T:6-->
Line 25: Line 23:


<!--T:9-->
<!--T:9-->
[[File:TypeSlot.jpg]]
[[File:TypeSlot.jpg|577x577px]]


= Specifying Complex Types = <!--T:10-->
= Specifying Complex Types = <!--T:10-->


<!--T:11-->
<!--T:11-->
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, and will have a grave (`) at the end of their names, followed by the number of types they want (usually just one).
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).


<!--T:12-->
<!--T:12-->
For example, <code>IAssetProvider`1</code> 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 <code>SyncRef&lt;Material&gt;</code>, and be typed out as <code>IAssetProvider`1[FrooxEngine.Material]</code>.
For example, <code>IAssetProvider</code> 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 <code>AssetRef&lt;Material&gt;</code>, and be typed out as <code>IAssetProvider&lt;Material&gt;</code>.


<!--T:13-->
<!--T:13-->
[[File:TypeMaterial.jpg]]
[[File:TypeMaterial.jpg|577x577px]]


= Common Complex Types = <!--T:14-->
= Common Complex Types = <!--T:14-->
The syntax for doing this is unusual, so here are some commonly used type strings.
The syntax for doing this is unusual, so here are some commonly used type strings.
<!--T:16-->
To get a grave (`), depending on your keyboard, either look for the key containing `~ and press it, or press shift on your keyboard - in that case, the Esc key should become a `


== Assets == <!--T:15-->
== Assets == <!--T:15-->
* Materials - <code>IAssetProvider`1[FrooxEngine.Material]</code>
* Materials - <code>IAssetProvider&lt;Material&gt;</code>
* Textures - <code>IAssetProvider`1[FrooxEngine.ITexture]</code>
* Textures - <code>IAssetProvider&lt;ITexture&gt;</code>
* <code>IAssetProvider`1[FrooxEngine.ITexture2D]</code>
* <code>IAssetProvider&lt;ITexture2D&gt;</code>
* AudioClip - <code>IAssetProvider`1[FrooxEngine.AudioClip]</code>
* AudioClip - <code>IAssetProvider&lt;AudioClip&gt;</code>
* Mesh - <code>IAssetProvider`1[FrooxEngine.Mesh]</code>
* Mesh - <code>IAssetProvider&lt;Mesh&gt;</code>


== Public Class Members == <!--T:26-->
== Public Class Members == <!--T:26-->
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 <code>+</code>. This can be a little hard to explain without an example so here are a few examples:
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 <code>+</code>. 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: <code>FrooxEngine.XiexeToonMaterial+OutlineStyle</code>
* The style of the outline on Xiexe's Toon Material can be created using: <code>FrooxEngine.XiexeToonMaterial+OutlineStyle</code>
Line 65: Line 62:


<!--T:20-->
<!--T:20-->
Type parameters sometimes need to be ''qualified'', meaning that you need to specify where they come from. This is why the above examples have a prefix of ''FrooxEngine''. This is not the case for all types, which is why the prefix is not used before <code>IAssetProvider`1</code>. You can usually try without ''FrooxEngine.'' and then if it does not work, it can be added.
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 <code>IAssetProvider</code>. 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:
 
<!--T:21-->
Some types need additional qualification. For example, float3 is provided by Elements.Core, but the game will not be able to find it by default. Thus, you will have to write it out like this:
 
<!--T:22-->
<code><nowiki>[[Elements.Core.float3, Elements.Core]]</nowiki></code>


<!--T:23-->
{{Stub}}
Note the additional set of square brackets and the second entry, that being the binary/namespace it comes from.


== Further reading == <!--T:24-->
== Further reading == <!--T:24-->
{{stub}}
{{stub}}

Latest revision as of 17:09, 1 May 2024

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.