// Crest Water System // Copyright © 2024 Wave Harmonic. All rights reserved. using UnityEngine; namespace WaveHarmonic.Crest { /// /// Contains extensions to support scripting. /// public static partial class _Extensions { /// /// AddComponent that is compatible with Crest inputs. /// /// The input type. /// The game object to add the input to. /// The input mode. Not all inputs support all modes. Refer to the UI as to what input supports what mode. /// The newly created input component setup with the provided mode. public static T AddComponent(this GameObject gameObject, LodInputMode mode) where T : LodInput { var input = gameObject.AddComponent(); input._Mode = mode; // Not all modes have associated data. if (mode is not LodInputMode.Global or LodInputMode.Primitive or LodInputMode.Unset) AddData(input, mode); input.InferBlend(); return input; } static void AddData(this LodInput input, LodInputMode mode) where T : LodInputData, new() { input.Data = new T(); input.Data._Input = input; } } }