Пример #1
0
        static void BindField(FieldInfo fieldInfo, string sourceNamePrefix, string destinationName)
        {
            if (fieldInfo.GetCustomAttribute <NotKeyableAttribute>() != null)
            {
                return;
            }

            var fieldType = fieldInfo.FieldType;

            if (BindingUtils.IsSourceTypeAnimatable(fieldType))
            {
                BindingsStore.CreateBindingNameRemap($"{sourceNamePrefix}.{fieldInfo.Name}", destinationName);
                return;
            }

            var fields = fieldType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            foreach (var field in fields)
            {
                if (field.IsPublic || field.GetCustomAttribute <SerializeField>() != null)
                {
                    BindField(field, $"{sourceNamePrefix}.{fieldInfo.Name}", $"{destinationName}.{field.Name}");
                }
            }
        }
        protected override void OnUpdate()
        {
            // Camera remaps
            // Those 2 *may* conflict, but animating both is asking for trouble.
            BindingsStore.CreateBindingNameRemap("Camera.field of view", $"{typeof(Camera).Name}.{nameof(Camera.fov)}");
            BindingsStore.CreateBindingNameRemap("Camera.orthographic size", $"{typeof(Camera).Name}.{nameof(Camera.fov)}");

            BindingsStore.CreateBindingNameRemap("Camera.near clip plane", $"{typeof(Camera).Name}.{nameof(Camera.clipZNear)}");
            BindingsStore.CreateBindingNameRemap("Camera.far clip plane", $"{typeof(Camera).Name}.{nameof(Camera.clipZFar)}");

            // Light remaps
            BindingsStore.CreateBindingNameRemap("Light.m_Range", $"{typeof(Light).Name}.{nameof(Light.clipZFar)}");
            BindingsStore.CreateBindingNameRemap("Light.m_Intensity", $"{typeof(Light).Name}.{nameof(Light.intensity)}");
            BindingsStore.CreateBindingNameRemap("Light.m_SpotAngle", $"{typeof(SpotLight).Name}.{nameof(SpotLight.fov)}");

            BindingsStore.CreateBindingNameRemap("Light.m_Color.r", $"{typeof(Light).Name}.{nameof(Light.color)}.x");
            BindingsStore.CreateBindingNameRemap("Light.m_Color.g", $"{typeof(Light).Name}.{nameof(Light.color)}.y");
            BindingsStore.CreateBindingNameRemap("Light.m_Color.b", $"{typeof(Light).Name}.{nameof(Light.color)}.z");
            BindingsStore.DiscardBinding("Light.m_Color.a");
        }