using System; using System.Reflection; using UnityEngine; using UnityEngine.Serialization; namespace UnityEditor.AddressableAssets.Settings { /// /// Contains data for AddressableAssetGroups. /// public class AddressableAssetGroupSchema : ScriptableObject { [FormerlySerializedAs("m_group")] [HideInInspector] [SerializeField] AddressableAssetGroup m_Group; /// /// Get the group that the schema belongs to. /// public AddressableAssetGroup Group { get { return m_Group; } internal set { m_Group = value; if(m_Group != null) OnSetGroup(m_Group); } } /// /// Override this method to perform post creation initialization. /// /// The group that the schema is added to. protected virtual void OnSetGroup(AddressableAssetGroup group) { } /// /// Used to display the GUI of the schema. /// public virtual void OnGUI() { var type = GetType(); var so = new SerializedObject(this); var p = so.GetIterator(); p.Next(true); while (p.Next(false)) { var prop = type.GetField(p.name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); if(prop != null) EditorGUILayout.PropertyField(p, true); } so.ApplyModifiedProperties(); } /// /// Used to notify the addressables settings that data has been modified. This must be called by subclasses to ensure proper cache invalidation. /// /// Determines if this method call will post an event to the internal addressables event system protected void SetDirty(bool postEvent) { if (m_Group != null) { if (m_Group.Settings != null && m_Group.Settings.IsPersisted) EditorUtility.SetDirty(this); if (m_Group != null) m_Group.SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaModified, this, postEvent, false); } } } }