© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
13 replies
Theos

❔ Zenject (Unity) doesn't fire when i do new()

Hey,

I have a class which looks like this

public class Something
{
  private A _a;

  private B _b;

  public Something(A a)
  {
    _a = a;
  }

  [Inject]
  public void Construct(B b)
  {
    _b = b;
  }
public class Something
{
  private A _a;

  private B _b;

  public Something(A a)
  {
    _a = a;
  }

  [Inject]
  public void Construct(B b)
  {
    _b = b;
  }


public class Test : MonoBehaviour
{

  public void Start()
  {
    var smth = new Something(_a);
  }
}
public class Test : MonoBehaviour
{

  public void Start()
  {
    var smth = new Something(_a);
  }
}


and
_b
_b
is null for some reason?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Unity Zenject qustion
C#CC# / help
3y ago
❔ Unity: NewInputSystem: MultiTap
C#CC# / help
4y ago
❔ Unity doesn't want to download.
C#CC# / help
3y ago
❔ Fire and forget, do I need a new logger?
C#CC# / help
3y ago