/// <inheritdoc /> protected override void Bind(ShortcutBinding binding) { var input = new KeyBinding(command, binding.Key, binding.Modifiers); inputBindings.Add(input); mapping.Add(binding, input); }
async static public void TriggerShortcut(string shortcut) { IShortcutManager manager = ShortcutManager.instance; List <string> shortcuts = manager.GetAvailableShortcutIds().ToList(); if (!shortcuts.Contains(shortcut)) { Debug.LogWarning($"{shortcut} is not a shortcut!"); return; } if (manager.GetAvailableProfileIds().Contains(temporaryProfile)) { manager.DeleteProfile(temporaryProfile); } manager.CreateProfile(temporaryProfile); string previousProfile = manager.activeProfileId; manager.activeProfileId = temporaryProfile; manager.ClearShortcutOverride(shortcut); var binding = new ShortcutBinding(new KeyCombination(KeyCode.F12)); manager.RebindShortcut(shortcut, binding); EditorWindow.focusedWindow.SendEvent(Event.KeyboardEvent("F12")); await Task.Delay(100); manager.activeProfileId = previousProfile; manager.DeleteProfile(temporaryProfile); }
private void SetBinding(ShortcutBinding binding, int index) { if (index < shortcut.Bindings.Count) { if (binding == null) { shortcut.Bindings.RemoveAt(index); } else { shortcut.Bindings[index] = binding; } } else if (index == shortcut.Bindings.Count) { if (binding != null) { shortcut.Bindings.Add(binding); } } else { throw new InvalidOperationException("Index out of valid range."); } }
/// <inheritdoc /> protected override void Unbind(ShortcutBinding binding) { if (!mapping.TryGetValue(binding, out var input)) { return; } mapping.Remove(binding); inputBindings.Remove(input); }
static void UpdateBindingAndTooltip() { ShortcutManager.instance.shortcutBindingChanged -= OnShortcutBindingChanged; ShortcutManager.instance.shortcutBindingChanged += OnShortcutBindingChanged; if (!IsShortcutAvailable()) { return; } s_ShortcutBinding = ShortcutManager.instance.GetShortcutBinding(k_SearchAllShortcutName); Styles.gotoSearch.tooltip = L10n.Tr($"Open in Search ({s_ShortcutBinding})"); }
/// <summary> /// Initializes a new instance of the attribute. /// </summary> /// <param name="toolName">The tool that defines this shortcut.</param> /// <param name="id">The shortcut unique ID.</param> /// <param name="defaultBinding">Default keyboard mapping.</param> /// <param name="isClutch">True if the shortcut is a clutch.</param> /// <param name="onlyOnPlatforms">An array of platforms on which the shortcut is defined. If null, this parameter has no effect.</param> /// <param name="excludedPlatforms">An array of platforms on which the shortcut is not defined. If null, this parameter has no effect.</param> public ToolShortcutEventAttribute( string toolName, string id, ShortcutBinding defaultBinding, bool isClutch = false, RuntimePlatform[] onlyOnPlatforms = null, RuntimePlatform[] excludedPlatforms = null) { ToolName = toolName; Identifier = id; DefaultBinding = defaultBinding; DisplayName = Identifier; IsClutch = isClutch; OnlyOnPlatforms = onlyOnPlatforms; ExcludedPlatforms = excludedPlatforms; }
//---------------------------------------------------------------------------------------------------------------------- private void DrawUpdateRenderCacheGUI() { ShortcutBinding updateRenderCacheShortcut = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_UPDATE_RENDER_CACHE); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { RenderCachePlayableAssetEditorConfig editorConfig = m_asset.GetEditorConfig(); bool captureAllFrames = EditorGUILayout.Toggle("Capture All Frames", editorConfig.GetCaptureAllFrames()); editorConfig.SetCaptureAllFrames(captureAllFrames); EditorGUI.BeginDisabledGroup(captureAllFrames); ++EditorGUI.indentLevel; int captureStartFrame = Math.Max(0, editorConfig.GetCaptureStartFrame()); int captureEndFrame = editorConfig.GetCaptureEndFrame(); if (captureEndFrame < 0) { captureEndFrame = TimelineUtility.CalculateNumFrames(TimelineEditor.selectedClip); } editorConfig.SetCaptureStartFrame(EditorGUILayout.IntField("From", captureStartFrame)); editorConfig.SetCaptureEndFrame(EditorGUILayout.IntField("To", captureEndFrame)); --EditorGUI.indentLevel; EditorGUI.EndDisabledGroup(); GUILayout.Space(10); if (GUILayout.Button($"Update Render Cache ({updateRenderCacheShortcut})")) { PlayableDirector director = TimelineEditor.inspectedDirector; if (null == director) { EditorUtility.DisplayDialog("Streaming Image Sequence", "PlayableAsset is not loaded in scene. Please load the correct scene before doing this operation.", "Ok"); return; } //Loop time EditorCoroutineUtility.StartCoroutine(UpdateRenderCacheCoroutine(director, m_asset), this); } } }
//---------------------------------------------------------------------------------------------------------------------- public override void OnInspectorGUI() { ShortcutBinding useFrameShortcut = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_TOGGLE_FRAME_MARKER); bool prevUseFrame = m_assets[0].IsFrameUsed(); bool useFrame = EditorGUILayout.Toggle($"Use Frame ({useFrameShortcut})", prevUseFrame); if (useFrame != prevUseFrame) { //Set all selected objects foreach (FrameMarker m in m_assets) { SetMarkerValueByContext(m, useFrame); } } //Only show lock and edit for RenderCachePlayableAsset foreach (FrameMarker frameMarker in m_assets) { SISPlayableFrame playableFrame = frameMarker.GetOwner(); RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>(); if (null == playableAsset) { return; } } //m_assets only contain RenderCachePlayableAsset at this point ShortcutBinding lockAndEditShortcut = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_LOCK_AND_EDIT_FRAME); if (GUILayout.Button($"Lock and Edit ({lockAndEditShortcut})")) { foreach (FrameMarker frameMarker in m_assets) { SISPlayableFrame playableFrame = frameMarker.GetOwner(); RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>(); Assert.IsNotNull(playableAsset); LockAndEditPlayableFrame(playableFrame, playableAsset); } } }
//---------------------------------------------------------------------------------------------------------------------- public override void OnInspectorGUI() { //View resolution Vector2 res = ViewEditorUtility.GetMainGameViewSize(); EditorGUILayout.LabelField("Resolution (Modify GameView size to change)"); ++EditorGUI.indentLevel; EditorGUILayout.LabelField("Width", res.x.ToString(CultureInfo.InvariantCulture)); EditorGUILayout.LabelField("Height", res.y.ToString(CultureInfo.InvariantCulture)); --EditorGUI.indentLevel; EditorGUILayout.Space(15f); //Check if the asset is actually inspected if (null != TimelineEditor.selectedClip && TimelineEditor.selectedClip.asset != m_asset) { return; } ValidateAssetFolder(); string prevFolder = m_asset.GetFolder(); string newFolder = InspectorUtility.ShowFolderSelectorGUI("Cache Output Folder", "Select Folder", prevFolder, AssetEditorUtility.NormalizeAssetPath ); if (newFolder != prevFolder) { m_asset.SetFolder(AssetEditorUtility.NormalizeAssetPath(newFolder)); GUIUtility.ExitGUI(); } TimelineClipSISData timelineClipSISData = m_asset.GetBoundTimelineClipSISData(); if (null == timelineClipSISData) { return; } GUILayout.Space(15); //Capture Selected Frames using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { ShowCaptureSelectedFramesGUI(TimelineEditor.selectedClip, timelineClipSISData); ShowLockFramesGUI(TimelineEditor.selectedClip, timelineClipSISData); } ShortcutBinding updateRenderCacheShortcut = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_UPDATE_RENDER_CACHE); GUILayout.Space(15); if (GUILayout.Button($"Update Render Cache ({updateRenderCacheShortcut})")) { PlayableDirector director = TimelineEditor.inspectedDirector; if (null == director) { EditorUtility.DisplayDialog("Streaming Image Sequence", "PlayableAsset is not loaded in scene. Please load the correct scene before doing this operation.", "Ok"); return; } //Loop time EditorCoroutineUtility.StartCoroutine(UpdateRenderCacheCoroutine(director, m_asset), this); } }
/// <inheritdoc /> protected override void Unbind(ShortcutBinding binding) { onUnbind(binding); }
//---------------------------------------------------------------------------------------------------------------------- public override void OnInspectorGUI() { ShortcutBinding useFrameShortcut = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_TOGGLE_FRAME_MARKER); bool prevUseFrame = m_assets[0].IsFrameUsed(); bool useFrame = EditorGUILayout.Toggle($"Use Frame ({useFrameShortcut})", prevUseFrame); if (useFrame != prevUseFrame) { //Set all selected objects foreach (FrameMarker m in m_assets) { SetMarkerValueByContext(m, useFrame); } } if (1 == m_assets.Length) { SISPlayableFrame playableFrame = m_assets[0].GetOwner(); string prevNote = playableFrame?.GetUserNote(); DrawNoteGUI(prevNote); } else { int numSelectedAssets = m_assets.Length; Assert.IsTrue(numSelectedAssets > 1); SISPlayableFrame firstPlayableFrame = m_assets[0].GetOwner(); //Check invalid PlayableFrame. Perhaps because of unsupported Duplicate operation ? if (null == firstPlayableFrame) { return; } string prevNote = firstPlayableFrame.GetUserNote(); for (int i = 1; i < numSelectedAssets; ++i) { SISPlayableFrame playableFrame = m_assets[i].GetOwner(); if (playableFrame.GetUserNote() != prevNote) { prevNote = "<different notes>"; } } DrawNoteGUI(prevNote); } //Only show lock and edit for RenderCachePlayableAsset //[TODO-Sin: 2020-8-24]: Define capabilities in RenderCachePlayableAsset that defines what is visible foreach (FrameMarker frameMarker in m_assets) { SISPlayableFrame playableFrame = frameMarker.GetOwner(); RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>(); if (null == playableAsset) { return; } } GUILayout.Space(15); //m_assets only contain RenderCachePlayableAsset at this point ShortcutBinding lockAndEditShortcut = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_LOCK_AND_EDIT_FRAME); if (GUILayout.Button($"Lock and Edit ({lockAndEditShortcut})")) { foreach (FrameMarker frameMarker in m_assets) { SISPlayableFrame playableFrame = frameMarker.GetOwner(); RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>(); Assert.IsNotNull(playableAsset); LockAndEditPlayableFrame(playableFrame, playableAsset); } } }
// irrelevant, we check all registered bindings manually protected override void Bind(ShortcutBinding binding) { }
protected abstract void Unbind(ShortcutBinding binding);
public ShortcutEdit() { this.InitializeComponent(); this.binding = this.DataContext as ShortcutBinding; this.keys = new HashSet <Key>(); }