using System; using TriLibCore.Interfaces; using TriLibCore.Mappers; using UnityEngine; namespace TriLibCore.Samples { /// /// A custom that forwards user properties /// (attached to model GameObjects) to a user-specified callback. /// public class SampleUserPropertiesMapper : UserPropertiesMapper { /// /// A callback invoked for each user property discovered during model loading. /// /// /// This receives the following parameters: /// /// /// GameObject: The GameObject to which the user property is attached. /// /// /// string: The property’s name. /// /// /// object: The property’s value (may be various types, such as , , , etc.). /// /// /// public Action OnUserDataProcessed; /// /// Overrides the default TriLib user property processing to invoke /// the callback (if not null). /// /// Contains context about the current model loading process. /// The that owns the current user property. /// The name of the user property. /// The value of the user property, potentially in various types. public override void OnProcessUserData( AssetLoaderContext assetLoaderContext, GameObject gameObject, string propertyName, object propertyValue) { if (OnUserDataProcessed != null) { OnUserDataProcessed(gameObject, propertyName, propertyValue); } } } }