unity-addressable-importer icon indicating copy to clipboard operation
unity-addressable-importer copied to clipboard

Force add schema from template to rule target group

Open JVinceW opened this issue 2 years ago • 2 comments

I've created a group template: image

And all I wanna do is my rule target group will be create from this template but the code not work as I expected and always give me this warning, the new created group not have the schema of my group, it only have the BundledAssetGroupSchema. After deep dive into code I think this feature is must have so I create this RP, if you have time, please take a look at this.

I also think of force remove schema if template don't have that, but I'm not sure if it need so I just leave it there image

JVinceW avatar Jan 15 '22 08:01 JVinceW

@favoyang If you have time, please take a look at this. Thanks

JVinceW avatar Jan 15 '22 08:01 JVinceW

I'm a little bit surprised at how ApplyToAddressableAssetGroup is implemented, which only applies schema values for the group to the schema values found in the source template. If a schema (value) of the template doesn't include in the given group, it didn't get applied to it. It probably should rename to ApplyExistingSchemaValuesToAddressableAssetGroup.

        /// <summary>
        /// Applies schema values for the group to the schema values found in the template
        /// </summary>
        /// <param name="group">The AddressableAssetGroup to apply the schema settings to</param>
        public void ApplyToAddressableAssetGroup(AddressableAssetGroup group)
        {
            foreach (AddressableAssetGroupSchema schema in group.Schemas)
            {
                List<Preset> presets = SchemaPresetObjects;
                foreach (Preset p in presets)
                {
                    Assert.IsNotNull(p);
                    if (p.CanBeAppliedTo(schema))
                    {
                        p.ApplyTo(schema);
                        schema.Group = group;
                    }
                }
            }
        }

Then I think forceAddSchemaFromTemplate is not an option. Just remove the boolean and let it run every time before ApplyToAddressableAssetGroup. Thought?

I also think of force remove schema if template don't have that, but I'm not sure if it need so I just leave it there.

This is another feature, let's just leave it there.

favoyang avatar Feb 05 '22 05:02 favoyang

Sorry for the very late reply. (I didn't get notification from this, or maybe I missed the mail). That's sound good. I will update my PR

JVinceW avatar Dec 21 '22 05:12 JVinceW

@favoyang I know this was an very old PR but it still needed feature (I think so I update the code as the advice you gave me) so if you have time please take a look.

Will take an eye on this repo more and see if I can contribute more.

JVinceW avatar Dec 21 '22 05:12 JVinceW

I will review it later this week. Thx.

favoyang avatar Dec 21 '22 14:12 favoyang

:tada: This PR is included in version 0.15.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Dec 25 '22 14:12 github-actions[bot]