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

How to break up scripts

Discussion in 'Scripting' started by Saxi, Sep 22, 2014.

  1. Saxi

    Saxi

    Joined:
    Jun 28, 2013
    Posts:
    381
    If I have a script that uses resources load() to load sprites into an array and assign them to prefabs. When I want to clean up, and unload those resources, where would I do that?

    Should I have another script that unloads the resources and grabs a reference to the variables in the first script that loaded it?

    I know one way is to use a singleton and place the arrays there. I could also use a delegate and have the load script respond to it and clean up.

    I would like to know what is considered best practice.