Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

How to desing my game code?

Discussion in 'Scripting' started by platinio2007, Oct 12, 2016.

  1. platinio2007

    platinio2007

    Joined:
    Jul 17, 2015
    Posts:
    17
    Hi guys is my first time writing here, you see i have a problem about desing maybe some more expert on Unity here can help me, you see normally on my game i use singletons for store information about the level like the Time for complete the level bonus etc etc etc, and some values from anothers objects like example the fade speed of UI componets and bonus score for X action and my script get bigger and bigger and in the GM (my singleton) i controll all the game logic and gets really bigger and in the inspector window see so big and bad, in the other hand i can use public varibles on the other script like the ui for the fadeSpeed but then i need to hand made put all the fade speed of every single ui component even when the value is the same and this feel like a bad way to do it,i take a look to some design patterns but really dont look to useful in unity, then my question is guys how do you organize you unity code? how i can get better this? do you any project what i can take a look and get some ideas? do you use a design pattern?

    really thanks for your time, and sorry about my english.

    James Roman
     
    Last edited: Oct 12, 2016
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,559
    Some suggestions.
    • Use scriptable objects for global configuration
    • Use serialisable classes to create foldouts in complex inspector windows
    • Don't be afraid to break a complex script into multiple smaller ones