/// <summary> /// Updates the displayed texture with specified color information. /// </summary> /// <param name="start">Initial color on the left of the slider.</param> /// <param name="step">Final color to the right of the slider.</param> /// <param name="isHSV">Determines are the provided colors in RGB or HSV space.</param> public void UpdateTexture(Color start, Color step, bool isHSV) { Color[] colors = new Color[width * height]; FillArea(width, height, colors, start, step, new Color(0, 0, 0, 0)); if (isHSV) { for (int i = 0; i < colors.Length; i++) { colors[i] = Color.HSV2RGB(colors[i]); } } texture.SetPixels(colors); guiTexture.SetTexture(spriteTexture); Rect2I sliderBounds = guiTexture.Bounds; sliderBounds.x -= SLIDER_X_OFFSET; sliderBounds.width += SLIDER_X_OFFSET * 2; sliderBounds.y -= SLIDER_Y_OFFSET; sliderBounds.height += SLIDER_Y_OFFSET; guiSlider.Bounds = sliderBounds; }
/// <inheritdoc/> protected internal override InspectableState Refresh() { SpriteTexture spriteTexture = InspectedObject as SpriteTexture; if (spriteTexture == null) { return(InspectableState.NotModified); } InspectableState state = genericDrawer.Refresh(); if (state != InspectableState.NotModified) { // The inspector will by default just assign a resource reference without loading it, make sure we load it // so it can be previewed if (spriteTexture.Texture != null && !spriteTexture.Texture.IsLoaded) { Resources.Load <Texture>(spriteTexture.Texture.UUID); } // Make sure GUI redraws as the sprite texture properties were updated previewTexture.SetTexture(spriteTexture); } return(state); }
/// <summary> /// Updates the texture displayed on the color box. /// </summary> /// <param name="mode">Mode determining the color gamut shown in the color box.</param> /// <param name="value">Value of the third component (normally retrieved from the separate side slider).</param> public void UpdateTexture(ColorBoxMode mode, float value) { Color[] colors = new Color[width * height]; switch (mode) { case ColorBoxMode.BG_R: FillArea(width, height, colors, new Color(value, 0, 0, 1), new Color(0, 0, 1, 0), new Color(0, 1, 0, 0)); break; case ColorBoxMode.BR_G: FillArea(width, height, colors, new Color(0, value, 0, 1), new Color(0, 0, 1, 0), new Color(1, 0, 0, 0)); break; case ColorBoxMode.RG_B: FillArea(width, height, colors, new Color(0, 0, value, 1), new Color(1, 0, 0, 0), new Color(0, 1, 0, 0)); break; case ColorBoxMode.SV_H: FillArea(width, height, colors, new Color(value, 0, 0, 1), new Color(0, 1, 0, 0), new Color(0, 0, 1, 0)); for (int i = 0; i < colors.Length; i++) { colors[i] = Color.HSV2RGB(colors[i]); } break; case ColorBoxMode.HV_S: FillArea(width, height, colors, new Color(0, value, 0, 1), new Color(1, 0, 0, 0), new Color(0, 0, 1, 0)); for (int i = 0; i < colors.Length; i++) { colors[i] = Color.HSV2RGB(colors[i]); } break; case ColorBoxMode.HS_V: FillArea(width, height, colors, new Color(0, 0, value, 1), new Color(1, 0, 0, 0), new Color(0, 1, 0, 0)); for (int i = 0; i < colors.Length; i++) { colors[i] = Color.HSV2RGB(colors[i]); } break; } texture.SetPixels(colors); guiTexture.SetTexture(spriteTexture); }
/// <summary> /// Updates the displayed texture with specified color information. /// </summary> /// <param name="start">Initial color on the top of the slider.</param> /// <param name="step">Final color to the bottom of the slider.</param> /// <param name="isHSV">Determines are the provided colors in RGB or HSV space.</param> /// <param name="isLinear">True if the provided colors are in linear color space.</param> public void UpdateTexture(Color start, Color step, bool isHSV, bool isLinear) { Color[] colors = new Color[width * height]; FillArea(width, height, colors, start, new Color(0, 0, 0, 0), step); if (isHSV) { for (int i = 0; i < colors.Length; i++) { colors[i] = Color.HSV2RGB(colors[i]); } } else { // If RGB, convert to gamma space if needed if (isLinear) { for (int i = 0; i < colors.Length; i++) { colors[i] = colors[i].Gamma; } } } texture.SetPixels(colors); guiTexture.SetTexture(spriteTexture); Rect2I sliderBounds = guiTexture.Bounds; sliderBounds.x -= SLIDER_X_OFFSET; sliderBounds.width += SLIDER_X_OFFSET; sliderBounds.y -= SLIDER_Y_OFFSET; sliderBounds.height += SLIDER_Y_OFFSET * 2; guiSlider.Bounds = sliderBounds; }
/// <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; }