void StatGUI() { EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); var foldout = EditorUtil.GUILayout.AutoSavedFoldout("DclFoldStat", LabelLocalization.getString(LanguageStringValue.Statistics), true, null); if (foldout) { if (GUILayout.Button(LabelLocalization.getString(LanguageStringValue.Refresh))) { sceneMeta.RefreshStatistics(); } } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 1; if (foldout) { GUILayout.Label(LabelLocalization.getString(LanguageStringValue.KeepTheseNumbersSmaller), EditorStyles.centeredGreyMiniLabel); var n = sceneMeta.parcels.Count; var sceneStatistics = sceneMeta.sceneStatistics; StatisticsLineGUI(LabelLocalization.getString(LanguageStringValue.Triangles), sceneStatistics.triangleCount, LimitationConfigs.GetMaxTriangles(n)); StatisticsLineGUI(LabelLocalization.getString(LanguageStringValue.Bodies), sceneStatistics.bodyCount, LimitationConfigs.GetMaxBodies(n)); StatisticsLineGUI(LabelLocalization.getString(LanguageStringValue.Entities), sceneStatistics.entityCount, LimitationConfigs.GetMaxTriangles(n)); StatisticsLineGUI(LabelLocalization.getString(LanguageStringValue.Materials), sceneStatistics.materialCount, LimitationConfigs.GetMaxMaterials(n)); StatisticsLineGUI(LabelLocalization.getString(LanguageStringValue.Textures), sceneStatistics.textureCount, LimitationConfigs.GetMaxTextures(n)); StatisticsLineGUI(LabelLocalization.getString(LanguageStringValue.Height), sceneStatistics.maxHeight, LimitationConfigs.GetMaxHeight(n)); } WarningsGUI(); EditorGUI.indentLevel = 0; EditorGUILayout.EndVertical(); }
static void Init() { var window = (DclExporter)GetWindow(typeof(DclExporter)); window.titleContent = new GUIContent(LabelLocalization.getString(LanguageStringValue.DCLExporter)); window.Show(); window.minSize = new Vector2(240, 400); }
void OnGUI() { if (!sceneMeta) { CheckAndGetDclSceneMetaObject(); } ParcelGUI(); GUILayout.Space(SPACE_SIZE); StatGUI(); GUILayout.Space(SPACE_SIZE); EditorGUI.BeginChangeCheck(); //OptionsGUI(); no use yet //GUILayout.Space(SPACE_SIZE); OwnerGUI(); GUILayout.Space(SPACE_SIZE); ExportForDCLGUI(); GUILayout.Space(SPACE_SIZE); ExportForNowGUI(); GUILayout.Space(SPACE_SIZE * 3); #region Help Link string url = "https://github.com/fairwood/DecentralandUnityPlugin"; if (GUILayout.Button(string.Format(LabelLocalization.getString(LanguageStringValue.Document), url), EditorStyles.helpBox)) { Application.OpenURL(url); } #endregion if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(sceneMeta); EditorSceneManager.MarkSceneDirty(sceneMeta.gameObject.scene); } }
void OwnerGUI() { EditorGUILayout.BeginVertical("box"); var oriFoldout = EditorPrefs.GetBool("DclBoldOwner"); var foldout = EditorGUILayout.Foldout(oriFoldout, LabelLocalization.getString(LanguageStringValue.OwnerInfo), true); if (foldout) { EditorGUI.indentLevel = 1; sceneMeta.ethAddress = EditorGUILayout.TextField(LabelLocalization.getString(LanguageStringValue.OwnerInfoAddress), sceneMeta.ethAddress); sceneMeta.contactName = EditorGUILayout.TextField(LabelLocalization.getString(LanguageStringValue.OwnerInfoName), sceneMeta.contactName); sceneMeta.email = EditorGUILayout.TextField(LabelLocalization.getString(LanguageStringValue.OwnerInfoEmail), sceneMeta.email); EditorGUI.indentLevel = 0; } if (foldout != oriFoldout) { EditorPrefs.SetBool("DclBoldOwner", foldout); } EditorGUILayout.EndVertical(); }
void WarningsGUI() { var foldout = EditorPrefs.GetBool("DclFoldStat", true); if (foldout) { var warningCount = sceneMeta.sceneWarningRecorder.OutOfLandWarnings.Count + sceneMeta.sceneWarningRecorder.UnsupportedShaderWarnings.Count + sceneMeta.sceneWarningRecorder.InvalidTextureWarnings.Count; // GUILayout.Label(string.Format("Warnings({0})", warningCount)); if (warningCount > 0) { GUILayout.Label(LabelLocalization.getString(LanguageStringValue.ClickWarning), EditorStyles.centeredGreyMiniLabel); foreach (var outOfLandWarning in sceneMeta.sceneWarningRecorder.OutOfLandWarnings) { WarningLineGUI(string.Format(LabelLocalization.getString(LanguageStringValue.OutofLandRange), outOfLandWarning.meshRenderer.name), null, outOfLandWarning.meshRenderer.gameObject); } foreach (var warning in sceneMeta.sceneWarningRecorder.UnsupportedShaderWarnings) { var path = AssetDatabase.GetAssetPath(warning.renderer); WarningLineGUI(string.Format(LabelLocalization.getString(LanguageStringValue.UnsupportedShader), warning.renderer.name), LabelLocalization.getString(LanguageStringValue.OnlyStandardShaderSupported), path); } foreach (var warning in sceneMeta.sceneWarningRecorder.InvalidTextureWarnings) { var path = AssetDatabase.GetAssetPath(warning.renderer); WarningLineGUI(string.Format(LabelLocalization.getString(LanguageStringValue.InvalidTextureSize), warning.renderer.name), LabelLocalization.getString(LanguageStringValue.TextureSizeMustBe), path); } } } }
void ExportForNowGUI() { EditorGUILayout.BeginVertical("box"); var foldout = EditorUtil.GUILayout.AutoSavedFoldout("DclExportForNow", LabelLocalization.getString(LanguageStringValue.ExportForNowSh), true, null); if (foldout) { GUILayout.Label(LabelLocalization.getString(LanguageStringValue.DCLNowProjectPath), EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); exportPath = EditorPrefs.GetString("DclNowExportPath"); var newExportPath = EditorGUILayout.TextField(exportPath); if (GUILayout.Button("...", GUILayout.Width(24), GUILayout.Height(24))) { newExportPath = EditorUtility.OpenFolderPanel(LabelLocalization.getString(LanguageStringValue.SelectDCLProjectPath), exportPath, ""); if (string.IsNullOrEmpty(newExportPath)) { newExportPath = exportPath; } } if (newExportPath != exportPath) { exportPath = newExportPath; EditorPrefs.SetString("DclNowExportPath", newExportPath); } EditorGUILayout.EndHorizontal(); GUILayout.Space(SPACE_SIZE); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); var oriColor = GUI.backgroundColor; GUI.backgroundColor = Color.green; if (GUILayout.Button(LabelLocalization.getString(LanguageStringValue.Export), GUILayout.Width(220), GUILayout.Height(32))) { Export(); //Add package.json & so on files var templateFolder = FileUtil.FindFolder("Editor/now_template"); var filesToCopy = new string[] { "build.json", "package.json", "tsconfig.json", }; foreach (var filename in filesToCopy) { UnityEditor.FileUtil.ReplaceFile(Path.Combine(templateFolder, filename), Path.Combine(exportPath, filename)); } } GUI.backgroundColor = oriColor; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(SPACE_SIZE * 2); } EditorGUILayout.EndVertical(); }
void ExportForDCLGUI() { EditorGUILayout.BeginVertical("box"); var foldout = EditorUtil.GUILayout.AutoSavedFoldout("DclExportForDCL", LabelLocalization.getString(LanguageStringValue.StandardExport), true, null); if (foldout) { GUILayout.Label(LabelLocalization.getString(LanguageStringValue.DCLProjectPath), EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); exportPath = EditorPrefs.GetString("DclExportPath"); var newExportPath = EditorGUILayout.TextField(exportPath); if (GUILayout.Button("...", GUILayout.Width(24), GUILayout.Height(24))) { newExportPath = EditorUtility.OpenFolderPanel(LabelLocalization.getString(LanguageStringValue.SelectDCLProjectPath), exportPath, ""); if (string.IsNullOrEmpty(newExportPath)) { newExportPath = exportPath; } } if (newExportPath != exportPath) { exportPath = newExportPath; EditorPrefs.SetString("DclExportPath", newExportPath); } EditorGUILayout.EndHorizontal(); GUILayout.Space(SPACE_SIZE); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); var oriColor = GUI.backgroundColor; GUI.backgroundColor = Color.green; if (GUILayout.Button(LabelLocalization.getString(LanguageStringValue.Export), GUILayout.Width(220), GUILayout.Height(32))) { Export(); } GUI.backgroundColor = oriColor; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(SPACE_SIZE * 2); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(LabelLocalization.getString(LanguageStringValue.InitProject), GUILayout.Width(105))) { if (Directory.Exists(exportPath)) { if (EditorUtility.DisplayDialog(LabelLocalization.getString(LanguageStringValue.ConfirmInitDCLProject), string.Format(LabelLocalization.getString(LanguageStringValue.InitDCLProjectAreYouSure), exportPath), LabelLocalization.getString(LanguageStringValue.YES), LabelLocalization.getString(LanguageStringValue.NO))) { DclCLI.DclInit(exportPath); } } else { ShowNotification(new GUIContent(LabelLocalization.getString(LanguageStringValue.SelectValidProjectFolder))); } } if (GUILayout.Button(LabelLocalization.getString(LanguageStringValue.RunProject), GUILayout.Width(105))) { if (Directory.Exists(exportPath)) { if (EditorUtility.DisplayDialog(LabelLocalization.getString(LanguageStringValue.ConfimRunDCLProject), string.Format(LabelLocalization.getString(LanguageStringValue.RunDCLProjectAreYouSure), exportPath), LabelLocalization.getString(LanguageStringValue.YES), LabelLocalization.getString(LanguageStringValue.NO))) { DclCLI.DclStart(exportPath); ShowNotification(new GUIContent(LabelLocalization.getString(LanguageStringValue.DCLStartWait10Seconds))); } } else { ShowNotification(new GUIContent(LabelLocalization.getString(LanguageStringValue.SelectValidProjectFolder))); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(SPACE_SIZE * 2); } EditorGUILayout.EndVertical(); }
private static void chooseLanguage(LabelLocalization.ELanguage l) { LabelLocalization.Language = l; LabelLocalization.loadLanguageStringFromFile(); }
void ParcelGUI() { EditorGUILayout.BeginVertical("box"); var parcels = sceneMeta.parcels; EditorGUILayout.BeginHorizontal(); var style = EditorStyles.foldout; style.fontStyle = FontStyle.Bold; var foldout = EditorUtil.GUILayout.AutoSavedFoldout("DclFoldParcel", string.Format(LabelLocalization.getString(LanguageStringValue.ParcelsCount), parcels.Count), true, style); if (foldout) { if (editParcelsMode) { if (GUILayout.Button(LabelLocalization.getString(LanguageStringValue.Save))) { CheckAndGetDclSceneMetaObject(); try { var newParcels = new List <ParcelCoordinates>(); ParseTextToCoordinates(editParcelsText, newParcels); parcels = newParcels; sceneMeta.parcels = parcels; editParcelsMode = false; } catch (Exception e) { Debug.LogError(e.Message); EditorUtility.DisplayDialog(LabelLocalization.getString(LanguageStringValue.CoordinatesFormatError), @"57,-11 57,-12 57,-13", "OK"); } EditorUtility.SetDirty(sceneMeta); EditorSceneManager.MarkSceneDirty(sceneMeta.gameObject.scene); } if (GUILayout.Button("X", GUILayout.Width(20))) { editParcelsMode = false; CheckAndGetDclSceneMetaObject(); } } else { if (GUILayout.Button(LabelLocalization.getString(LanguageStringValue.Edit))) { var sb = new StringBuilder(); if (parcels.Count > 0) { sb.Append(ParcelToStringBuilder(parcels[0])); for (int i = 1; i < parcels.Count; i++) { sb.Append('\n').Append(ParcelToStringBuilder(parcels[i])); } } editParcelsText = sb.ToString(); editParcelsMode = true; CheckAndGetDclSceneMetaObject(); } } } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 1; if (foldout) { if (editParcelsMode) { editParcelsText = EditorGUILayout.TextArea(editParcelsText, GUILayout.Height(120)); } else { var sb = new StringBuilder(); if (parcels.Count > 0) { sb.Append(ParcelToStringBuilder(parcels[0])).Append(LabelLocalization.getString(LanguageStringValue.Base)); for (int i = 1; i < parcels.Count; i++) { sb.Append('\n').Append(ParcelToStringBuilder(parcels[i])); } } EditorGUILayout.LabelField(sb.ToString(), GUILayout.Height(120)); } } EditorGUI.indentLevel = 0; EditorGUILayout.EndVertical(); }