private void SetCustomParameters(ImageEffectBase imageEffect) { System.Type type = imageEffect.GetType(); if (type == typeof(VideoGlitchBrokenScreen)) { ((VideoGlitchBrokenScreen)imageEffect).impact = new Vector2(Random.Range(-0.75f, 0.75f), Random.Range(-0.75f, 0.75f)); } }
private void DrawCustomControls(ImageEffectBase imageEffect) { System.Type type = imageEffect.GetType(); if (type == typeof(VideoGlitchShift)) { VideoGlitchShift effect = imageEffect as VideoGlitchShift; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Amplitude", GUILayout.Width(60)); effect.amplitude = GUILayout.HorizontalSlider(effect.amplitude, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Speed", GUILayout.Width(60)); effect.speed = GUILayout.HorizontalSlider(effect.speed, 0.0f, 0.2f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VideoGlitchNoiseDigital)) { VideoGlitchNoiseDigital effect = imageEffect as VideoGlitchNoiseDigital; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Threshold", GUILayout.Width(60)); effect.threshold = GUILayout.HorizontalSlider(effect.threshold, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Max offset", GUILayout.Width(60)); effect.maxOffset = GUILayout.HorizontalSlider(effect.maxOffset, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Threshold YUV", GUILayout.Width(60)); effect.thresholdYUV = GUILayout.HorizontalSlider(effect.thresholdYUV, 0.0f, 1.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VideoGlitchBlackWhiteDistortion)) { VideoGlitchBlackWhiteDistortion effect = imageEffect as VideoGlitchBlackWhiteDistortion; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Steps", GUILayout.Width(60)); effect.distortionSteps = GUILayout.HorizontalSlider(effect.distortionSteps, 1.0f, 10.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Speed", GUILayout.Width(60)); effect.distortionSpeed = GUILayout.HorizontalSlider(effect.distortionSpeed, 0.0f, 10.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VideoGlitchBrokenScreen)) { VideoGlitchBrokenScreen effect = imageEffect as VideoGlitchBrokenScreen; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Splits", GUILayout.Width(60)); effect.splits = (int)GUILayout.HorizontalSlider(effect.splits, 2.0f, 100.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Threshold", GUILayout.Width(60)); effect.splitThreshold = GUILayout.HorizontalSlider(effect.splitThreshold, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Distortion", GUILayout.Width(60)); effect.distortion = GUILayout.HorizontalSlider(effect.distortion, 0.0f, 1.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VideoGlitchRGBDisplay)) { VideoGlitchRGBDisplay effect = imageEffect as VideoGlitchRGBDisplay; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Cell size", GUILayout.Width(60)); effect.cellSize = (int)GUILayout.HorizontalSlider(effect.cellSize, 1.0f, 10.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VideoGlitchSpectrumOffset)) { VideoGlitchSpectrumOffset effect = imageEffect as VideoGlitchSpectrumOffset; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Strength", GUILayout.Width(60)); effect.strength = GUILayout.HorizontalSlider(effect.strength, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Steps", GUILayout.Width(60)); effect.steps = (int)GUILayout.HorizontalSlider(effect.steps, 3.0f, 10.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VideoGlitchOldTape)) { VideoGlitchOldTape effect = imageEffect as VideoGlitchOldTape; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Speed", GUILayout.Width(60)); effect.noiseSpeed = GUILayout.HorizontalSlider(effect.noiseSpeed, 1.0f, 100.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Amplitude", GUILayout.Width(60)); effect.noiseAmplitude = (int)GUILayout.HorizontalSlider(effect.noiseAmplitude, 1.0f, 100.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VideoGlitchVHSPause)) { VideoGlitchVHSPause effect = imageEffect as VideoGlitchVHSPause; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Strength", GUILayout.Width(60)); effect.strength = GUILayout.HorizontalSlider(effect.strength, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Color noise", GUILayout.Width(80)); effect.colorNoise = GUILayout.HorizontalSlider(effect.colorNoise, 0.0f, 1.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VideoGlitchOldTV)) { VideoGlitchOldTV effect = imageEffect as VideoGlitchOldTV; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("SlowScan", GUILayout.Width(60)); effect.slowScan = GUILayout.HorizontalSlider(effect.slowScan, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("ScanLine", GUILayout.Width(60)); effect.scanLine = GUILayout.HorizontalSlider(effect.scanLine, 0.0f, 2.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Vignette softness", GUILayout.Width(60)); effect.vignetteSoftness = GUILayout.HorizontalSlider(effect.vignetteSoftness, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Vignette scale", GUILayout.Width(60)); effect.vignetteScale = GUILayout.HorizontalSlider(effect.vignetteScale, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Grain opacity", GUILayout.Width(60)); effect.grainOpacity = GUILayout.HorizontalSlider(effect.grainOpacity, 0.0f, 100.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Grain saturation", GUILayout.Width(60)); effect.grainSaturation = GUILayout.HorizontalSlider(effect.grainSaturation, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Scan distort", GUILayout.Width(60)); effect.scanDistort = GUILayout.HorizontalSlider(effect.scanDistort, 0.0f, 10.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Timer", GUILayout.Width(60)); effect.timer = GUILayout.HorizontalSlider(effect.timer, 0.0f, 5.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Speed", GUILayout.Width(60)); effect.speed = GUILayout.HorizontalSlider(effect.speed, 1.0f, 5.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("CRT scale", GUILayout.Width(60)); effect.crtScale = GUILayout.HorizontalSlider(effect.crtScale, 1.0f, 10.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Stripes count", GUILayout.Width(60)); effect.stripesCount = GUILayout.HorizontalSlider(effect.stripesCount, 0.0f, 1000.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Stripes opacity", GUILayout.Width(60)); effect.stripesOpacity = GUILayout.HorizontalSlider(effect.stripesOpacity, 0.0f, 10.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Bars count", GUILayout.Width(60)); effect.barsCount = GUILayout.HorizontalSlider(effect.barsCount, 0.0f, 1000.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Moire opacity", GUILayout.Width(60)); effect.moireOpacity = GUILayout.HorizontalSlider(effect.moireOpacity, 0.0f, 100.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Moire scale", GUILayout.Width(60)); effect.moireScale = GUILayout.HorizontalSlider(effect.moireScale, 0.01f, 100.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("TV lines", GUILayout.Width(60)); effect.tvLines = GUILayout.HorizontalSlider(effect.tvLines, 0.01f, 10.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("TV lines opacity", GUILayout.Width(60)); effect.tvLinesOpacity = GUILayout.HorizontalSlider(effect.tvLinesOpacity, 0.0f, 10.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Vignette tube scale", GUILayout.Width(60)); effect.vignetteTubeScale = GUILayout.HorizontalSlider(effect.vignetteTubeScale, 0.01f, 10.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("TV dots", GUILayout.Width(60)); effect.tvDots = GUILayout.HorizontalSlider(effect.tvDots, 0.0f, 4.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("TV dots blend", GUILayout.Width(60)); effect.tvDotsBlend = GUILayout.HorizontalSlider(effect.tvDotsBlend, 0.0f, 1000.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VideoGlitchCorruptionDigital)) { VideoGlitchCorruptionDigital effect = imageEffect as VideoGlitchCorruptionDigital; if (effect != null) { GUILayout.BeginHorizontal(); { GUILayout.Label("Strength", GUILayout.Width(60)); effect.strength = GUILayout.HorizontalSlider(effect.strength, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Tile size", GUILayout.Width(60)); effect.tileSize = (int)GUILayout.HorizontalSlider(effect.tileSize, 1.0f, 128.0f); } GUILayout.EndHorizontal(); } } }
private void DrawExtraControls(ImageEffectBase imageEffect) { if (imageEffect.GetType() == typeof(VintageExtrasBrightnessContrastGamma)) { VintageExtrasBrightnessContrastGamma extraEffect = imageEffect as VintageExtrasBrightnessContrastGamma; GUILayout.BeginHorizontal(); { GUILayout.Label("Brightness", GUILayout.Width(70)); extraEffect.brightness = GUILayout.HorizontalSlider(extraEffect.brightness * 100.0f, -100.0f, 100.0f) * 0.01f; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Contrast", GUILayout.Width(70)); extraEffect.contrast = GUILayout.HorizontalSlider(extraEffect.contrast * 100.0f, -100, 100) * 0.01f; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Gamma", GUILayout.Width(70)); extraEffect.gamma = GUILayout.HorizontalSlider(extraEffect.gamma, 0.01f, 10.0f); } GUILayout.EndHorizontal(); } else if (imageEffect.GetType() == typeof(VintageExtrasHueSaturation)) { VintageExtrasHueSaturation extraEffect = imageEffect as VintageExtrasHueSaturation; GUILayout.BeginHorizontal(); { GUILayout.Label("Hue", GUILayout.Width(70)); extraEffect.hue = GUILayout.HorizontalSlider(extraEffect.hue, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Saturation", GUILayout.Width(70)); extraEffect.saturation = GUILayout.HorizontalSlider(extraEffect.saturation, 0.0f, 1.0f); } GUILayout.EndHorizontal(); } else if (imageEffect.GetType() == typeof(VintageExtrasFilm)) { VintageExtrasFilm extraEffect = imageEffect as VintageExtrasFilm; GUILayout.BeginHorizontal(); { GUILayout.Label("Grain", GUILayout.Width(70)); extraEffect.grainStrength = GUILayout.HorizontalSlider(extraEffect.grainStrength, 0.0f, 100.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Grain size", GUILayout.Width(70)); extraEffect.grainSize = GUILayout.HorizontalSlider(extraEffect.grainSize, 0.0f, 0.1f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Blink", GUILayout.Width(70)); extraEffect.blinkStrenght = GUILayout.HorizontalSlider(extraEffect.blinkStrenght, 0.0f, 0.1f); } GUILayout.EndHorizontal(); } }
private void OnGUI() { #if UNITY_ANDROID || UNITY_IPHONE GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3((float)Screen.width / 1280.0f, (float)Screen.height / 720.0f, 1.0f)); #endif if (videoGlitches.Count == 0) { return; } if (effectNameStyle == null) { effectNameStyle = new GUIStyle(GUI.skin.textArea); effectNameStyle.alignment = TextAnchor.MiddleCenter; effectNameStyle.fontSize = 22; } if (menuStyle == null) { menuStyle = new GUIStyle(GUI.skin.textArea); menuStyle.alignment = TextAnchor.MiddleCenter; menuStyle.fontSize = 14; } if (showEffectName == true && guiShow == false) { GUILayout.BeginArea(new Rect(Screen.width * 0.5f - 150.0f, 20.0f, 300.0f, 30.0f), AddSpacesToName(videoGlitches[guiSelection].GetType().ToString().Replace(@"VideoGlitches.VideoGlitch", string.Empty)).ToUpper(), effectNameStyle); GUILayout.EndArea(); } if (guiShow == false) { return; } GUILayout.BeginHorizontal("box", GUILayout.Width(Screen.width)); { GUILayout.Space(guiMargen); if (GUILayout.Button("MENU", menuStyle, GUILayout.Width(80.0f)) == true) { menuOpen = !menuOpen; } GUILayout.FlexibleSpace(); if (GUILayout.Button("<<<", menuStyle) == true) { slideEffectTime = 0.0f; if (guiSelection > 0) { guiSelection--; } else { guiSelection = videoGlitches.Count - 1; } Event.current.Use(); } GUI.contentColor = Color.white; GUILayout.Label(AddSpacesToName(videoGlitches[guiSelection].GetType().ToString().Replace(@"VideoGlitches.VideoGlitch", string.Empty)).ToUpper(), menuStyle, GUILayout.Width(200.0f)); if (GUILayout.Button(">>>", menuStyle) == true) { slideEffectTime = 0.0f; if (guiSelection < videoGlitches.Count - 1) { guiSelection++; } else { guiSelection = 0; } } GUILayout.FlexibleSpace(); if (fps < 30.0f) { GUI.contentColor = Color.yellow; } else if (fps < 15.0f) { GUI.contentColor = Color.red; } else { GUI.contentColor = Color.green; } GUILayout.Label(fps.ToString("000"), menuStyle, GUILayout.Width(40.0f)); GUI.contentColor = Color.white; GUILayout.Space(guiMargen); } GUILayout.EndHorizontal(); // Update for (int i = 0; i < videoGlitches.Count; ++i) { ImageEffectBase imageEffect = videoGlitches[i]; if (guiSelection == i && imageEffect.enabled == false) { imageEffect.enabled = true; SetCustomParameters(imageEffect); } if (imageEffect.enabled == true && guiSelection != i) { imageEffect.enabled = false; } } if (menuOpen == true) { GUILayout.BeginVertical("box", GUILayout.Width(guiWidth)); { GUILayout.Space(guiMargen); // Cideo Glitches. if (videoGlitches.Count > 0) { scrollPosition = GUILayout.BeginScrollView(scrollPosition, "box"); { int effectChanged = -1; // Draw for (int i = 0; i < videoGlitches.Count; ++i) { ImageEffectBase imageEffect = videoGlitches[i]; GUILayout.BeginHorizontal(); { if (imageEffect.enabled == true) { GUILayout.BeginVertical("box"); } bool enableChanged = GUILayout.Toggle(imageEffect.enabled, guiTab + imageEffect.GetType().ToString().Replace(@"VideoGlitches.VideoGlitch", string.Empty)); if (enableChanged != imageEffect.enabled) { effectChanged = i; } if (imageEffect.enabled == true) { DrawCommonControls(imageEffect); DrawCustomControls(imageEffect); GUILayout.EndVertical(); } } GUILayout.EndHorizontal(); GUILayout.Space(guiMargen * 0.5f); } // Update for (int i = 0; i < videoGlitches.Count; ++i) { ImageEffectBase imageEffect = videoGlitches[i]; if (effectChanged == i) { imageEffect.enabled = !imageEffect.enabled; if (imageEffect.enabled == true) { guiSelection = i; } } if (imageEffect.enabled == true && guiSelection != i) { imageEffect.enabled = false; } } } GUILayout.EndScrollView(); } else { GUILayout.Label("No 'Video Glitches' found."); } GUILayout.FlexibleSpace(); GUILayout.BeginVertical("box"); { GUILayout.Label("F1 - Hide/Show gui."); GUILayout.Label("PageUp\nPageDown - Change effects."); } GUILayout.EndVertical(); GUILayout.Space(guiMargen); if (Debug.isDebugBuild == true && GUILayout.Button(consoleShow ? "Close console" : "Open console") == true) { consoleShow = !consoleShow; scrollLog.y = Mathf.Infinity; } if (GUILayout.Button(@"Open Web") == true) { Application.OpenURL(@"http://www.ibuprogames.com/2015/07/02/video-glitches/ "); } #if !UNITY_WEBPLAYER if (GUILayout.Button(@"Quit") == true) { Application.Quit(); } #endif } GUILayout.EndVertical(); // Log console if (consoleShow == true) { GUILayout.BeginVertical("box", GUILayout.Width(Screen.width), GUILayout.Height(Screen.height / 4)); { scrollLog = GUILayout.BeginScrollView(scrollLog, false, true); { for (int i = 0; i < logs.Count; ++i) { GUILayout.Label(logs[i]); } } GUILayout.EndScrollView(); } GUILayout.EndVertical(); } } }
private void DrawCustomControls(ImageEffectBase imageEffect) { System.Type type = imageEffect.GetType(); if (type == typeof(VintageAmaro)) { VintageAmaro effect = imageEffect as VintageAmaro; if (effect != null) { GUILayout.BeginHorizontal("box"); { GUILayout.Label("Overlay", GUILayout.Width(60)); effect.overlayStrength = GUILayout.HorizontalSlider(effect.overlayStrength, 0.0f, 1.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VintageEarlybird)) { VintageEarlybird effect = imageEffect as VintageEarlybird; if (effect != null) { GUILayout.BeginHorizontal("box"); { GUILayout.Label("Obturation", GUILayout.Width(60)); effect.obturation = GUILayout.HorizontalSlider(effect.obturation, 0.0f, 2.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VintageWalden)) { VintageWalden effect = imageEffect as VintageWalden; if (effect != null) { GUILayout.BeginHorizontal("box"); { GUILayout.Label("Obturation", GUILayout.Width(60)); effect.obturation = GUILayout.HorizontalSlider(effect.obturation, 0.0f, 2.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VintageXProII)) { VintageXProII effect = imageEffect as VintageXProII; if (effect != null) { GUILayout.BeginHorizontal("box"); { GUILayout.Label("Obturation", GUILayout.Width(60)); effect.obturation = GUILayout.HorizontalSlider(effect.obturation, 0.0f, 2.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VintageHudson)) { VintageHudson effect = imageEffect as VintageHudson; if (effect != null) { GUILayout.BeginHorizontal("box"); { GUILayout.Label("Overlay", GUILayout.Width(60)); effect.overlayStrength = GUILayout.HorizontalSlider(effect.overlayStrength, 0.0f, 1.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VintageRise)) { VintageRise effect = imageEffect as VintageRise; if (effect != null) { GUILayout.BeginHorizontal("box"); { GUILayout.Label("Overlay", GUILayout.Width(60)); effect.overlayStrength = GUILayout.HorizontalSlider(effect.overlayStrength, 0.0f, 1.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VintageSutro)) { VintageSutro effect = imageEffect as VintageSutro; if (effect != null) { GUILayout.BeginHorizontal("box"); { GUILayout.Label("Obturation", GUILayout.Width(60)); effect.obturation = GUILayout.HorizontalSlider(effect.obturation, 0.0f, 2.0f); } GUILayout.EndHorizontal(); } } else if (type == typeof(VintageSierra)) { VintageSierra effect = imageEffect as VintageSierra; if (effect != null) { GUILayout.BeginHorizontal("box"); { GUILayout.Label("Overlay", GUILayout.Width(60)); effect.overlayStrength = GUILayout.HorizontalSlider(effect.overlayStrength, 0.0f, 1.0f); } GUILayout.EndHorizontal(); } } }