public void Build(CustomBuilderConfiguration config) { BuildPipeline.BuildPlayer( config.scenesInBuild.ToArray(), config.buildPath, config.buildTarget, config.buildOptions ); }
private void CreateNewConfiguration() { string nameBase = "Build"; string name = nameBase; string path = null; int i = 0; while (true) { path = BuildConfigurationsDir + name + ".json"; if (!File.Exists(path)) { break; } name = nameBase + (++i).ToString(); } var config = new CustomBuilderConfiguration(); config.InitializeNew(name); File.WriteAllText(path, config.ToJson().ToString(Newtonsoft.Json.Formatting.Indented), Encoding.UTF8); this._currentConfigurationName = name; this._currentConfiguration = config; this._currentConfigurationDirty = false; }
private void OnEnable() { if (!string.IsNullOrEmpty(this._currentConfigurationSerialized)) { this._currentConfiguration = new CustomBuilderConfiguration(); this._currentConfiguration.FromJson(JObject.Parse(this._currentConfigurationSerialized)); } else { this._currentConfiguration = null; } this._currentConfigurationSerialized = null; }
private void OnGUI() { var configs = this.GetConfigurations(); EditorGUILayout.LabelField("Custom Project Builder v.0.0.3"); GUILayout.Space(10); int oldConfigIndex = this._currentConfigurationName != null ? System.Array.IndexOf(configs, this._currentConfigurationName) : -1; int newConfigIndex = EditorGUILayout.Popup( oldConfigIndex, configs ); if (newConfigIndex != oldConfigIndex) { this._currentConfigurationName = newConfigIndex != -1 ? configs[newConfigIndex] : null; this._currentConfiguration = null; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("New")) { this.CreateNewConfiguration(); } if (GUILayout.Button(this._currentConfiguration != null && this._currentConfigurationDirty ? "Save*" : "Save")) { this.SaveCurrentConfiguration(); } EditorGUILayout.EndHorizontal(); if (this._currentConfiguration == null && this._currentConfigurationName != null) { this._currentConfiguration = this.LoadConfiguration(this._currentConfigurationName); this._currentConfigurationDirty = false; } if (this._currentConfiguration != null) { this._currentConfigurationDirty |= this._currentConfiguration.OnGUI(); } var toRemove = new List<GlobalDefine>(); if( GUILayout.Button( "Add Define" ) ) { var d = new GlobalDefine(); d.define = "NEW_DEFINE"; d.enabled = false; _globalDefines.Add( d ); pos.y += 20; } GUILayout.Space (10); pos = EditorGUILayout.BeginScrollView(pos); foreach( var define in _globalDefines ) { if( DefineEditor( define ) ) toRemove.Add( define ); } foreach( var define in toRemove ) _globalDefines.Remove( define ); GUILayout.Space( 10 ); EditorGUILayout.HelpBox ("Это тестовый пример сборщика проектов!", MessageType.Info); EditorGUILayout.EndScrollView(); GUI.backgroundColor = Color.green; if (this._currentConfiguration != null) { if (GUILayout.Button("Build " + this._currentConfiguration.name)) { SaveDefines(); this.Build(this._currentConfiguration); this.Close(); } } }
private CustomBuilderConfiguration LoadConfiguration(string name) { var config = new CustomBuilderConfiguration(); string path = BuildConfigurationsDir + name + ".json"; if (File.Exists(path)) { config.name = name; config.FromJson(JObject.Parse(File.ReadAllText(path))); } else { config.InitializeNew(name); } return config; }