Skip to content

Version 5.0

Compare
Choose a tag to compare
@svermeulen svermeulen released this 13 Feb 18:15
· 755 commits to master since this release

Summary

Notable parts of this release includes the long awaited support for Memory Pools, a re-design of Commands/Signals, and support for late resolve via Lazy<> construct. It also includes some API breaking changes to make it easier for new users. Some of the bind methods were renamed to better represent what they mean, and in some cases the scope is now required to be made explicit, to avoid accidentally using transient scope. Finally, there was also some significant performance improvements for when using Zenject in scenes with many transforms.

New Features

  • Added Lazy<> construct so that you can have the resolve occur upon first usage
  • Added menu option "Validate All Active Scenes"
  • Added support for memory pools. This includes a fluent interface similar to how factories work
  • Added DiContainer.QueueForInject method to support adding pre-made instances to the initial inject list
  • Added new construction methods
    • FromMethodMultiple
    • FromComponentInHierarchy
    • FromComponentSibling
    • FromComponentInParents
    • FromComponentInChildren
    • FromScriptableObjectResource

Changes

  • Updated sample projects to be easier to understand
  • Improved error messages to include full type names
  • Changed list bindings to default to optional so that you don't have to do this explicitly constantly
  • Changed to require that the scope be explicitly set for some of the bind methods to avoid extremely common errors of accidentally leaving it as transient. Bind methods that are more like "look ups" (eg. FromMethod, FromComponentInParents, etc.) have it as optional, however bind methods that create new instances require that it be set explicitly
  • Renamed BindAllInterfaces to BindInterfacesTo and BindAllInterfacesAndSelf to BindInterfacesAndSelfTo to avoid the extremely common mistake of forgetting the To
  • Removed support for passing arguments to InjectGameObject and InstantiatePrefab methods (issue #125)
  • Removed UnityEventManager since it isn't core to keep things lightweight
  • Renamed the Resolve overload that included an ID to ResolveId to avoid the ambiguity with the non generic version of Resolve
  • Renamed the following construction methods. This was motivated by the fact that with the new construction methods it's unclear which ones are "look ups" versus creating new instances
    • FromComponent => FromNewComponentOn
    • FromSiblingComponent => FromNewComponentSibling
    • FromGameObject => FromNewComponentOnNewGameObject
    • FromPrefab => FromComponentInNewPrefab
    • FromPrefabResource => FromComponentInNewPrefabResource
    • FromSubContainerResolve.ByPrefab => FromSubContainerResolve.ByNewPrefab
  • Signals package received significant changes
    • The order of generic arguments to the Signal<> base class was changed to have parameters first to be consistent with everything else
    • The functionality of commands was merged into signals

Bug fixes

  • (optimization) Fixed major performance issue for scenes that have a lot of transforms Re issue #188.
  • (optimization) Fixed to avoid the extra performance costs of calling SetParent by directly passing the parent to the GameObject.Instantiate method issue #188
  • Fixed extremely rare bug that would cause an infinite loop when using complex subcontainer setups
  • Fixed to work with nunit test case attributes
  • Fixed to instantiate prefabs without always changing them to be active
  • Fixed WithArguments bind method to support passing null values
  • Fixed context menu to work properly when creating installers etc. issue #200
  • Fixed issue with ZenUtilInternal.InjectGameObjectForComponent method to support looking up non-monobehaviours.
  • Fixed NonLazy() bind method to work properly wtihin sub containers