- Home /
How to automatically edit and build a project by script?
Hello guys, I have a somewhat complex task to do, and I'd like some advice.
I want to do (well, MY CUSTOMER wants me to do) a web-based Content Management System that will allow to interface the user with a (running or not) instance of Unity Editor and then edit and build a project composing a limited set of predefined objects, scenes and actions.
Mind that I'm not talking about something like the Team License: there will be only a single person working on the project, it's just that he will not be on the same machine of the Unity Editor (and the Unity Player will be on a third machine, ideally), and this person will not be trained in the use of Unity, nor allowed to do some actions (e.g. he will be able to import new textures but not to create materials or shaders; he will clone scenes but not create new ones or change the objects in them, except for some specific properties). There will be a predefined set of scenes (basically, each scene will be a room, and each door will allow the player to pass from one scene to another), and each scene will contain some predefined objects.
So basically, this CMS will need to do something like:
Duplicate scenes;
change components properties on some GameObjects already present in the scene (e.g., change texture of a material, or change the value of some script's public parameters);
Add the various scenes to the building list;
Save scenes, save project, build project, etc.
I'm not asking how to build a web service able to receive these informations, that's another problem ;) I wonder if I can have an external program (in any language) able to accomplish these operations without having to manually open the Unity Editor.
I have seen that I can build a project via external script, and also create and save a new scene, so point 4 won't be a problem..... still, how can I edit the list of scenes that will be included in the build?
I know that I can add elements at runtime and edit the Unity Editor, but is there a way to add objects to a (new or already existing) scene, and save, all at startup, before launching the build? Also, can I edit scenes that are not currently opened? And when I create/open a new scene, with some predefined objects in it, can I pass some parameters, somehow?
Having the ability to edit prefab files and other objects in the scene would be great, but I don't think it's possible (I tried opening .prefab and .unity files and they are binaries, if I'm right); do you think there could be a way to compose a set to script able to receive some input parameters at UnityEditor startup and then automate the creation and building of an entire project (either from scratch or not)?
You can send events (keys) to Unity - It'll help you with some of your points. If you can access the Unity machine, you could maybe write whatever you want to do in a $$anonymous$$enuItem
that is executed by a certain key combo, say Alt+Shift+E - so then you just send that combo to Unity and it will execute that $$anonymous$$enuItem you set with whatever code have you...
Your answer
![](https://koobas.hobune.stream/wayback/20220613141039im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity Editor Scripting - Saving data in scriptable object problem 0 Answers
Getting the current BuildOptions 1 Answer
Set dynamicBatching player setting via editor script? 0 Answers
Add/Remove scene to build settings from editor script and run levels in editor 0 Answers
Bind to OnWillSaveAssets and force to save my scene 0 Answers