Esempio n. 1
0
            public void AddComponent <T>(Action <T, XmlLayoutElement> componentConfig, IAttributeCollection <T> attrs = null) where T : Component
            {
                objectBuildActions.Add((prefabObject, binder) =>
                {
                    if (!prefabObject.gameObject.TryGetComponent <T>(out var component))
                    {
                        component = prefabObject.gameObject.AddComponent <T>();
                    }

                    componentConfig?.Invoke(component, prefabObject);

                    if (attrs.IsEmpty())
                    {
                        return;
                    }

                    foreach (var c in attrs.SerializableConstants)
                    {
                        c.Setter(prefabObject, component);
                    }

                    binder.AddAttributes(prefabObject, component,
                                         attrs.Variables, attrs.NonSerializableConstants);
                });
            }
Esempio n. 2
0
            public void AddObjectAttributes(IAttributeCollection <GameObject> attrs = null)
            {
                if (attrs.IsEmpty())
                {
                    return;
                }

                objectBuildActions.Add((prefabObject, binder) =>
                {
                    foreach (var c in attrs.SerializableConstants)
                    {
                        c.Setter(prefabObject, prefabObject.gameObject);
                    }

                    binder.AddAttributes(prefabObject, prefabObject.gameObject,
                                         attrs.Variables, attrs.NonSerializableConstants);
                });
            }