private void HandleDownloadInstall() { var skin = InspectorEditor.Skin; var downloadOrInstallPressed = false; var rect = EditorGUILayout.GetControlRect(); var orgWidth = rect.width; rect.width = 74; var buttonText = m_status == Status.AwaitInstall ? "Install" : "Download"; using (new GUI.EnabledBlock(m_status == Status.AwaitDownload || (m_currentVersion.IsValid && m_status == Status.AwaitInstall))) downloadOrInstallPressed = UnityEngine.GUI.Button(rect, GUI.MakeLabel(buttonText), skin.Button); rect.x += rect.width + EditorGUIUtility.standardVerticalSpacing; rect.width = orgWidth - rect.x; using (new GUI.EnabledBlock(m_status == Status.Downloading)) EditorGUI.ProgressBar(rect, m_downloadProgress, m_serverVersion.VersionStringShort + (m_status == Status.Downloading ? $": { (int)(100.0f * m_downloadProgress + 0.5f) }%" : "")); if (m_status == Status.AwaitInstall) { InspectorGUI.Separator(1, 4); EditorGUILayout.LabelField(GUI.MakeLabel($"AGXDynamicsForUnity-{m_serverVersion.VersionStringShort} is ready to be installed!\n\n" + GUI.AddColorTag("During the installation Unity will be restarted.", Color.Lerp(Color.red, Color.white, 0.25f))), skin.TextAreaMiddleCenter); } if (downloadOrInstallPressed) { if (m_status == Status.AwaitDownload) { if (File.Exists(Target)) { File.Delete(Target); } Web.RequestHandler.Get($"https://us.download.algoryx.se/AGXUnity/packages/{m_sourceFilename}", new FileInfo(Target).Directory, OnDownloadComplete, OnDownloadProgress); m_status = Status.Downloading; } else if (m_status == Status.AwaitInstall) { InstallTarget(); } } }
private void MeshStatisticsGUI() { if (IsMultiSelect || Mesh.PrecomputedCollisionMeshes.Length == 0) { return; } EditorGUILayout.Space(); InspectorGUI.BrandSeparator(); var numCollisionMeshes = Mesh.PrecomputedCollisionMeshes.Length; var totNumVertices = Mesh.PrecomputedCollisionMeshes.Select(collisionMesh => collisionMesh.Vertices.Length).Sum(); var totNumTriangles = Mesh.PrecomputedCollisionMeshes.Select(collisionMesh => collisionMesh.Indices.Length).Sum() / 3; var meshPlural = numCollisionMeshes > 1 ? "es" : string.Empty; var summaryString = $"Summary ({numCollisionMeshes} mesh{meshPlural}, {totNumTriangles} triangles, {totNumVertices} vertices)"; if (InspectorGUI.Foldout(GetMeshStatisticsEditorData(Mesh), GUI.MakeLabel(summaryString))) { InspectorGUI.Separator(); EditorGUILayout.LabelField(GUI.MakeLabel("Number of meshes"), GUI.MakeLabel(Mesh.PrecomputedCollisionMeshes.Length.ToString(), Color.green), InspectorEditor.Skin.TextField); using (InspectorGUI.IndentScope.Single) { InspectorGUI.Separator(); for (int i = 0; i < Mesh.PrecomputedCollisionMeshes.Length; ++i) { var numVertices = Mesh.PrecomputedCollisionMeshes[i].Vertices.Length; var numTriangles = Mesh.PrecomputedCollisionMeshes[i].Indices.Length / 3; EditorGUILayout.LabelField(GUI.MakeLabel($"[{i}] Number of triangles (vertices)"), GUI.MakeLabel($"{numTriangles.ToString().Color( InspectorGUISkin.BrandColorBlue )} ({numVertices.ToString()})"), InspectorEditor.Skin.TextField); } InspectorGUI.Separator(); } var totNumTrianglesString = totNumTriangles.ToString().Color(InspectorGUISkin.BrandColorBlue); var hasReducedNumTriangles = Mesh.Options != null && (Mesh.Options.Mode != AGXUnity.Collide.CollisionMeshOptions.MeshMode.Trimesh || Mesh.Options.ReductionEnabled); if (hasReducedNumTriangles) { totNumTrianglesString += $" (originally: {Mesh.SourceObjects.Select( source => source.triangles.Length / 3 ).Sum().ToString().Color( Color.red )})"; } EditorGUILayout.LabelField(GUI.MakeLabel("Total number of triangles"), GUI.MakeLabel(totNumTrianglesString), InspectorEditor.Skin.TextField); } }
public override void OnPostTargetMembersGUI() { if (Targets.Length == 1) { InspectorGUI.ToolArrayGUI(this, ArticulatedRoot.RigidBodies, "Rigid Bodies"); } else { for (int i = 0; i < NumTargets; ++i) { var articulatedRoot = Targets[i] as ArticulatedRoot; InspectorGUI.ToolArrayGUI(this, articulatedRoot.RigidBodies, $"{GUI.AddColorTag( articulatedRoot.name, InspectorGUISkin.BrandColor )}: Rigid Bodies"); if (i < NumTargets - 1) { InspectorGUI.Separator(); } } } }
private void OnGUI() { ValidateLicenseDirectory(); using (GUI.AlignBlock.Center) GUILayout.Box(IconManager.GetAGXUnityLogo(), GUI.Skin.customStyles[3], GUILayout.Width(System.Math.Min(400.0f, position.width - 20.0f)), GUILayout.Height(100)); EditorGUILayout.LabelField("© " + System.DateTime.Now.Year + " Algoryx Simulation AB", InspectorEditor.Skin.LabelMiddleCenter); InspectorGUI.BrandSeparator(1, 6); m_scroll = EditorGUILayout.BeginScrollView(m_scroll); if (IsUpdatingLicenseInformation) { ShowNotification(GUI.MakeLabel("Reading...")); } else if (AGXUnity.LicenseManager.IsBusy) { ShowNotification(GUI.MakeLabel(AGXUnity.LicenseManager.IsActivating ? "Activating..." : "Refreshing...")); } using (new GUI.EnabledBlock(!IsUpdatingLicenseInformation && !AGXUnity.LicenseManager.IsBusy)) { for (int i = 0; i < m_licenseData.Count; ++i) { var data = m_licenseData[i]; LicenseDataGUI(data); if (i + 1 < m_licenseData.Count) { InspectorGUI.Separator(2, 6, InspectorGUISkin.BrandColorBlue); } } if (m_licenseData.Count > 0) { InspectorGUI.Separator(2, 6, InspectorGUISkin.BrandColorBlue); } ActivateLicenseGUI(); } InspectorGUI.BrandSeparator(1, 6); GUILayout.Label(GUI.MakeLabel("Online Documentation", true), InspectorEditor.Skin.Label); if (InspectorGUI.Link(GUI.MakeLabel("License Manager", false, s_licenseManagerUrl))) { Application.OpenURL(s_licenseManagerUrl); } if (InspectorGUI.Link(GUI.MakeLabel("Licensing AGX Dynamics for Unity", false, s_licensingUrl))) { Application.OpenURL(s_licensingUrl); } if (InspectorGUI.Link(GUI.MakeLabel("Free Trial", false, s_freeTrialUrl))) { Application.OpenURL(s_freeTrialUrl); } EditorGUILayout.EndScrollView(); if (AGXUnity.LicenseManager.IsBusy || IsUpdatingLicenseInformation) { Repaint(); } }
private void LicenseDataGUI(LicenseData data) { var highlight = m_licenseData.Count > 1 && !IsUpdatingLicenseInformation && !AGXUnity.LicenseManager.IsBusy && data.LicenseInfo.UniqueId == AGXUnity.LicenseManager.LicenseInfo.UniqueId; if (highlight && m_activeLicenseStyle == null) { m_activeLicenseStyle = new GUIStyle(InspectorEditor.Skin.Label); } // The texture is deleted when hitting stop in the editor while // m_activeLicenseStyle != null. if (m_activeLicenseStyle != null && m_activeLicenseStyle.normal.background == null) { m_activeLicenseStyle.normal.background = GUI.CreateColoredTexture(1, 1, Color.Lerp(InspectorGUI.BackgroundColor, Color.green, 0.025f)); } var licenseFileButtons = new InspectorGUI.MiscButtonData[] { InspectorGUI.MiscButtonData.Create(MiscIcon.Update, () => { RefreshLicense(data); }, UnityEngine.GUI.enabled && data.LicenseInfo.Type == AGXUnity.LicenseInfo.LicenseType.Service, "Refresh license from server."), InspectorGUI.MiscButtonData.Create(MiscIcon.EntryRemove, () => { var deactivateDelete = EditorUtility.DisplayDialog("Deactivate and erase license.", "Would you like to deactivate the current license " + "and remove the license file from this project?\n\n" + "It's possible to activate the license again in this " + "License Manager and/or download the license file again " + "from the license portal.", "Yes", "Cancel"); if (deactivateDelete) { AGXUnity.LicenseManager.DeactivateAndDelete(data.Filename); StartUpdateLicenseInformation(); } }, UnityEngine.GUI.enabled, "Deactivate and erase license file from project.") }; var highlightScope = highlight ? new EditorGUILayout.VerticalScope(m_activeLicenseStyle) : null; InspectorGUI.SelectableTextField(GUI.MakeLabel("License file"), data.Filename, licenseFileButtons); InspectorGUI.SelectableTextField(GUI.MakeLabel("License type"), data.LicenseInfo.TypeDescription); InspectorGUI.Separator(1, 6); InspectorGUI.LicenseEndDateField(data.LicenseInfo); EditorGUILayout.EnumFlagsField(GUI.MakeLabel("Enabled modules", false, data.LicenseInfo.EnabledModules.ToString()), data.LicenseInfo.AllModulesEnabled ? AGXUnity.LicenseInfo.Module.All : data.LicenseInfo.EnabledModules, false, InspectorEditor.Skin.Popup); InspectorGUI.SelectableTextField(GUI.MakeLabel("User"), data.LicenseInfo.User); InspectorGUI.SelectableTextField(GUI.MakeLabel("Contact"), data.LicenseInfo.Contact); highlightScope?.Dispose(); }
private void OnGUI() { AboutWindow.AGXDynamicsForUnityLogoGUI(); EditorGUILayout.LabelField(GUI.MakeLabel("Current version"), GUI.MakeLabel(m_currentVersion.IsValid ? m_currentVersion.VersionStringShort : "git checkout", Color.white)); using (new EditorGUILayout.HorizontalScope()) { var newVersionAvailable = m_serverVersion.IsValid && m_serverVersion > m_currentVersion; EditorGUILayout.LabelField(GUI.MakeLabel("Latest version"), GUI.MakeLabel(m_serverVersion.IsValid ? m_serverVersion.VersionStringShort : "...", newVersionAvailable ? Color.Lerp(Color.green, Color.black, 0.35f) : Color.white), InspectorEditor.Skin.Label); GUILayout.FlexibleSpace(); if (newVersionAvailable && InspectorGUI.Link(GUI.MakeLabel("Changelog"))) { Application.OpenURL(TopMenu.AGXUnityChangelogURL); } else if (!newVersionAvailable) { GUILayout.Label("", InspectorEditor.Skin.Label); } } InspectorGUI.Separator(1, 4); var isUpToDate = m_currentVersion.IsValid && m_serverVersion.IsValid && m_currentVersion >= m_serverVersion; if (isUpToDate) { EditorGUILayout.LabelField(GUI.MakeLabel("The version of AGX Dynamics for Unity is up to date.", Color.Lerp(Color.green, Color.black, 0.35f)), InspectorEditor.Skin.TextAreaMiddleCenter); } else if (m_status == Status.Passive) { if (Web.RequestHandler.Get(@"https://us.download.algoryx.se/AGXUnity/latest.php", OnPackageNameRequest)) { m_status = Status.CheckingForUpdate; } } else if (m_status == Status.CheckingForUpdate) { Repaint(); } else { if (m_serverVersion.IsValid) { HandleDownloadInstall(); if (m_status == Status.Downloading) { Repaint(); } } } var manualPackageButtonSize = new Vector2(110, EditorGUIUtility.singleLineHeight); var manualPackageRect = new Rect(maxSize - manualPackageButtonSize - new Vector2(2.0f * EditorGUIUtility.standardVerticalSpacing, 2.0f * EditorGUIUtility.standardVerticalSpacing), manualPackageButtonSize); var manualSelectPressed = false; using (new GUI.EnabledBlock(m_status != Status.Installing && m_status != Status.Downloading)) manualSelectPressed = UnityEngine.GUI.Button(manualPackageRect, GUI.MakeLabel("Manual select..."), InspectorEditor.Skin.Button); if (manualSelectPressed) { if (!Directory.Exists(GetManualPackageDirectoryData().String)) { GetManualPackageDirectoryData().String = "Assets"; } var manualPackageFilename = EditorUtility.OpenFilePanelWithFilters("AGX Dynamics for Unity package", GetManualPackageDirectoryData().String, new string[] { "AGXUnity package", "*.*.*unitypackage" }); if (!string.IsNullOrEmpty(manualPackageFilename)) { var manualTargetFileInfo = new FileInfo(manualPackageFilename); GetManualPackageDirectoryData().String = manualTargetFileInfo.Directory.FullName; if (!manualTargetFileInfo.Exists) { Debug.LogWarning($"The target package \"{manualTargetFileInfo.FullName}\" doesn't exist. Aborting."); } else if (!VersionInfo.Parse(manualTargetFileInfo.Name).IsValid) { Debug.LogWarning($"Unable to parse version from package name \"{manualTargetFileInfo.Name}\". Aborting."); } else if (!manualTargetFileInfo.Name.StartsWith("AGXDynamicsForUnity-")) { Debug.LogWarning($"Package name \"{manualTargetFileInfo.Name}\" doesn't seems to be an AGX Dynamics for Unity package. Aborting."); } else if (EditorUtility.DisplayDialog("AGX Dynamics for Unity update", "AGX Dynamics for Unity is about to be updated/downgraded " + "to version " + VersionInfo.Parse(manualTargetFileInfo.Name).VersionString + ".\n\nDo you want to continue with the update/downgrade?", "Continue", "Cancel")) { Target = manualTargetFileInfo.FullName; m_status = Status.AwaitInstall; InstallTarget(); } } } }
private void MeshOptionsGUI() { InspectorGUI.Separator(); using (new GUI.EnabledBlock(!EditorApplication.isPlayingOrWillChangePlaymode)) { if (InspectorGUI.Foldout(GetEditorData(Mesh), GUI.MakeLabel("Options"))) { using (InspectorGUI.IndentScope.Single) { InspectorEditor.DrawMembersGUI(Targets, t => (t as AGXUnity.Collide.Mesh).Options); var applyResetResult = InspectorGUI.PositiveNegativeButtons(UnityEngine.GUI.enabled, "Apply", "Apply the changes", "Reset", "Delete collision meshes and reset mesh options values to default."); if (applyResetResult == InspectorGUI.PositiveNegativeResult.Positive) { var meshes = GetTargets <AGXUnity.Collide.Mesh>().ToArray(); var collisionMeshGenerator = new AGXUnity.Collide.CollisionMeshGenerator(); var generatorStartTime = EditorApplication.timeSinceStartup; collisionMeshGenerator.GenerateAsync(meshes); var isCanceled = false; while (!isCanceled && collisionMeshGenerator.IsRunning) { var progressBarTitle = $"Generating collision meshes: {(int)( EditorApplication.timeSinceStartup - generatorStartTime )} s"; var progressBarInfo = string.Empty; var progress = collisionMeshGenerator.Progress; isCanceled = EditorUtility.DisplayCancelableProgressBar(progressBarTitle, progressBarInfo, progress); if (!isCanceled) { System.Threading.Thread.Sleep(50); } } EditorUtility.ClearProgressBar(); if (isCanceled) { CanceledAsyncCollisionMeshGeneretors.RegisterCanceled(collisionMeshGenerator); } else { var results = collisionMeshGenerator.CollectResults(); using (new Utils.UndoCollapseBlock("Apply collision mesh data")) { foreach (var result in results) { Undo.RecordObject(result.Mesh, "Collision Meshes"); result.Mesh.Options = result.Options; result.Mesh.PrecomputedCollisionMeshes = result.CollisionMeshes; } } var hasPrefabAssetBeenChanged = results.Any(result => PrefabUtility.GetCorrespondingObjectFromOriginalSource(result.Mesh.gameObject) == null && PrefabUtility.GetPrefabInstanceHandle(result.Mesh.gameObject) == null); // Trying to dirty gizmos rendering of all affected prefab instances. // We don't have to dirty them all but it's hard to determine where // the instance is located in the hierarchy. if (hasPrefabAssetBeenChanged) { var allMeshes = Object.FindObjectsOfType <AGXUnity.Collide.Mesh>(); foreach (var m in allMeshes) { m.OnPrecomputedCollisionMeshDataDirty(); } } } collisionMeshGenerator = null; GUIUtility.ExitGUI(); } else if (applyResetResult == InspectorGUI.PositiveNegativeResult.Negative && EditorUtility.DisplayDialog("Reset collision meshes to default", "Destroy collision meshes and reset mesh options to default?", "Yes", "Cancel")) { var meshes = GetTargets <AGXUnity.Collide.Mesh>().ToArray(); using (new Utils.UndoCollapseBlock("Reset collision mesh data")) { for (int i = 0; i < meshes.Length; ++i) { var mesh = meshes[i]; Undo.RecordObject(mesh, "Resetting collision mesh data"); mesh.DestroyCollisionMeshes(); if (mesh.Options != null) { Undo.RecordObject(mesh, "Resetting mesh options to default"); mesh.Options.ResetToDesfault(); } } } } } } } }
public override void OnPreTargetMembersGUI() { var refMaterial = Material; var mixedPreset = Targets.Any(target => (target as DeformableTerrainMaterial).PresetName != refMaterial.PresetName); using (new InspectorGUI.IndentScope((InspectorGUI.IndentScope.Level > 0 ? -1 : 0))) { var resetButtonWidth = EditorGUIUtility.singleLineHeight; var rect = EditorGUILayout.GetControlRect(); var totalRectWidth = rect.width; var availablePresets = DeformableTerrainMaterial.GetAvailablePresets().ToArray(); var presetIndex = FindPresetIndex(availablePresets, refMaterial.PresetName); var invalidPreset = presetIndex < 0; EditorGUI.showMixedValue = mixedPreset || invalidPreset; if (invalidPreset) { InspectorGUI.WarningLabel($"Material preset name {refMaterial.PresetName} doesn't exist in the material presets library."); } rect.width = EditorGUIUtility.labelWidth; EditorGUI.PrefixLabel(rect, GUI.MakeLabel("Preset"), InspectorEditor.Skin.Label); rect.x += rect.width; rect.width = totalRectWidth - EditorGUIUtility.labelWidth - resetButtonWidth; EditorGUI.BeginChangeCheck(); var newPresetIndex = EditorGUI.Popup(rect, Mathf.Max(presetIndex, 0), availablePresets, InspectorEditor.Skin.Popup); if (EditorGUI.EndChangeCheck() && invalidPreset) { invalidPreset = false; } EditorGUI.showMixedValue = false; rect.x += rect.width; rect.width = resetButtonWidth; var resetButtonPressed = InspectorGUI.Button(rect, MiscIcon.ResetDefault, !invalidPreset, $"Reset values to default for preset: {refMaterial.PresetName}", 0.9f); if (!invalidPreset && newPresetIndex != presetIndex && EditorUtility.DisplayDialog("Library preset -> " + availablePresets[newPresetIndex], $"Change preset from {refMaterial.PresetName} to {availablePresets[ newPresetIndex ]}?\n" + "All current values will be overwritten.", "Yes", "No")) { foreach (var material in GetTargets <DeformableTerrainMaterial>()) { material.SetPresetNameAndUpdateValues(availablePresets[newPresetIndex]); } } if (resetButtonPressed && EditorUtility.DisplayDialog("Reset values to default", $"Reset preset {refMaterial.PresetName} to default?", "Yes", "No")) { foreach (var material in GetTargets <DeformableTerrainMaterial>()) { material.ResetToPresetDefault(); } } InspectorGUI.Separator(); } }
private void RouteGUI() { var addNewPressed = false; var insertBeforePressed = false; var insertAfterPressed = false; var erasePressed = false; NodeT listOpNode = null; Undo.RecordObject(Route, "Route changed"); if (InspectorGUI.Foldout(EditorData.Instance.GetData(Parent, "Route", entry => { entry.Bool = true; }), GUI.MakeLabel("Route"))) { var validatedRoute = Route.GetValidated(); foreach (var validatedNode in validatedRoute) { var node = validatedNode.Node; using (InspectorGUI.IndentScope.Single) { var foldoutState = NodeFoldout(validatedNode); if (foldoutState.Foldout) { OnPreFrameGUI(node); InspectorGUI.HandleFrame(node, 1); OnPostFrameGUI(node); } if (listOpNode == null && foldoutState.ButtonPressed) { listOpNode = node; } insertBeforePressed = insertBeforePressed || foldoutState.InsertBefore; insertAfterPressed = insertAfterPressed || foldoutState.InsertAfter; erasePressed = erasePressed || foldoutState.Erase; } if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.button == 0) { Selected = node; } } GUILayout.BeginHorizontal(); { InspectorGUI.Separator(1, EditorGUIUtility.singleLineHeight); addNewPressed = InspectorGUI.Button(MiscIcon.EntryAdd, true, "Add new node to the route.", GUILayout.Width(18)); if (listOpNode == null && addNewPressed) { listOpNode = Route.LastOrDefault(); } } GUILayout.EndHorizontal(); } else { InspectorGUI.Separator(1, 3); } if (addNewPressed || insertBeforePressed || insertAfterPressed) { NodeT newRouteNode = null; // Clicking "Add" will not copy data from last node. newRouteNode = listOpNode != null? addNewPressed? RouteNode.Create <NodeT>(null, listOpNode.Position, listOpNode.Rotation) : RouteNode.Create <NodeT>(listOpNode.Parent, listOpNode.LocalPosition, listOpNode.LocalRotation) : RouteNode.Create <NodeT>(); OnNodeCreate(newRouteNode, listOpNode, addNewPressed); if (addNewPressed) { Route.Add(newRouteNode); } if (insertBeforePressed) { Route.InsertBefore(newRouteNode, listOpNode); } if (insertAfterPressed) { Route.InsertAfter(newRouteNode, listOpNode); } if (newRouteNode != null) { CreateRouteNodeTool(newRouteNode); Selected = newRouteNode; } } else if (listOpNode != null && erasePressed) { Selected = null; Route.Remove(listOpNode); } }
private void OnGUI() { using (GUI.AlignBlock.Center) GUILayout.Box(IconManager.GetAGXUnityLogo(), GUI.Skin.customStyles[3], GUILayout.Width(400), GUILayout.Height(100)); EditorGUILayout.LabelField("© " + System.DateTime.Now.Year + " Algoryx Simulation AB", InspectorEditor.Skin.LabelMiddleCenter); InspectorGUI.BrandSeparator(1, 6); var agxLfxColor = Color.Lerp(Color.green, Color.black, 0.35f); var encryptedFilename = $"agx{AGXUnity.LicenseManager.GetRuntimeActivationExtension()}".Color(agxLfxColor); var serviceFilename = $"agx{AGXUnity.LicenseManager.GetLicenseExtension( AGXUnity.LicenseInfo.LicenseType.Service )}".Color(agxLfxColor); InspectorGUI.ToolDescription("Generate an AGX Dynamics for Unity runtime activation file containing " + "encrypted License Id and Activation Code bound to the application. The " + "generated runtime activation file (" + encryptedFilename + ") will be replaced " + "with a hardware locked " + serviceFilename + " if the activation is successful.\n\n" + "<b>Internet access is required during the activation on the target hardware.</b>"); InspectorGUI.Separator(1, 6); InspectorGUI.SelectFolder(GUI.MakeLabel("Build directory"), BuildDirectory, "Build directory", newBuildDirectory => { if (!Directory.Exists(newBuildDirectory)) { Debug.LogWarning($"Ignoring given build path {newBuildDirectory} doesn't exist."); return; } BuildDirectory = newBuildDirectory; // Reset reference file if it doesn't exist in the new build directory hierarchy. if (!File.Exists(ReferenceFileInBuildFull)) { m_referenceFileInBuild = string.Empty; } }); InspectorGUI.SelectFile(GUI.MakeLabel("Reference file"), ReferenceFileInBuild, "Select reference file in build", BuildDirectory, newFilename => { ReferenceFileInBuild = newFilename; }); m_idPassword.Id = EditorGUILayout.TextField(GUI.MakeLabel("Runtime License Id"), m_idPassword.Id, InspectorEditor.Skin.TextField); if (m_idPassword.Id.Any(c => !char.IsDigit(c))) { m_idPassword.Id = new string( m_idPassword.Id.Where(c => char.IsDigit(c)).ToArray()); } m_idPassword.Password = EditorGUILayout.PasswordField(GUI.MakeLabel("Runtime Activation Code"), m_idPassword.Password); var generateToolTip = string.Empty; using (new GUI.EnabledBlock(ValidateGenerate(ref generateToolTip))) { GUILayout.Space(3); if (GUILayout.Button(GUI.MakeLabel("Generate", false, generateToolTip))) { var generatedFilename = string.Empty; if (AGXUnity.LicenseManager.GenerateEncryptedRuntime(System.Convert.ToInt32(m_idPassword.Id), m_idPassword.Password, BuildDirectory, ReferenceFileInBuild, filename => generatedFilename = filename)) { EditorUtility.DisplayDialog("Encrypted Runtime License", $"Encrypted runtime successfully written to: {generatedFilename}", "Ok"); Close(); } } } }
public override void OnPreTargetMembersGUI() { var skin = InspectorEditor.Skin; var disabledPairs = Manager.DisabledPairs; bool clearPressed = false; bool addPressed = false; CollisionGroupEntryPair erasePair = null; GUILayout.Label(GUI.MakeLabel("Add pair", true), skin.LabelMiddleCenter); GUILayout.BeginVertical(skin.TextArea); { HandleCollisionGroupEntryPair(m_groupEntryPairToAdd); var buttonState = InspectorGUI.PositiveNegativeButtons(m_groupEntryPairToAdd.First.Tag.Length > 0 || m_groupEntryPairToAdd.Second.Tag.Length > 0, "Add", "Add pair to disabled pairs.", "Clear"); addPressed = buttonState == InspectorGUI.PositiveNegativeResult.Positive; clearPressed = buttonState == InspectorGUI.PositiveNegativeResult.Negative; } GUILayout.EndVertical(); if (InspectorGUI.Foldout(FoldoutDataEntry, GUI.MakeLabel("Disabled Pairs [" + disabledPairs.Length + "]"))) { using (InspectorGUI.IndentScope.Single) { foreach (var disabledPair in disabledPairs) { GUILayout.BeginHorizontal(); { InspectorGUI.Separator(1, EditorGUIUtility.singleLineHeight); if (InspectorGUI.Button(MiscIcon.EntryRemove, true, "Remove pair from list.", GUILayout.Width(18))) { erasePair = disabledPair; } } GUILayout.EndHorizontal(); HandleCollisionGroupEntryPair(disabledPair); // TODO GUI: Maybe unnecessary space with correct separator. GUILayout.Space(6.0f); } } } if (clearPressed) { m_groupEntryPairToAdd.First.Tag = m_groupEntryPairToAdd.Second.Tag = string.Empty; } if (addPressed) { Manager.SetEnablePair(m_groupEntryPairToAdd.First.Tag, m_groupEntryPairToAdd.Second.Tag, false); m_groupEntryPairToAdd.First.Tag = m_groupEntryPairToAdd.Second.Tag = string.Empty; FoldoutDataEntry.Bool = true; } if (erasePair != null) { if (EditorUtility.DisplayDialog("Remove pair", "Erase disabled pair: " + erasePair.First.Tag + " and " + erasePair.Second.Tag + "?", "Yes", "No")) { Manager.SetEnablePair(erasePair.First.Tag, erasePair.Second.Tag, true); } } }
public override void OnPostTargetMembersGUI() { var skin = InspectorEditor.Skin; Simulation.DisplayStatistics = InspectorGUI.Toggle(GUI.MakeLabel("Display Statistics"), Simulation.DisplayStatistics); if (Simulation.DisplayStatistics) { using (InspectorGUI.IndentScope.Single) Simulation.DisplayMemoryAllocations = InspectorGUI.Toggle(GUI.MakeLabel("Display Memory Allocations"), Simulation.DisplayMemoryAllocations); } InspectorGUI.Separator(1, 4); using (new GUI.EnabledBlock(Application.isPlaying)) { #if AGXUNITY_DEV_BUILD if (GUILayout.Button(GUI.MakeLabel("Save current step as (.agx)...", false, "Save scene in native file format when the editor is in play mode."), skin.Button)) { saveCurrentState(); } if (GUILayout.Button(GUI.MakeLabel("Open in AGX native viewer", false, "Creates Lua file, saves current scene to an .agx file and executes luaagx.exe."), skin.Button)) { Simulation.OpenInNativeViewer(); } #endif var rect = EditorGUILayout.GetControlRect(); var orgWidth = rect.width; rect.width = EditorGUIUtility.labelWidth; EditorGUI.PrefixLabel(rect, GUI.MakeLabel("Save current step as (.agx)"), skin.Label); rect.x += EditorGUIUtility.labelWidth; rect.width = orgWidth - EditorGUIUtility.labelWidth; if (UnityEngine.GUI.Button(rect, GUI.MakeLabel("Output file..."), skin.Button)) { string result = EditorUtility.SaveFilePanel("Save scene as .agx", "Assets", UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name, "agx"); if (result != string.Empty) { var success = Simulation.SaveToNativeFile(result); if (success) { Debug.Log(GUI.AddColorTag("Successfully wrote simulation to file: ", Color.green) + result); } } } } Simulation.SavePreFirstStepPath = InspectorGUI.ToggleSaveFile(GUI.MakeLabel("Dump initial (.agx)"), Simulation.SavePreFirstStep, enabled => Simulation.SavePreFirstStep = enabled, Simulation.SavePreFirstStepPath, UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name, "agx", "Path to initial dump (including file name and extension)", fileExtension => fileExtension == ".agx" || fileExtension == ".aagx"); #if AGXUNITY_DEV_ENV using (new GUI.EnabledBlock(EditorApplication.isPlaying)) { var rect = EditorGUILayout.GetControlRect(); rect.x += EditorGUIUtility.labelWidth; rect.width -= EditorGUIUtility.labelWidth; if (UnityEngine.GUI.Button(rect, GUI.MakeLabel("Open in native viewer..."), skin.Button)) { ; } } #endif }