public override void OnInspectorGUI() { VmodMonkeMapLoader.Behaviours.MapDescriptor targetDescriptor = (VmodMonkeMapLoader.Behaviours.MapDescriptor)target; DrawDefaultInspector(); GUILayout.Space(10); if (GUILayout.Button("Export Map")) { if (!ExporterUtils.BuildTargetInstalled(BuildTarget.Android) && EditorUtility.DisplayDialog("Android Build Support missing", "You don't have Android Build Support installed for this Unity version. Please install it and do NOT continue unless you know for sure what you're doing.", "Cancel", "Continue Anyways")) { return; } GameObject noteObject = targetDescriptor.gameObject; string path = EditorUtility.SaveFilePanel("Save map file", "", targetDescriptor.MapName + ".gtmap", "gtmap"); if (path != "") { EditorUtility.SetDirty(targetDescriptor); if (noteObject.transform.Find("ThumbnailCamera") != null) { ExporterUtils.ExportPackage(noteObject, path, "Map", ExporterUtils.MapDescriptorToJSON(targetDescriptor)); EditorUtility.DisplayDialog("Exportation Successful!", "Exportation Successful!", "OK"); EditorUtility.RevealInFinder(path); } else { EditorUtility.DisplayDialog("Exportation Failed!", "No thumbnail camera.", "OK"); } } Debug.Log("YOO"); } }
void OnGUI() { var window = EditorWindow.GetWindow(typeof(CompileNoteWindow), false, "Material Exporter", false); int ScrollSpace = (16 + 20) + (16 + 17 + 17 + 20 + 20); foreach (GorillaCosmetics.Data.Descriptors.GorillaMaterialDescriptor note in notes) { if (note != null) { ScrollSpace += (16 + 17 + 17 + 20 + 20); } } float currentWindowWidth = EditorGUIUtility.currentViewWidth; float windowWidthIncludingScrollbar = currentWindowWidth; if (window.position.size.y >= ScrollSpace) { windowWidthIncludingScrollbar += 30; } scrollPosition = GUI.BeginScrollView(new Rect(0, 0, EditorGUIUtility.currentViewWidth, window.position.size.y), scrollPosition, new Rect(0, 0, EditorGUIUtility.currentViewWidth - 20, ScrollSpace), false, false); //GUILayout.ScrollViewScope GUILayout.Label("Notes", EditorStyles.boldLabel, GUILayout.Height(16)); GUILayout.Space(20); foreach (GorillaCosmetics.Data.Descriptors.GorillaMaterialDescriptor note in notes) { if (note != null) { GUILayout.Label("GameObject : " + note.gameObject.name, EditorStyles.boldLabel, GUILayout.Height(16)); note.AuthorName = EditorGUILayout.TextField("Author name", note.AuthorName, GUILayout.Width(windowWidthIncludingScrollbar - 40), GUILayout.Height(17)); note.MaterialName = EditorGUILayout.TextField("Material name", note.MaterialName, GUILayout.Width(windowWidthIncludingScrollbar - 40), GUILayout.Height(17)); if (GUILayout.Button("Export " + note.MaterialName, GUILayout.Width(windowWidthIncludingScrollbar - 40), GUILayout.Height(20))) { GameObject noteObject = note.gameObject; if (noteObject != null && note != null) { string path = EditorUtility.SaveFilePanel("Save material file", "", note.MaterialName + ".gmat", "gmat"); Debug.Log(path == ""); if (path != "") { EditorUtility.SetDirty(note); GameObject tempMaterialObject = GameObject.CreatePrimitive(PrimitiveType.Sphere); tempMaterialObject.GetComponent <MeshRenderer>().sharedMaterial = noteObject.GetComponent <MeshRenderer>().sharedMaterial; // do stuff ExporterUtils.ExportPackage(tempMaterialObject, path, "Material", ExporterUtils.MaterialDescriptorToJSON(note)); EditorUtility.DisplayDialog("Exportation Successful!", "Exportation Successful!", "OK"); EditorUtility.RevealInFinder(path); } else { EditorUtility.DisplayDialog("Exportation Failed!", "Path is invalid.", "OK"); } } else { EditorUtility.DisplayDialog("Exportation Failed!", "Note GameObject is missing.", "OK"); } } GUILayout.Space(20); } } GUI.EndScrollView(); }
void OnGUI() { var window = EditorWindow.GetWindow(typeof(CompileHatWindow), false, "Hat Exporter", false); int ScrollSpace = (16 + 20) + (16 + 17 + 17 + 20 + 20); foreach (GorillaCosmetics.Data.Descriptors.HatDescriptor note in notes) { if (note != null) { ScrollSpace += (16 + 17 + 17 + 20 + 20); } } float currentWindowWidth = EditorGUIUtility.currentViewWidth; float windowWidthIncludingScrollbar = currentWindowWidth; if (window.position.size.y >= ScrollSpace) { windowWidthIncludingScrollbar += 30; } scrollPosition = GUI.BeginScrollView(new Rect(0, 0, EditorGUIUtility.currentViewWidth, window.position.size.y), scrollPosition, new Rect(0, 0, EditorGUIUtility.currentViewWidth - 20, ScrollSpace), false, false); //GUILayout.ScrollViewScope GUILayout.Label("Notes", EditorStyles.boldLabel, GUILayout.Height(16)); GUILayout.Space(20); foreach (GorillaCosmetics.Data.Descriptors.HatDescriptor note in notes) { if (note != null) { GUILayout.Label("GameObject : " + note.gameObject.name, EditorStyles.boldLabel, GUILayout.Height(16)); note.AuthorName = EditorGUILayout.TextField("Author name", note.AuthorName, GUILayout.Width(windowWidthIncludingScrollbar - 40), GUILayout.Height(17)); note.HatName = EditorGUILayout.TextField("Hat name", note.HatName, GUILayout.Width(windowWidthIncludingScrollbar - 40), GUILayout.Height(17)); if (GUILayout.Button("Export " + note.HatName, GUILayout.Width(windowWidthIncludingScrollbar - 40), GUILayout.Height(20))) { GameObject noteObject = note.gameObject; if (noteObject != null && note != null) { string path = EditorUtility.SaveFilePanel("Save hat file", "", note.HatName + ".hat", "hat"); Debug.Log(path == ""); if (path != "") { EditorUtility.SetDirty(note); noteObject = Instantiate(noteObject); foreach (Collider collider in noteObject.GetComponentsInChildren <Collider>()) { DestroyImmediate(collider); } noteObject.GetComponent <GorillaCosmetics.Data.Descriptors.HatDescriptor>().enabled = false; DestroyImmediate(noteObject.GetComponent <GorillaCosmetics.Data.Descriptors.HatDescriptor>()); // do stuff ExporterUtils.ExportPackage(noteObject, path, "Hat", ExporterUtils.HatDescriptorToJSON(note)); EditorUtility.DisplayDialog("Exportation Successful!", "Exportation Successful!", "OK"); EditorUtility.RevealInFinder(path); } else { EditorUtility.DisplayDialog("Exportation Failed!", "Path is invalid.", "OK"); } } else { EditorUtility.DisplayDialog("Exportation Failed!", "Note GameObject is missing.", "OK"); } } GUILayout.Space(20); } } GUI.EndScrollView(); }
void OnGUI() { var window = EditorWindow.GetWindow(typeof(CompileMapWindow), false, "Map Exporter", false); int ScrollSpace = (16 + 20) + (16 + 17 + 17 + 20 + 20); foreach (MapDescriptor note in notes) { if (note != null) { ScrollSpace += (16 + 17 + 17 + 20 + 20); } } float currentWindowWidth = EditorGUIUtility.currentViewWidth; float windowWidthIncludingScrollbar = currentWindowWidth; if (window.position.size.y >= ScrollSpace) { windowWidthIncludingScrollbar += 30; } scrollPosition = GUI.BeginScrollView(new Rect(0, 0, EditorGUIUtility.currentViewWidth, window.position.size.y), scrollPosition, new Rect(0, 0, EditorGUIUtility.currentViewWidth - 20, ScrollSpace), false, false); //GUILayout.ScrollViewScope GUILayout.Label("Maps:", EditorStyles.boldLabel, GUILayout.Height(16)); GUILayout.Space(10); foreach (MapDescriptor note in notes) { if (note != null) { GUILayout.Label("GameObject : " + note.gameObject.name, EditorStyles.boldLabel, GUILayout.Height(16)); note.AuthorName = EditorGUILayout.TextField("Author name", note.AuthorName, GUILayout.Width(windowWidthIncludingScrollbar - 40), GUILayout.Height(17)); note.MapName = EditorGUILayout.TextField("Map name", note.MapName, GUILayout.Width(windowWidthIncludingScrollbar - 40), GUILayout.Height(17)); if (GUILayout.Button("Export " + note.MapName, GUILayout.Width(windowWidthIncludingScrollbar - 40), GUILayout.Height(20))) { if (!ExporterUtils.BuildTargetInstalled(BuildTarget.Android) && EditorUtility.DisplayDialog("Android Build Support missing", "You don't have Android Build Support installed for this Unity version. Please install it and do NOT continue unless you know for sure what you're doing.", "Cancel", "Continue Anyways")) { return; } GameObject noteObject = note.gameObject; if (noteObject != null && note != null) { string path = EditorUtility.SaveFilePanel("Save map file", "", note.MapName + ".gtmap", "gtmap"); if (path != "") { EditorUtility.SetDirty(note); ExporterUtils.ExportPackage(noteObject, path, "Map", ExporterUtils.MapDescriptorToJSON(note)); } } else { EditorUtility.DisplayDialog("Exportation Failed!", "Map GameObject is missing.", "OK"); } } GUILayout.Space(20); } } GUI.EndScrollView(); }
public override void OnInspectorGUI() { serializedObject.Update(); VmodMonkeMapLoader.Behaviours.MapDescriptor targetDescriptor = (VmodMonkeMapLoader.Behaviours.MapDescriptor)target; GUILayout.BeginVertical(); DrawPropertiesExcluding(serializedObject, "GravitySpeed", "SlowJumpLimit", "FastJumpLimit", "SlowJumpMultiplier", "FastJumpMultiplier", "SpawnPoints", "CustomSkybox", "ExportLighting", "m_Script"); // Don't like these hardcoded values. Maybe find a more automatic solution // DrawDefaultInspector(); EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); playerSettingsOpened = EditorGUILayout.Foldout(playerSettingsOpened, "Player Settings"); if (playerSettingsOpened) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.9f)); DrawPropertiesExcluding(serializedObject, "MapName", "AuthorName", "Description", "SpawnPoints", "CustomSkybox", "ExportLighting", "m_Script"); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } mapSettingsOpened = EditorGUILayout.Foldout(mapSettingsOpened, "Map Settings"); if (mapSettingsOpened) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.9f)); DrawPropertiesExcluding(serializedObject, "MapName", "AuthorName", "Description", "m_Script", "GravitySpeed", "SlowJumpLimit", "FastJumpLimit", "SlowJumpMultiplier", "FastJumpMultiplier"); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Thumbnail Preview"); GUILayout.Button("Refresh Preview"); GUILayout.EndHorizontal(); GUILayout.Space(10); if (textureGenerated == false) { GeneratePreview(); } float smallest = EditorGUIUtility.currentViewWidth; float width = smallest * .9f; float widthCenter = (EditorGUIUtility.currentViewWidth - (width < 512 ? width : 512)) / 2; float heightDifference = smallest * .02f; GUILayout.EndVertical(); float lastSpace = GUILayoutUtility.GetLastRect().height; // Debug.Log(lastSpace); GUILayout.Space(width); GUI.Label(new Rect(widthCenter + 7, lastSpace, width, width), texture); EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); if (GUILayout.Button("Export Map")) { if (!ExporterUtils.BuildTargetInstalled(BuildTarget.Android) && EditorUtility.DisplayDialog("Android Build Support missing", "You don't have Android Build Support installed for this Unity version. Please install it and do NOT continue unless you know for sure what you're doing.", "Cancel", "Continue Anyways")) { return; } GameObject noteObject = targetDescriptor.gameObject; string path = EditorUtility.SaveFilePanel("Save map file", "", targetDescriptor.MapName + ".gtmap", "gtmap"); if (path != "") { EditorUtility.SetDirty(targetDescriptor); ExporterUtils.ExportPackage(noteObject, path, "Map", ExporterUtils.MapDescriptorToJSON(targetDescriptor)); } } try { serializedObject.ApplyModifiedProperties(); } catch { // serialized object doesn't exist. sometimes this happens when switching scenes. } }