Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Architecture for replacing multiple of duplicate Settings conditionals over code base

Discussion in 'Editor & General Support' started by joesobo, May 27, 2020.

  1. joesobo

    joesobo

    Joined:
    Sep 6, 2018
    Posts:
    17
    Hope the title makes sense. Basic premise is that I have a general settings class that controls the rest of my code at run time. For example if useParticles is false then no particles will spawn. The problem I'm having is that every time I want to create a new particle I have to find the settings object and check to see if its useParticles is active and only then spawn the actual particle. I know there definetly better ways to do this (I have if statements everywhere now!). Is there any form of programming architecture I should be using so that the settings class can send signals to each individual particle, instead of the other way around where whatever spawns the particle sends a signal to the settings class.