protected virtual void DrawBuild(ProjectBuilder builder) { using (new EditorGUILayout.HorizontalScope()) { EditorGUI.BeginDisabledGroup(!builder.BuildApplication); // Build. if (GUILayout.Button( new GUIContent("Build", EditorGUIUtility.FindTexture("preAudioPlayOff")), "LargeButton")) { EditorApplication.delayCall += () => ProjectBuilderUtil.StartBuild(builder, false, false); } // Open output. var r = EditorGUILayout.GetControlRect(false, GUILayout.Width(15)); if (GUI.Button(new Rect(r.x - 2, r.y + 5, 20, 20), contentOpen, EditorStyles.label)) { string outputFullPath = BuildPathUtils.GetOutputPath(builder); ProjectBuilderUtil.RevealOutputInFinder(outputFullPath); } EditorGUI.EndDisabledGroup(); } }
protected virtual void DrawBuildAssetBundles(ProjectBuilder builder) { using (new EditorGUILayout.HorizontalScope()) { EditorGUI.BeginDisabledGroup(!builder.BuildAssetBundle); // Build. if (GUILayout.Button( new GUIContent("Build AssetBundles", EditorGUIUtility.FindTexture("buildsettings.editor.small")), "LargeButton")) { EditorApplication.delayCall += () => ProjectBuilderUtil.StartBuild(builder, false, true); } // Open output. var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(15)); if (GUI.Button(new Rect(rect.x - 2, rect.y + 5, 20, 20), contentOpen, EditorStyles.label)) { Directory.CreateDirectory(builder.BundleOutputPath); ProjectBuilderUtil.RevealOutputInFinder(builder.BundleOutputPath); } EditorGUI.EndDisabledGroup(); } }
protected virtual void OnGUI() { Initialize(); if (_targets == null || _targets.Length == 0) { if (GUILayout.Button("Create New ProjectBuilder Asset")) { Selection.activeObject = ProjectBuilderUtil.CreateBuilderAsset(); } return; } using (var svs = new EditorGUILayout.ScrollViewScope(_scrollPosition)) { _scrollPosition = svs.scrollPosition; _serializedObject = _serializedObject ?? new SerializedObject(_targets); _serializedObject.Update(); GUILayout.Label(contentTitle, styleTitle); DrawControlPanel(); DrawApplicationBuildSettings(); DrawAssetBundleBuildSettings(); DrawBuildTragetSettings(); _serializedObject.ApplyModifiedProperties(); } }
protected virtual void SelectBuilder(ProjectBuilder[] builders) { // Get all scenes in build from BuildSettings. s_AvailableScenes = EditorBuildSettings.scenes.Select(x => Path.GetFileName(x.path)).ToArray(); // Get all builder assets in project. s_BuildersInProject = new List <ProjectBuilder>( ProjectBuilderUtil.GetAssets <ProjectBuilder>() .OrderBy(b => b.BuildApplication) .ThenBy(b => b.ActualBuildTarget) ); _targets = 0 < builders.Length ? builders : s_BuildersInProject.Take(1).ToArray(); _serializedObject = null; contentTitle.text = 0 < _targets.Length ? _targets.Select(x => " " + x.name).Aggregate((a, b) => a + "\n" + b) : ""; // 最後に選択したビルダーアセットを記憶. var lastSelected = _targets.FirstOrDefault(x => x.ActualBuildTarget == EditorUserBuildSettings.activeBuildTarget); if (lastSelected) { PlayerPrefs.SetString(kPrefsKeyLastSelected + EditorUserBuildSettings.activeBuildTarget, AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(lastSelected))); PlayerPrefs.Save(); } }
protected virtual void OnAddBuilderItem(ReorderableList list) { EditorApplication.delayCall += () => { ProjectBuilderUtil.CreateBuilderAsset(); OnSelectionChanged(); }; }
protected virtual void DrawSwitchBuildTarget(ProjectBuilder builder) { if (GUILayout.Button(new GUIContent("Switch Platform", EditorGUIUtility.FindTexture("d_preAudioLoopOff")), "LargeButton")) { EditorApplication.delayCall += () => ProjectBuilderUtil.SwitchActiveBuildTarget(builder); } }
protected virtual void DrawBuildAndPlay(ProjectBuilder builder) { if (GUILayout.Button(new GUIContent("Build & Run", EditorGUIUtility.FindTexture("preAudioPlayOn")), "LargeButton")) { EditorApplication.delayCall += () => ProjectBuilderUtil.StartBuild(builder, true, false); } }
//---- ▲ GUIキャッシュ ▲ ---- //------------------------------- // Unityコールバック. //------------------------------- /// <summary> /// Raises the enable event. /// </summary> protected virtual void OnEnable() { _targets = null; // 最後に選択したビルダーが存在する. string path = AssetDatabase.GUIDToAssetPath( PlayerPrefs.GetString(kPrefsKeyLastSelected + EditorUserBuildSettings.activeBuildTarget)); if (!string.IsNullOrEmpty(path)) { var builder = AssetDatabase.LoadAssetAtPath <ProjectBuilder>(path); if (builder) { SelectBuilder(new[] { builder }); } } if (_targets == null) { // 選択しているオブジェクト内にビルダーが存在する if (Selection.objects.OfType <ProjectBuilder>().Any()) { SelectBuilder(Selection.objects.OfType <ProjectBuilder>().ToArray()); } else { // プロジェクト内にビルダーが存在する var builders = ProjectBuilderUtil.GetAssets <ProjectBuilder>(); if (builders.Any()) { SelectBuilder(builders.Take(1).ToArray()); } } } Selection.selectionChanged += OnSelectionChanged; minSize = new Vector2(300, 300); }
protected virtual void Initialize() { if (styleCommand != null) { return; } styleTitle = new GUIStyle("IN BigTitle"); styleTitle.alignment = TextAnchor.UpperLeft; styleTitle.fontSize = 12; styleTitle.stretchWidth = true; styleTitle.margin = new RectOffset(); styleSymbols = new GUIStyle(EditorStyles.textArea); styleSymbols.wordWrap = true; styleCommand = new GUIStyle(EditorStyles.textArea); styleCommand.stretchWidth = false; styleCommand.fontSize = 9; contentOpen = new GUIContent(EditorGUIUtility.FindTexture("project")); // Find end property in ProjectBuilder. var dummy = ScriptableObject.CreateInstance <ProjectBuilder>(); var sp = new SerializedObject(dummy).GetIterator(); sp.Next(true); while (sp.Next(false)) { s_EndBasePropertyName = sp.name; } // Scene list. roSceneList = new ReorderableList(new List <ProjectBuilder.SceneSetting>(), typeof(ProjectBuilder.SceneSetting)); roSceneList.drawElementCallback += DrawScenesList; roSceneList.headerHeight = 0; roSceneList.elementHeight = 18; // Exclude Directories List roExcludeDirectoriesList = new ReorderableList(new List <string>(), typeof(string)); roExcludeDirectoriesList.drawElementCallback += DrawExcludeDirectoriesList; roExcludeDirectoriesList.headerHeight = 0; roExcludeDirectoriesList.elementHeight = 18; // Builder list. roBuilderList = new ReorderableList(s_BuildersInProject, typeof(ProjectBuilder)); roBuilderList.onSelectCallback = (list) => Selection.activeObject = list.list[list.index] as ProjectBuilder; roBuilderList.onAddCallback += OnAddBuilderItem; roBuilderList.onRemoveCallback += OnRemoveBuilderItem; roBuilderList.drawElementCallback += DrawBuildersList; roBuilderList.headerHeight = 0; roBuilderList.draggable = false; contentTitle = new GUIContent(ProjectBuilderUtil.GetAssets <Texture2D>(typeof(ProjectBuilder).Name + " Icon").FirstOrDefault()); DestroyImmediate(dummy); }