Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force add schema from template to rule target group #65

Conversation

JVinceW
Copy link
Contributor

@JVinceW JVinceW commented Jan 15, 2022

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 JVinceW changed the title [WIP] Add force add schema from template group to the target group Force add schema from template to rule target group Jan 15, 2022
@JVinceW
Copy link
Contributor Author

JVinceW commented Jan 15, 2022

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

@favoyang
Copy link
Owner

favoyang commented Feb 5, 2022

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.

@JVinceW
Copy link
Contributor Author

JVinceW commented Dec 21, 2022

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
Copy link
Contributor Author

JVinceW commented Dec 21, 2022

@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.

@favoyang
Copy link
Owner

I will review it later this week. Thx.

Copy link
Owner

@favoyang favoyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@favoyang favoyang merged commit d553499 into favoyang:master Dec 25, 2022
github-actions bot pushed a commit that referenced this pull request Dec 25, 2022
# [0.15.0](v0.14.1...v0.15.0) (2022-12-25)

### Features

* force add schema from template to rule target group ([#65](#65)) ([d553499](d553499))
@github-actions
Copy link

🎉 This PR is included in version 0.15.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

favoyang added a commit that referenced this pull request Dec 25, 2022
favoyang added a commit that referenced this pull request Dec 25, 2022
@JVinceW JVinceW deleted the developer/vince/implement_create_asset_from_template_group branch December 26, 2022 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants