public override void OnInspectorGUI() { //Basic Info EditorGUILayout.BeginVertical(EditorStyles.helpBox); var idProperty = serializedObject.FindProperty("id"); EditorGUILayout.PropertyField(idProperty); idProperty.stringValue = idProperty.stringValue.Trim(); var titleProperty = serializedObject.FindProperty("title"); EditorGUILayout.PropertyField(titleProperty); titleProperty.stringValue = titleProperty.stringValue.Trim(); var authorProperty = serializedObject.FindProperty("author"); EditorGUILayout.PropertyField(authorProperty, new GUIContent("Author", "Only shown in local mods, mods from Steam will show Steam user as author")); authorProperty.stringValue = authorProperty.stringValue.Trim(); EditorGUILayout.PropertyField(serializedObject.FindProperty("description")); EditorGUILayout.PropertyField(serializedObject.FindProperty("version")); EditorGUILayout.PropertyField(serializedObject.FindProperty("outputFolder")); EditorGUILayout.EndVertical(); //Preview Image EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); using (new EditorGUILayout.VerticalScope()) { EditorGUILayout.LabelField("Preview Image:"); EditorGUILayout.PropertyField(serializedObject.FindProperty("previewImage"), new GUIContent()); if (ModConfig.PreviewImage != null) { FileInfo f = new FileInfo(AssetDatabase.GetAssetPath(ModConfig.PreviewImage)); if (f.Exists) { EditorGUILayout.LabelField(string.Format("File Size: {0}", WorkshopEditorWindow.FormatFileSize(f.Length))); if (f.Length > 1024 * 1024) { EditorGUILayout.HelpBox("Max allowed size is 1MB", MessageType.Error); } } } } GUILayout.Label(ModConfig.PreviewImage, GUILayout.MaxWidth(128), GUILayout.MaxHeight(128)); EditorGUILayout.EndHorizontal(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.Update(); WorkshopItem item = (WorkshopItem)target; //Basic Info EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.PropertyField(serializedObject.FindProperty("WorkshopPublishedFileID"), new GUIContent("Workshop File ID")); EditorGUILayout.PropertyField(serializedObject.FindProperty("Title")); EditorGUILayout.PropertyField(serializedObject.FindProperty("Description")); EditorGUILayout.EndVertical(); //Preview Image EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); using (new EditorGUILayout.VerticalScope()) { EditorGUILayout.LabelField("Preview Image:"); EditorGUILayout.PropertyField(serializedObject.FindProperty("PreviewImage"), new GUIContent()); if (item.PreviewImage != null) { FileInfo f = new FileInfo(AssetDatabase.GetAssetPath(item.PreviewImage)); if (f.Exists) { EditorGUILayout.LabelField(string.Format("File Size: {0}", WorkshopEditorWindow.FormatFileSize(f.Length))); if (f.Length > 1024 * 1024) { EditorGUILayout.HelpBox("Max allowed size is 1MB", MessageType.Error); } } } } GUILayout.Label(item.PreviewImage, GUILayout.MaxWidth(128), GUILayout.MaxHeight(128)); EditorGUILayout.EndHorizontal(); //Tags if (item.Tags == null) { item.Tags = new List <string>(); } EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.MaxWidth(128)); EditorGUILayout.LabelField("Tags:"); for (int i = 0; i < tags.Length; i++) { bool hasTag = item.Tags.Contains(tags[i]); bool toggled = EditorGUILayout.Toggle(tags[i], hasTag); if (hasTag && !toggled) { item.Tags.Remove(tags[i]); } else if (!hasTag && toggled) { item.Tags.Add(tags[i]); } } EditorGUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); }
protected static void ShowWindow() { WorkshopEditorWindow window = EditorWindow.GetWindow <WorkshopEditorWindow>("Workshop"); window.Show(); }
public override void OnInspectorGUI() { EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUIContent idLabel = new GUIContent("Mod ID", "Identifier for the mod. Affects assembly name and output name."); GUI.changed = false; ModConfig.ID = EditorGUILayout.TextField(idLabel, ModConfig.ID); SetDirtyOnGUIChange(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUIContent titleLabel = new GUIContent("Mod Title", "Name of the mod as it appears in game."); GUI.changed = false; ModConfig.Title = EditorGUILayout.TextField(titleLabel, ModConfig.Title); SetDirtyOnGUIChange(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(serializedObject.FindProperty("description")); SetDirtyOnGUIChange(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUIContent versionLabel = new GUIContent("Mod Version", "Current version of the mod."); GUI.changed = false; ModConfig.Version = EditorGUILayout.TextField(versionLabel, ModConfig.Version); SetDirtyOnGUIChange(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUIContent outputFolderLabel = new GUIContent("Mod Output Folder", "Folder relative to the project where the built mod bundle will be placed."); GUI.changed = false; ModConfig.OutputFolder = EditorGUILayout.TextField(outputFolderLabel, ModConfig.OutputFolder); SetDirtyOnGUIChange(); EditorGUILayout.EndHorizontal(); EditorGUILayout.HelpBox("This folder will be cleaned with each build.", MessageType.Warning); //Preview Image EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); using (new EditorGUILayout.VerticalScope()) { EditorGUILayout.LabelField("Preview Image:"); EditorGUILayout.PropertyField(serializedObject.FindProperty("previewImage"), new GUIContent()); if (ModConfig.PreviewImage != null) { FileInfo f = new FileInfo(AssetDatabase.GetAssetPath(ModConfig.PreviewImage)); if (f.Exists) { EditorGUILayout.LabelField(string.Format("File Size: {0}", WorkshopEditorWindow.FormatFileSize(f.Length))); if (f.Length > 1024 * 1024) { EditorGUILayout.HelpBox("Max allowed size is 1MB", MessageType.Error); } } } } GUILayout.Label(ModConfig.PreviewImage, GUILayout.MaxWidth(128), GUILayout.MaxHeight(128)); EditorGUILayout.EndHorizontal(); serializedObject.ApplyModifiedProperties(); GUI.enabled = true; }