From 51f1940849843733aa4190211549e5d26b81a1de Mon Sep 17 00:00:00 2001 From: hww Date: Sat, 16 Feb 2019 15:54:10 +0300 Subject: [PATCH] font scale fixed --- Prefabs/Oscilloscope.prefab | 4 +- Scenes/DemoScene.unity | 121 ++++++++++++++++++--------- Src/OscGuiManager.cs | 162 +++++++++++++++++++----------------- Src/OscLabelManager.cs | 1 - 4 files changed, 166 insertions(+), 122 deletions(-) diff --git a/Prefabs/Oscilloscope.prefab b/Prefabs/Oscilloscope.prefab index b0e74c0..06cf739 100644 --- a/Prefabs/Oscilloscope.prefab +++ b/Prefabs/Oscilloscope.prefab @@ -4845,7 +4845,7 @@ Canvas: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1920016341916424} - m_Enabled: 1 + m_Enabled: 0 serializedVersion: 3 m_RenderMode: 0 m_Camera: {fileID: 0} @@ -4888,7 +4888,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1920016341916424} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Name: diff --git a/Scenes/DemoScene.unity b/Scenes/DemoScene.unity index 75bb4a1..5b4a133 100644 --- a/Scenes/DemoScene.unity +++ b/Scenes/DemoScene.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -50,7 +50,6 @@ LightmapSettings: m_BounceScale: 1 m_IndirectOutputScale: 1 m_AlbedoBoost: 1 - m_TemporalCoherenceThreshold: 1 m_EnvironmentLightingMode: 0 m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 0 @@ -117,7 +116,8 @@ NavMeshSettings: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 77496794} @@ -133,7 +133,8 @@ GameObject: RectTransform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 77496793} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} @@ -151,7 +152,8 @@ RectTransform: MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 77496793} m_Enabled: 1 m_EditorHideFlags: 0 @@ -165,7 +167,8 @@ MonoBehaviour: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 170076735} @@ -181,7 +184,8 @@ GameObject: Light: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 170076733} m_Enabled: 1 serializedVersion: 8 @@ -218,7 +222,8 @@ Light: Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 170076733} m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 3, z: 0} @@ -228,110 +233,129 @@ Transform: m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1001 &297087742 -Prefab: +PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 1187740112738316, guid: c3c8d32b6f5808f43971e053741117b0, type: 3} + propertyPath: m_Name + value: Oscilloscope + objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_LocalPosition.z value: 0 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_LocalRotation.x value: -0 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_LocalRotation.y value: -0 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_LocalRotation.z value: -0 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_RootOrder value: 2 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, + type: 3} propertyPath: m_AnchoredPosition.x value: 234 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_AnchoredPosition.y value: 131.5 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_SizeDelta.x value: 900 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_SizeDelta.y value: 640 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_AnchorMin.x value: 0.5 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_AnchorMin.y value: 0.5 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_AnchorMax.x value: 0.5 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_AnchorMax.y value: 0.5 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_Pivot.x value: 0.5 objectReference: {fileID: 0} - target: {fileID: 224170326033462138, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} + type: 3} propertyPath: m_Pivot.y value: 0.5 objectReference: {fileID: 0} m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: c3c8d32b6f5808f43971e053741117b0, type: 2} - m_IsPrefabAsset: 0 + m_SourcePrefab: {fileID: 100100000, guid: c3c8d32b6f5808f43971e053741117b0, type: 3} --- !u!1 &534669902 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 534669905} @@ -348,14 +372,16 @@ GameObject: AudioListener: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 534669902} m_Enabled: 1 --- !u!20 &534669904 Camera: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 534669902} m_Enabled: 1 serializedVersion: 2 @@ -364,6 +390,7 @@ Camera: m_projectionMatrixMode: 1 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} + m_GateFitMode: 2 m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 @@ -395,7 +422,8 @@ Camera: Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 534669902} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 1, z: -10} @@ -408,7 +436,8 @@ Transform: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 573335052} @@ -425,7 +454,8 @@ GameObject: MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 573335049} m_Enabled: 1 m_EditorHideFlags: 0 @@ -443,7 +473,8 @@ MonoBehaviour: MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 573335049} m_Enabled: 1 m_EditorHideFlags: 0 @@ -457,7 +488,8 @@ MonoBehaviour: Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 573335049} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} @@ -469,11 +501,18 @@ Transform: --- !u!223 &676954318 stripped Canvas: m_CorrespondingSourceObject: {fileID: 223655951512232192, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} - m_PrefabInternal: {fileID: 297087742} + type: 3} + m_PrefabInstance: {fileID: 297087742} + m_PrefabAsset: {fileID: 0} --- !u!114 &2108722784 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 114969355926249186, guid: c3c8d32b6f5808f43971e053741117b0, - type: 2} - m_PrefabInternal: {fileID: 297087742} + type: 3} + m_PrefabInstance: {fileID: 297087742} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 512fcec5d1c5a8446bc00944f4a7f213, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Src/OscGuiManager.cs b/Src/OscGuiManager.cs index 458238a..b87d75d 100644 --- a/Src/OscGuiManager.cs +++ b/Src/OscGuiManager.cs @@ -29,11 +29,10 @@ namespace VARP.OSC { /// - /// Simple GUI for oscilloscope + /// Simple GUI for oscilloscope /// public class OscGuiManager : MonoBehaviour { - public Canvas oscCanvas; public Text helpText; public Image keyboard; @@ -42,24 +41,26 @@ public class OscGuiManager : MonoBehaviour /********************************************************** * Main button to activate or deactivate oscilloscope **********************************************************/ - private const KeyCode buttonMain = KeyCode.BackQuote; + + private const KeyCode ButtonMain = KeyCode.F4; /********************************************************** * Channel selection **********************************************************/ - private const KeyCode buttonSelectC1 = KeyCode.Alpha1; - private const KeyCode buttonSelectC2 = KeyCode.Alpha2; - private const KeyCode buttonSelectC3 = KeyCode.Alpha3; - private const KeyCode buttonSelectC4 = KeyCode.Alpha4; - private const KeyCode buttonSelectC5 = KeyCode.Alpha5; - private const KeyCode buttonSelectC6 = KeyCode.Alpha6; - private const KeyCode buttonSelectC7 = KeyCode.Alpha7; - private const KeyCode buttonSelectC8 = KeyCode.Alpha8; - private const KeyCode buttonSelectTrigger = KeyCode.Alpha0; + + private const KeyCode ButtonSelectC1 = KeyCode.Alpha1; + private const KeyCode ButtonSelectC2 = KeyCode.Alpha2; + private const KeyCode ButtonSelectC3 = KeyCode.Alpha3; + private const KeyCode ButtonSelectC4 = KeyCode.Alpha4; + private const KeyCode ButtonSelectC5 = KeyCode.Alpha5; + private const KeyCode ButtonSelectC6 = KeyCode.Alpha6; + private const KeyCode ButtonSelectC7 = KeyCode.Alpha7; + private const KeyCode ButtonSelectC8 = KeyCode.Alpha8; + private const KeyCode ButtonSelectTrigger = KeyCode.Alpha0; // used for changing function buttonSelectCN, when shift pressed // the channel attached as trigger's source - private const KeyCode buttonSelectModifyer1 = KeyCode.LeftShift; - private const KeyCode buttonSelectModifyer2 = KeyCode.LeftShift; + private const KeyCode ButtonSelectModifier1 = KeyCode.LeftShift; + private const KeyCode ButtonSelectModifier2 = KeyCode.LeftShift; // (computed) list of all above private KeyCode[] buttonSelectKeys; @@ -67,59 +68,63 @@ public class OscGuiManager : MonoBehaviour /********************************************************** * Cursors will be used to control magnitude **********************************************************/ + // horizontal position and level - private const KeyCode buttonTimePosPlus = KeyCode.RightArrow; - private const KeyCode buttonTimePosMinus = KeyCode.LeftArrow; - private const KeyCode buttonTimeScalePlus = KeyCode.Equals; - private const KeyCode buttonTimeScaleMinus = KeyCode.Minus; - private const KeyCode buttonLevelPlus = KeyCode.UpArrow; - private const KeyCode buttonLevelMinus = KeyCode.DownArrow; + private const KeyCode ButtonTimePosPlus = KeyCode.RightArrow; + private const KeyCode ButtonTimePosMinus = KeyCode.LeftArrow; + private const KeyCode ButtonTimeScalePlus = KeyCode.Equals; + private const KeyCode ButtonTimeScaleMinus = KeyCode.Minus; + private const KeyCode ButtonLevelPlus = KeyCode.UpArrow; + private const KeyCode ButtonLevelMinus = KeyCode.DownArrow; // channel settings - private const KeyCode buttonPosPlus = KeyCode.UpArrow; - private const KeyCode buttonPosMinus = KeyCode.DownArrow; - private const KeyCode buttonGainPlus = KeyCode.Equals; - private const KeyCode buttonGainMinus = KeyCode.Minus; + private const KeyCode ButtonPosPlus = KeyCode.UpArrow; + private const KeyCode ButtonPosMinus = KeyCode.DownArrow; + private const KeyCode ButtonGainPlus = KeyCode.Equals; + private const KeyCode ButtonGainMinus = KeyCode.Minus; /********************************************************** * Channel settings **********************************************************/ - private const KeyCode buttonChannelAuto = KeyCode.A; - private const KeyCode buttonChannelAcDC = KeyCode.C; - private const KeyCode buttonChannelUnplug = KeyCode.U; - private const KeyCode buttonChannelView = KeyCode.V; + + private const KeyCode ButtonChannelAuto = KeyCode.A; + private const KeyCode ButtonChannelAcDc = KeyCode.C; + private const KeyCode ButtonChannelUnplug = KeyCode.U; + private const KeyCode ButtonChannelView = KeyCode.V; /********************************************************** * Trigger settings **********************************************************/ - private const KeyCode buttonTriggerMode = KeyCode.M; - private const KeyCode buttonTriggerEdge = KeyCode.E; - private const KeyCode buttonTriggerPause = KeyCode.Pause; - private const KeyCode buttonTriggerForceStart = KeyCode.S; + + private const KeyCode ButtonTriggerMode = KeyCode.M; + private const KeyCode ButtonTriggerEdge = KeyCode.E; + private const KeyCode ButtonTriggerPause = KeyCode.Pause; + private const KeyCode ButtonTriggerForceStart = KeyCode.S; /********************************************************** * Grid settings **********************************************************/ - private const KeyCode buttonGridSettings = KeyCode.G; + + private const KeyCode ButtonGridSettings = KeyCode.G; private int gridSetting; public void Initialize(Oscilloscope osc) { oscilloscope = osc; - buttonSelectKeys = new KeyCode[] + buttonSelectKeys = new[] { - buttonSelectC1, buttonSelectC2, buttonSelectC3, buttonSelectC4, - buttonSelectC5, buttonSelectC6, buttonSelectC7, buttonSelectC8, + ButtonSelectC1, ButtonSelectC2, ButtonSelectC3, ButtonSelectC4, + ButtonSelectC5, ButtonSelectC6, ButtonSelectC7, ButtonSelectC8 }; SelectChannel(OscChannel.Name.C1); UpdateHelp(); - IsVisible = true; + IsVisible = false; } void Update() { // -- Test main button -- - var main = Input.GetKeyDown(buttonMain); + var main = Input.GetKeyDown(ButtonMain); if (IsVisible) { var trigger = oscilloscope.trigger; @@ -135,13 +140,13 @@ void Update() else if (isInFocus) { // select channel - if (Input.GetKeyDown(buttonSelectTrigger)) + if (Input.GetKeyDown(ButtonSelectTrigger)) { SelectTriggerChannel(); } else { - var shift = Input.GetKey(buttonSelectModifyer1) || Input.GetKey(buttonSelectModifyer2); + var shift = Input.GetKey(ButtonSelectModifier1) || Input.GetKey(ButtonSelectModifier2); for (var i = 0; i < buttonSelectKeys.Length; i++) { if (Input.GetKeyDown(buttonSelectKeys[i])) @@ -157,18 +162,18 @@ void Update() } // global evens and buttons - if (Input.GetKeyDown(buttonTriggerPause)) + if (Input.GetKeyDown(ButtonTriggerPause)) trigger.Pause = !trigger.Pause; - else if (Input.GetKeyDown(buttonTriggerForceStart)) + else if (Input.GetKeyDown(ButtonTriggerForceStart)) trigger.ForceTrigger(); // -- trigger control -- - else if (Input.GetKeyDown(buttonTriggerMode)) + else if (Input.GetKeyDown(ButtonTriggerMode)) trigger.Mode = GetNextEnum(trigger.Mode); - else if (Input.GetKeyDown(buttonTriggerEdge)) + else if (Input.GetKeyDown(ButtonTriggerEdge)) trigger.Edge = GetNextEnum(trigger.Edge); - else if (Input.GetKeyDown(buttonGridSettings)) + else if (Input.GetKeyDown(ButtonGridSettings)) { gridSetting++; oscilloscope.grid.DrawGrid = (gridSetting & 1) > 0; @@ -179,17 +184,17 @@ void Update() if (selectedChannel == null) { // Joy pad control - if (Input.GetKeyDown(buttonTimeScalePlus)) + if (Input.GetKeyDown(ButtonTimeScalePlus)) trigger.SecondsDivisionPlus(); - else if (Input.GetKeyDown(buttonTimeScaleMinus)) + else if (Input.GetKeyDown(ButtonTimeScaleMinus)) trigger.SecondsDivisionMinus(); - else if (Input.GetKeyDown(buttonLevelPlus)) + else if (Input.GetKeyDown(ButtonLevelPlus)) trigger.Level += 0.5f; - else if (Input.GetKeyDown(buttonLevelMinus)) + else if (Input.GetKeyDown(ButtonLevelMinus)) trigger.Level -= 0.5f; - else if (Input.GetKeyDown(buttonTimePosPlus)) + else if (Input.GetKeyDown(ButtonTimePosPlus)) trigger.Position += 0.5f; - else if (Input.GetKeyDown(buttonTimePosMinus)) + else if (Input.GetKeyDown(ButtonTimePosMinus)) trigger.Position -= 0.5f; } else @@ -199,23 +204,23 @@ void Update() // ------------------------------------------------------ var channel = SelectedChannel; - if (Input.GetKeyDown(buttonChannelAuto)) + if (Input.GetKeyDown(ButtonChannelAuto)) channel.AutoGain = !channel.AutoGain; - else if (Input.GetKeyDown(buttonChannelAcDC)) + else if (Input.GetKeyDown(ButtonChannelAcDc)) channel.Decoupling = !channel.Decoupling; - else if (Input.GetKeyDown(buttonChannelUnplug)) + else if (Input.GetKeyDown(ButtonChannelUnplug)) channel.Unplug(); - else if (Input.GetKeyDown(buttonChannelView)) + else if (Input.GetKeyDown(ButtonChannelView)) channel.Style = GetNextEnum(channel.Style); // Joy pad control - if (Input.GetKeyDown(buttonPosPlus)) + if (Input.GetKeyDown(ButtonPosPlus)) channel.Position += 0.5f; - else if (Input.GetKeyDown(buttonPosMinus)) + else if (Input.GetKeyDown(ButtonPosMinus)) channel.Position -= 0.5f; - else if (Input.GetKeyDown(buttonGainPlus)) + else if (Input.GetKeyDown(ButtonGainPlus)) channel.GainPlus(); - else if (Input.GetKeyDown(buttonGainMinus)) + else if (Input.GetKeyDown(ButtonGainMinus)) channel.GainMinus(); } } @@ -237,10 +242,11 @@ void Update() public bool IsVisible { - get { return oscCanvas.enabled; } + get => oscCanvas.enabled; set { oscCanvas.enabled = isInFocus = value; + oscCanvas.scaleFactor = 1f; updateHelp = true; } } @@ -252,12 +258,12 @@ public bool IsVisible private bool isInFocus; //< TRUE means inputs tested /// - /// When oscilloscope is in focus the oscilloscope controlled by keys. - /// In other case the keyboard ignored. + /// When oscilloscope is in focus the oscilloscope controlled by keys. + /// In other case the keyboard ignored. /// public bool IsInFocus { - get { return isInFocus; } + get => isInFocus; set { keyboard.enabled = isInFocus = value; @@ -281,25 +287,25 @@ void UpdateHelp() if (!isInFocus) { // not in focus - helpText.text = toFocusHelp; + helpText.text = ToFocusHelp; } else { var help = ""; if (selectedChannel == null) { - // selected trigger channgel + // selected trigger channel help += "TRIGGER:\n"; - help += triggerHelp; + help += TriggerHelp; } else { // selected channel help += $"CHANNEL: {selectedChannel.channelName}\n"; - help += channelHelp; + help += ChannelHelp; } // display this help in any case - help += persistHelp; + help += PersistHelp; helpText.text = help; } } @@ -309,10 +315,10 @@ void UpdateHelp() // The text messages for help // ============================================================================================================= - private readonly string toFocusHelp = "` activate keyboard shortcuts\n"; - private readonly string channelHelp = "1,2,..,8 select input\nA auto, C coupling\nU unplug, V view\nUP,DOWN position\n+,- gain\n"; - private readonly string triggerHelp = "SHIFT+1,2,..,8 select input\nM mode, E edge\nUP,DOWN level\nLEFT,RIGHT time position\n+,- time scale"; - private readonly string persistHelp = "PAUSE pause, S force start\n"; + private const string ToFocusHelp = "` activate keyboard shortcuts\n"; + private const string ChannelHelp = "1,2,..,8 select input\nA auto, C coupling\nU unplug, V view\nUP,DOWN position\n+,- gain\n"; + private const string TriggerHelp = "SHIFT+1,2,..,8 select input\nM mode, E edge\nUP,DOWN level\nLEFT,RIGHT time position\n+,- time scale"; + private const string PersistHelp = "PAUSE pause, S force start\n"; // ============================================================================================================= // Current channel can be used for keyboard shortcuts @@ -346,24 +352,24 @@ public void SelectTriggerChannel() // Increment/Decrement enum value // ============================================================================================================= - public T GetNextEnum(T src) where T : struct + private T GetNextEnum(T src) where T : struct { if (!typeof(T).IsEnum) - throw new System.ArgumentException(string.Format("Argument {0} is not an Enum", typeof(T).FullName)); + throw new System.ArgumentException($"Argument {typeof(T).FullName} is not an Enum"); T[] values = (T[]) System.Enum.GetValues(src.GetType()); var j = System.Array.IndexOf(values, src) + 1; - return (values.Length == j) ? values[0] : values[j]; + return values.Length == j ? values[0] : values[j]; } - public T GetPrevEnum(T src) where T : struct + private T GetPrevEnum(T src) where T : struct { if (!typeof(T).IsEnum) - throw new System.ArgumentException(string.Format("Argument {0} is not an Enum", typeof(T).FullName)); + throw new System.ArgumentException($"Argument {typeof(T).FullName} is not an Enum"); T[] values = (T[]) System.Enum.GetValues(src.GetType()); var j = System.Array.IndexOf(values, src) - 1; - return (0 > j) ? values[values.Length - 1] : values[j]; + return 0 > j ? values[values.Length - 1] : values[j]; } } } diff --git a/Src/OscLabelManager.cs b/Src/OscLabelManager.cs index 0949264..923ef62 100644 --- a/Src/OscLabelManager.cs +++ b/Src/OscLabelManager.cs @@ -54,7 +54,6 @@ public OscChannelLabel SpawnLabel() { if (freeLabels.Count == 0) throw new SystemException("OscLabelManager.SpawnLabel reached limit if labels quantity."); - var last = freeLabels.Count - 1; var label = freeLabels[last]; freeLabels.RemoveAt(freeLabels.Count - 1);