Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Run a script of process before each level gets built?

Discussion in 'Scripting' started by techmage, Jan 23, 2015.

  1. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    When you click build, before each level does get built, I want to run a script that will do a process to the entire scene before putting it into the build.

    How would I go about doing that?
     
  2. Tanel

    Tanel

    Joined:
    Aug 31, 2011
    Posts:
    508
    I don't think that's possible. The only thing I glanced from the reference that comes close to what you want is a isBuildingPlayer flag, but you'd probably need something like OnBeforeSceneBuild or something.

    But why can't you make a component that does what you want in Awake or something?
     
  3. tobyheadcast

    tobyheadcast

    Joined:
    Aug 5, 2014
    Posts:
    25
    You could create editor scripts that you run before you build that do what you want. I often process levels etc using editor scripts. It's a pretty powerful system when you get into it.

    For instance on my current project I have scripts that load every scene process them save them and output them each as asset bundles.
     
    Mycroft and Tanel like this.
  4. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    That basically what I want to do. For pro this is easy. However I wanted to find a fairly automated solution for unity free.
     
  5. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001