As explained earlier, you are able to link BBParameter to non-identical Variable data types and let the AutoConvert feature handle the conversion automatically. You are also able to append custom conversions if you so require. Following is an example of how to do this. In this example we want to append a conversion from UnityEngine.Light to float by returning the Light.intensity property.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public static class CustomConverters { [RuntimeInitializeOnLoadMethod] #if UNITY_EDITOR [UnityEditor.InitializeOnLoadMethod] #endif static void Init() { TypeConverter.customConverter += OnConvert; } static System.Func<object, object> OnConvert(System.Type sourceType, System.Type targetType) { if ( sourceType == typeof(Light) && targetType == typeof(float) ) { return (value) => value is Light ? ( value as Light ).intensity : default(float); } //add more... return null; } } |
© Paradox Notion 2014-2024. All rights reserved.