private void OnGUI() { Initialize(); if (targets == null || targets.Length == 0) { if (GUILayout.Button("Create New ProjectBuilder Asset")) { Selection.activeObject = BuilderUtil.CreateBuilderAsset(); } return; } using (EditorGUILayout.ScrollViewScope svs = new EditorGUILayout.ScrollViewScope(scrollPosition)) { scrollPosition = svs.scrollPosition; serializedObject = serializedObject ?? new SerializedObject(targets); serializedObject.Update(); GUILayout.Label(contentTitle, styleTitle); DrawCustomProjectBuilder(); DrawApplicationBuildSettings(); DrawBuildTargetSettings(); DrawControlPanel(); serializedObject.ApplyModifiedProperties(); } }
private void Initialize() { if (styleCommand != null) { return; } styleTitle = new GUIStyle("IN BigTitle") { alignment = TextAnchor.UpperLeft, fontSize = 12, stretchWidth = true, margin = new RectOffset() }; styleCommand = new GUIStyle(EditorStyles.textArea) { stretchWidth = false, fontSize = 9 }; contentOpen = new GUIContent(EditorGUIUtility.FindTexture("project")); Builder dummy = CreateInstance <Builder>(); SerializedProperty sp = new SerializedObject(dummy).GetIterator(); sp.Next(true); while (sp.Next(false)) { endBasePropertyName = sp.name; } roSceneList = new ReorderableList(new List <Builder.SceneSetting>(), typeof(Builder.SceneSetting)); roSceneList.drawElementCallback += (rect, index, isActive, isFocused) => { SerializedProperty element = roSceneList.serializedProperty.GetArrayElementAtIndex(index); EditorGUI.PropertyField(new Rect(rect.x, rect.y, 16, rect.height - 2), element.FindPropertyRelative("enable"), GUIContent.none); EditorGUIEx.TextFieldWithTemplate(new Rect(rect.x + 16, rect.y, rect.width - 16, rect.height - 2), element.FindPropertyRelative("name"), GUIContent.none, availableScenes, false); }; roSceneList.headerHeight = 0; roSceneList.elementHeight = 18; roExcludeDirectoriesList = new ReorderableList(new List <string>(), typeof(string)); roExcludeDirectoriesList.drawElementCallback += (rect, index, isActive, isFocused) => { SerializedProperty element = roExcludeDirectoriesList.serializedProperty.GetArrayElementAtIndex(index); EditorGUIEx.DirectoryPathField(rect, element, GUIContent.none, "Select exclude directory in build."); }; roExcludeDirectoriesList.headerHeight = 0; roExcludeDirectoriesList.elementHeight = 18; roBuilderList = new ReorderableList(buildersInProject, typeof(Builder)) { onSelectCallback = list => Selection.activeObject = list.list[list.index] as Builder }; roBuilderList.onAddCallback += list => { EditorApplication.delayCall += () => { BuilderUtil.CreateBuilderAsset(); OnSelectionChanged(); }; }; roBuilderList.onRemoveCallback += list => { EditorApplication.delayCall += () => { AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(list.list[list.index] as Builder)); AssetDatabase.Refresh(); OnSelectionChanged(); }; }; roBuilderList.drawElementCallback += (rect, index, isActive, isFocused) => { Builder b = roBuilderList.list[index] as Builder; if (!b) { return; } GUI.DrawTexture(new Rect(rect.x, rect.y + 2, 16, 16), GetBuildTargetIcon(b)); GUI.Label(new Rect(rect.x + 16, rect.y + 2, rect.width - 16, rect.height - 2), new GUIContent($"{b.name} ({b.productName})")); }; roBuilderList.headerHeight = 0; roBuilderList.draggable = false; contentTitle = new GUIContent(Util.GetAssets <Texture2D>(typeof(Builder).Name + " Icon").FirstOrDefault()); DestroyImmediate(dummy); }