Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by VesuvianPrime · Oct 02, 2019 at 11:28 AM · editor-scriptingbuilding

Editor script that executes before build

Hi all

I want to write an editor script that will execute before the game is built. I've been looking around at the documentation for EditorApplication delegates, but I haven't found anything appropriate. Does anyone know how I can do this?

Thanks, Ves

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
21
Best Answer

Answer by INedelcu · Dec 31, 2016 at 12:58 PM

Edit: IPreprocessBuild is Obselete, it's replaced by IPreprocessBuildWithReport https://docs.unity3d.com/ScriptReference/Build.IPreprocessBuildWithReport.html

 #if UNITY_EDITOR
 using UnityEditor;
 using UnityEditor.Build;
 class MyCustomBuildProcessor : IPreprocessBuild
 {
      public int callbackOrder { get { return 0; } }
      public void OnPreprocessBuild(BuildTarget target, string path) {
      // Do the preprocessing here
      }
 }
 #endif

Just add a script like this one to your project. Works fine in 5.6b.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Alturis2 · Mar 29, 2017 at 01:12 PM 0
Share

I have a similar need and wondering if anyone has any suggestions. Due to the lack of nested prefab support in Unity I have some custom handling of certain GameObjects that are part of the scenes when referring to prefabs. Basically they have the ability to swap out the prefab or update it on the fly without being an actual prefab instance or having lost their prefab connection.

I was wanting to have this on the fly logic run when the scene is being built rather than when the game is running. Actually I need that to happen because some of these are networked game objects and throwing them out at runtime to be replaced with fresh prefabs breaks the networking id system.

Basically was looking for something like OnBeforeBuild() callback on $$anonymous$$onoBehavior?

avatar image OneSketchyGuy · Jun 14, 2019 at 04:08 PM 0
Share

This was exactly what I was looking for, helped me to find it at least. I was looking for PostBuild. But this helped me get there. Thank you!

avatar image kOnINC · Jul 07, 2019 at 03:57 PM 2
Share

Please note for Unity 2018.1 and above, the interface IPreprocessBuildWithReport should now be used ins$$anonymous$$d as IPreprocessBuild has become obsolete.

avatar image
1

Answer by eexxoo · Aug 07, 2017 at 02:51 PM

Is there any way of doing something similar compatible with Unity 5.3.1f?

Been searching around but with no luck.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image scott-roam · Aug 14, 2018 at 02:39 PM 0
Share

Same, too bad...

avatar image samizzo scott-roam · Sep 06, 2018 at 07:02 AM 0
Share

I sell a build config tool on the asset store which lets you define build configs and set up builds. I just pushed some changes to do pre-build steps as well because I needed exactly this feature in 5.4.3. If you're interested, check it out here http://u3d.as/12$$anonymous$$t

avatar image
-2

Answer by Graham-Dunnett · Jul 17, 2013 at 08:39 PM

Do your stuff, then execute the build using:

http://docs.unity3d.com/Documentation/ScriptReference/BuildPipeline.BuildPlayer.html

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image VesuvianPrime · Jul 17, 2013 at 09:58 PM 0
Share

Thanks, I guess that works, it's a shame there isn't a preBuild delegate though

avatar image
0

Answer by plasticYoda · Feb 11, 2017 at 07:40 PM

@INedelcu, that only works on 5.6+ the classes don't exist in an earlier version of Unity.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Up to date Unity building placement code/tutorials? 1 Answer

Does Unity decompress Truecolor RGBA format textures when loading? 0 Answers

Can't Build PC Standalone due to multiple namespace script errors but playable in editor 1 Answer

rotating the object in the correct orientation 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges