Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace UnityEditor.Timeline.Actions
|
||||
{
|
||||
/// <summary>
|
||||
/// Define the activeness of an action depending on its timeline mode.
|
||||
/// </summary>
|
||||
/// <seealso cref="TimelineModes"/>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class ActiveInModeAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Modes that will be used for activeness of an action.
|
||||
/// </summary>
|
||||
public TimelineModes modes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines in which mode the action will be active.
|
||||
/// </summary>
|
||||
/// <param name="timelineModes">Modes that will define activeness of the action.</param>
|
||||
public ActiveInModeAttribute(TimelineModes timelineModes)
|
||||
{
|
||||
modes = timelineModes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3a784fb721704576b3b4c3a7f3324264
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Timeline.Actions
|
||||
{
|
||||
/// <summary>
|
||||
/// Use this attribute to add a menu item to a context menu.
|
||||
/// Used to indicate path and priority that are auto added to the menu
|
||||
/// (examples can be found on <see href="https://docs.unity3d.com/ScriptReference/MenuItem.html"/>).
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// <code source="../../DocCodeExamples/TimelineAttributesExamples.cs" region="declare-menuEntryAttribute" title="menuEntryAttr"/>
|
||||
/// </example>
|
||||
/// <remarks>
|
||||
/// Unlike Menu item, MenuEntryAttribute doesn't handle shortcuts in the menu name. See <see cref="TimelineShortcutAttribute"/>.
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class MenuEntryAttribute : Attribute
|
||||
{
|
||||
internal readonly int priority;
|
||||
internal readonly string name;
|
||||
internal readonly string subMenuPath;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for Menu Entry Attribute to define information about the menu item for an action.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to the menu. If there is a "/" in the path, it will create one (or multiple) submenu items.</param>
|
||||
/// <param name="priority">Priority to decide where the menu will be positioned in the menu.
|
||||
/// The lower the priority, the higher the menu item will be in the context menu.
|
||||
/// </param>
|
||||
/// <seealso cref="MenuPriority"/>
|
||||
public MenuEntryAttribute(string path = default, int priority = MenuPriority.defaultPriority)
|
||||
{
|
||||
path = path ?? string.Empty;
|
||||
path = L10n.Tr(path);
|
||||
this.priority = priority;
|
||||
|
||||
var index = path.LastIndexOf('/');
|
||||
if (index >= 0)
|
||||
{
|
||||
name = (index == path.Length - 1) ? string.Empty : path.Substring(index + 1);
|
||||
subMenuPath = path.Substring(0, index + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = path;
|
||||
subMenuPath = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6870f707805737429a719f575621041
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
class ShortcutAttribute : Attribute
|
||||
{
|
||||
readonly string m_Identifier;
|
||||
readonly string m_EventCommandName;
|
||||
readonly string m_MenuShortcut;
|
||||
|
||||
public ShortcutAttribute(string identifier)
|
||||
{
|
||||
m_Identifier = identifier;
|
||||
m_EventCommandName = identifier;
|
||||
}
|
||||
|
||||
public ShortcutAttribute(string identifier, string commandName)
|
||||
{
|
||||
m_Identifier = identifier;
|
||||
m_EventCommandName = commandName;
|
||||
}
|
||||
|
||||
public ShortcutAttribute(KeyCode key, ShortcutModifiers modifiers = ShortcutModifiers.None)
|
||||
{
|
||||
m_MenuShortcut = new KeyCombination(key, modifiers).ToMenuShortcutString();
|
||||
}
|
||||
|
||||
public string GetMenuShortcut()
|
||||
{
|
||||
if (m_MenuShortcut != null)
|
||||
return m_MenuShortcut;
|
||||
|
||||
//find the mapped shortcut in the shortcut manager
|
||||
var shortcut = ShortcutIntegration.instance.directory.FindShortcutEntry(m_Identifier);
|
||||
if (shortcut != null && shortcut.combinations.Any())
|
||||
{
|
||||
return KeyCombination.SequenceToMenuString(shortcut.combinations);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public bool MatchesEvent(Event evt)
|
||||
{
|
||||
if (evt.type != EventType.ExecuteCommand)
|
||||
return false;
|
||||
return evt.commandName == m_EventCommandName;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
|
||||
class ShortcutPlatformOverrideAttribute : ShortcutAttribute
|
||||
{
|
||||
RuntimePlatform platform { get; }
|
||||
|
||||
public ShortcutPlatformOverrideAttribute(RuntimePlatform platform, KeyCode key, ShortcutModifiers modifiers = ShortcutModifiers.None)
|
||||
: base(key, modifiers)
|
||||
{
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public bool MatchesCurrentPlatform()
|
||||
{
|
||||
return Application.platform == platform;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c50a694a8232898498c1cdd47ce9873f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,24 @@
|
|||
using UnityEditor.ShortcutManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Timeline.Actions
|
||||
{
|
||||
/// <summary>
|
||||
/// Use this attribute to make an action work with the shortcut system.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// TimelineShortcutAttribute needs to be added to a static method.
|
||||
/// <code source="../../DocCodeExamples/TimelineAttributesExamples.cs" region="declare-timelineShortcutAttr" title="TimelineShortcutAttr"/>
|
||||
/// </example>
|
||||
public class TimelineShortcutAttribute : ShortcutManagement.ShortcutAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// TimelineShortcutAttribute Constructor
|
||||
/// </summary>
|
||||
/// <param name="id">Id to register the shortcut. It will automatically be prefix by 'Timeline/' in order to be in the 'Timeline' section of the shortcut manager.</param>
|
||||
/// <param name="defaultKeyCode">Optional key code for default binding.</param>
|
||||
/// <param name="defaultShortcutModifiers">Optional shortcut modifiers for default binding.</param>
|
||||
public TimelineShortcutAttribute(string id, KeyCode defaultKeyCode, ShortcutModifiers defaultShortcutModifiers = ShortcutModifiers.None)
|
||||
: base("Timeline/" + id, typeof(TimelineWindow), defaultKeyCode, defaultShortcutModifiers) {}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bbfc068399dbc814d96ebf991a1e5764
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue