private void BuildGUI() { progressBar = new GUIProgressBar(); messageLabel = new GUILabel(""); GUILayoutY layoutY = GUI.AddLayoutY(); layoutY.AddFlexibleSpace(); GUILayoutX messageLayout = layoutY.AddLayoutX(); messageLayout.AddFlexibleSpace(); messageLayout.AddElement(messageLabel); messageLayout.AddFlexibleSpace(); layoutY.AddSpace(10); GUILayoutX barLayout = layoutY.AddLayoutX(); barLayout.AddSpace(30); barLayout.AddElement(progressBar); barLayout.AddSpace(30); layoutY.AddFlexibleSpace(); Percent = percent; messageLabel.SetContent(message); }
public override void SetValue(object value) { if (value == null) { return; } string strValue = value.ToString(); valueDisplay.SetContent(strValue); }
/// <summary> /// Constructs the dialog box. /// </summary> /// <param name="title">Text to display in the title bar.</param> /// <param name="message">Message to display in the dialog box.</param> /// <param name="type">Type of dialog box that determines what buttons to display.</param> /// <param name="resultCallback">Callback to trigger when the user clicks on a dialog box button.</param> protected DialogBox(LocString title, LocString message, Type type, Action <ResultType> resultCallback) : base(false) { this.resultCallback = resultCallback; this.type = type; SetupGUI(); Title = title; messageLabel.SetContent(message); Width = 280; Height = messageLabel.Bounds.height + 60; }
/// <inheritdoc/> protected internal override InspectableState Refresh(bool force = false) { PlainText plainText = InspectedObject as PlainText; if (plainText == null) return InspectableState.NotModified; string newText = plainText.Text; string newShownText = plainText.Text.Substring(0, MathEx.Min(newText.Length, MAX_SHOWN_CHARACTERS)); if (newShownText != shownText) { textLabel.SetContent(newShownText); shownText = newShownText; } return InspectableState.NotModified; }
/// <summary> /// Shows a preview of the specified camera with the specified bounds. /// </summary> /// <param name="camera">The camera to preview</param> /// <param name="bounds">The bounds of the preview</param> public void ShowPreview(Camera camera, Rect2I bounds) { previewPanel.Bounds = bounds; cameraNameLabel.SetContent(camera.SceneObject?.Name); renderTextureGUI.SetWidth(bounds.width); renderTextureGUI.SetHeight(bounds.height); var cameraRenderTexture = (RenderTexture)camera.Viewport.Target; if (cameraRenderTexture != null) { var renderTexture = new RenderTexture(cameraRenderTexture.ColorSurface); renderTextureGUI.RenderTexture = renderTexture; } else { // TODO: We cannot preview cameras that don't have a render target because we need preview support for // setting a temporary render target for preview purposes } }
/// <summary> /// Updates the GUI element values from the current import options object. /// </summary> private void UpdateGUIValues() { isEditorField.Value = importOptions.EditorScript; ScriptCode scriptCode = InspectedObject as ScriptCode; if (scriptCode == null) { return; } string newText = scriptCode.Text; string newShownText = scriptCode.Text.Substring(0, MathEx.Min(newText.Length, MAX_SHOWN_CHARACTERS)); if (newShownText != shownText) { textLabel.SetContent(newShownText); shownText = newShownText; } }
private void BuildGUI() { progressBar = new GUIProgressBar(); messageLabel = new GUILabel("", EditorStyles.MultiLineLabelCentered, GUIOption.FixedHeight(60)); cancelImport = new GUIButton(new LocEdString("Cancel import")); cancelImport.OnClick += () => { ProjectLibrary.CancelImport(); cancelImport.Disabled = true; }; GUILayoutY layoutY = GUI.AddLayoutY(); layoutY.AddFlexibleSpace(); GUILayoutX messageLayout = layoutY.AddLayoutX(); messageLayout.AddSpace(15); messageLayout.AddElement(messageLabel); messageLayout.AddSpace(15); layoutY.AddSpace(10); GUILayoutX barLayout = layoutY.AddLayoutX(); barLayout.AddSpace(30); barLayout.AddElement(progressBar); barLayout.AddSpace(30); layoutY.AddSpace(20); GUILayoutX buttonLayout = layoutY.AddLayoutX(); buttonLayout.AddFlexibleSpace(); buttonLayout.AddElement(cancelImport); buttonLayout.AddFlexibleSpace(); layoutY.AddFlexibleSpace(); messageLabel.SetContent(new LocEdString("Resource import is still in progress. You can wait until it " + "finishes or cancel import. \n\nNote that even when cancelling you will need to wait for active import threads to finish.")); }
/// <inheritdoc/> protected internal override InspectableState Refresh() { ScriptCode scriptCode = InspectedObject as ScriptCode; if (scriptCode == null) { return(InspectableState.NotModified); } isEditorField.Value = importOptions.EditorScript; string newText = scriptCode.Text; string newShownText = scriptCode.Text.Substring(0, MathEx.Min(newText.Length, MAX_SHOWN_CHARACTERS)); if (newShownText != shownText) { textLabel.SetContent(newShownText); shownText = newShownText; } return(InspectableState.NotModified); }
/// <inheritdoc/> public override void UpdateContents(int index, ConsoleEntryData data) { if (index != sSelectedElementIdx) { if (index % 2 != 0) { background.Visible = true; background.SetTint(BG_COLOR); } else { background.Visible = false; } } else { background.Visible = true; background.SetTint(SELECTION_COLOR); } switch (data.type) { case DebugMessageType.Info: icon.SetTexture(EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 32, false)); break; case DebugMessageType.Warning: case DebugMessageType.CompilerWarning: icon.SetTexture(EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 32, false)); break; case DebugMessageType.Error: case DebugMessageType.CompilerError: icon.SetTexture(EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 32, false)); break; } messageLabel.SetContent(new LocEdString(data.message)); string method = ""; if (data.callstack != null && data.callstack.Length > 0) { string filePath = data.callstack[0].file; bool isFilePathValid = filePath.IndexOfAny(Path.GetInvalidPathChars()) == -1; if (isFilePathValid) { file = Path.GetFileName(data.callstack[0].file); } else { file = "<unknown file>"; } line = data.callstack[0].line; if (string.IsNullOrEmpty(data.callstack[0].method)) { method = "\tin " + file + ":" + line; } else { method = "\t" + data.callstack[0].method + " in " + file + ":" + line; } } else { file = ""; line = 0; } functionLabel.SetContent(new LocEdString(method)); entryIdx = index; }
/// <inheritdoc/> public override void SetValue(float value) { string strValue = value.ToString("n2"); valueDisplay.SetContent(strValue); }