Documentation

Learn how to use FlowCanvas

Connecting Assignable Types

As explained earlier, “value ports can only be connected to other value ports of the same or of assignable types”.

What this basically means, is that you are able to connect certain value type ports together even though they are not of the exact same type, if they can be converted or casted to that type. This is handled automatically for you and saves you a lot of time. In practice, if the editor allows you to connect 2 ports together then it means it’s possible and you have nothing more to worry about. When such a conversion is taking place, the connection will display an icon indicating the fact. In the following example, a float has been connected to a boolean. As a result, this conversion will result to false since the value is 0 (and true if the value was 1+).

ConnectionConvertion

For your convenience, here are the supported conversions by FlowCanvas and how they are done.

From To Through
Any Primitive Any Primitive .ConvertTo()
GameObject Any Component .GetComponent
GameObject Transform .transform
Any Component GameObject .gameObject
GameObject Vector3 .transform.position
AnyComponent Vector3 .transform.position
A Child Type Base Type upcasting
A Base Type Child Type downcasting
Anything String .ToString()

Custom Converters

You can also create custom converters from one type to another through code by subscribing to the ‘TypeConverter.customConverter’ event. Following is code on how to utilize this event as well as converting the Unity ‘Light’ type to a ‘float’ type by returning the Light.intensity for the shake of this example. Please note that this is an advanced topic.

Yes No Suggest edit
20 of 20 users found this section helpful
Suggest Edit

© Paradox Notion 2015-2024. All rights reserved.