From 8001cb71b534856a09e8ded72bdbf292f97d8d3d Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Wed, 25 Apr 2018 15:46:41 +0000 Subject: [PATCH 01/13] Unity 2018.2.0b2 C# reference source code --- .../AnimationWindow/AnimationRecording.cs | 17 +- .../AssetDatabase/AssetDatabaseSearching.cs | 39 ++- .../AssetPipeline/TextureImporter.bindings.cs | 1 + .../TextureImporterTypes.bindings.cs | 10 + Editor/Mono/BuildPlayerWindow.cs | 2 +- Editor/Mono/EditorApplication.bindings.cs | 14 +- Editor/Mono/EditorGUI.cs | 66 +++++ Editor/Mono/GUI/AppStatusBar.cs | 16 +- .../AssetOrGameObjectTreeViewDragging.cs | 6 +- .../GUI/TreeView/AssetsTreeViewDataSource.cs | 235 ++++++++++++--- Editor/Mono/GUI/TreeView/AssetsTreeViewGUI.cs | 9 + .../Inspector/LightProbeProxyVolumeEditor.cs | 6 + .../LookDevView/CameraControllerStandard.cs | 3 +- Editor/Mono/ObjectListArea.cs | 6 +- Editor/Mono/ObjectListLocalGroup.cs | 6 +- Editor/Mono/ProjectBrowser.cs | 270 +++++++++++++++--- Editor/Mono/ProjectBrowserColumnOne.cs | 77 ++++- .../ProjectWindow/CachedFilteredHierachy.cs | 45 ++- .../Mono/ProjectWindow/ProjectWindowUtil.cs | 2 +- Editor/Mono/SceneView/CameraFlyModeContext.cs | 66 ++++- Editor/Mono/SceneView/SceneView.cs | 1 - Editor/Mono/SceneView/SceneViewMotion.cs | 109 +------ .../AudioPlayableOutput.bindings.cs | 12 + .../Manipulators/EdgeDragHelper.cs | 28 +- .../Editor/Managed/PackageInfo.cs | 5 + .../Editor/Managed/PackageManager.cs | 4 +- README.md | 2 +- Runtime/Export/GraphicsEnums.cs | 6 + .../Export/LightProbeProxyVolume.bindings.cs | 2 + 29 files changed, 801 insertions(+), 264 deletions(-) diff --git a/Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs b/Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs index eed18e1814..1759bb7fa6 100644 --- a/Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs +++ b/Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs @@ -608,8 +608,10 @@ static private void ProcessAnimatorModifications(IAnimationRecordingState state, Animator animator = root.GetComponent(); bool isHuman = animator != null ? animator.isHuman : false; - bool hasRootMotion = animator != null ? animator.hasRootMotion : false; - bool applyRootMotion = animator != null ? animator.applyRootMotion : false; + + // timeline root motion scale revert + // bool hasRootMotion = animator != null ? animator.hasRootMotion : false; + // bool applyRootMotion = animator != null ? animator.applyRootMotion : false; // process animator positions List discardListPos = new List(); @@ -628,7 +630,10 @@ static private void ProcessAnimatorModifications(IAnimationRecordingState state, continue; bool isRootTransform = root.transform == target; - bool isRootMotion = (isHuman || hasRootMotion || applyRootMotion) && isRootTransform; + // timeline root motion scale revert + // bool isRootMotion = (isHuman || hasRootMotion || applyRootMotion) && isRootTransform; + bool isRootMotion = false; + bool isHumanBone = isHuman && !isRootTransform && animator.IsBoneTransform(target); if (isHumanBone) @@ -677,7 +682,11 @@ static private void ProcessAnimatorModifications(IAnimationRecordingState state, continue; bool isRootTransform = root.transform == target; - bool isRootMotion = (isHuman || hasRootMotion || applyRootMotion) && isRootTransform; + + // timeline root motion scale revert + // bool isRootMotion = (isHuman || hasRootMotion || applyRootMotion) && isRootTransform; + bool isRootMotion = false; + bool isHumanBone = isHuman && !isRootTransform && animator.IsBoneTransform(target); if (isHumanBone) diff --git a/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs b/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs index 9d6bd99197..f8f2f6cf3c 100644 --- a/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs +++ b/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs @@ -22,12 +22,15 @@ public static string[] FindAssets(string filter, string[] searchInFolders) SearchFilter searchFilter = new SearchFilter(); SearchUtility.ParseSearchString(filter, searchFilter); if (searchInFolders != null) + { searchFilter.folders = searchInFolders; + searchFilter.searchArea = SearchFilter.SearchArea.SelectedFolders; + } return FindAssets(searchFilter); } - private static string[] FindAssets(SearchFilter searchFilter) + internal static string[] FindAssets(SearchFilter searchFilter) { return FindAllAssets(searchFilter).Select(property => property.guid).ToArray(); } @@ -41,7 +44,7 @@ internal static IEnumerable FindAllAssets(SearchFilter search internal static IEnumerator EnumerateAllAssets(SearchFilter searchFilter) { - if (searchFilter.folders != null && searchFilter.folders.Length > 0) + if (searchFilter.folders != null && searchFilter.folders.Length > 0 && searchFilter.searchArea == SearchFilter.SearchArea.SelectedFolders) return FindInFolders(searchFilter, p => p); return FindEverywhere(searchFilter, p => p); @@ -49,15 +52,30 @@ internal static IEnumerator EnumerateAllAssets(SearchFilter s private static IEnumerator FindInFolders(SearchFilter searchFilter, Func selector) { - foreach (string folderPath in searchFilter.folders) + var folders = new List(); + folders.AddRange(searchFilter.folders); + if (folders.Remove(PackageManager.Folders.GetPackagesMountPoint())) + { + var packages = PackageManager.Packages.GetAll(); + foreach (var package in packages) + { + if (package.source == PackageManager.PackageSource.BuiltIn) + continue; + + if (!folders.Contains(package.assetPath)) + folders.Add(package.assetPath); + } + } + + foreach (string folderPath in folders) { var folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folderPath); var rootPath = "Assets"; - var pathComponents = folderPath.Split('/'); // Find the right rootPath if folderPath is part of a package - if (pathComponents.Length > 1 && pathComponents[0] == UnityEditor.PackageManager.Folders.GetPackagesMountPoint()) - rootPath = pathComponents[0] + "/" + pathComponents[1]; + var packageInfo = PackageManager.Packages.GetForAssetPath(folderPath); + if (packageInfo != null) + rootPath = packageInfo.assetPath; // Set empty filter to ensure we search all assets to find folder var property = new HierarchyProperty(rootPath); @@ -84,7 +102,14 @@ private static IEnumerator FindEverywhere(SearchFilter searchFilter, Func< { var rootPaths = new List(); rootPaths.Add("Assets"); - rootPaths.AddRange(UnityEditor.PackageManager.Folders.GetPackagesPaths()); + var packages = PackageManager.Packages.GetAll(); + foreach (var package in packages) + { + if (package.source == PackageManager.PackageSource.BuiltIn) + continue; + + rootPaths.Add(package.assetPath); + } foreach (var rootPath in rootPaths) { var property = new HierarchyProperty(rootPath); diff --git a/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs b/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs index 48cdb6f962..27b6e32588 100644 --- a/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs +++ b/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs @@ -209,6 +209,7 @@ public void SetPlatformTextureSettings(string platform, int maxTextureSize, Text public extern int mipmapFadeDistanceStart { get; set; } // Mip level where texture is faded out completely. public extern int mipmapFadeDistanceEnd { get; set; } + public extern bool pushPullDilation { get; set; } // Should mip maps be generated with gamma correction? [Obsolete("generateMipsInLinearSpace Property deprecated. Mipmaps are always generated in linear space.")] diff --git a/Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs b/Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs index 5bf982c219..be7349582b 100644 --- a/Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs +++ b/Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs @@ -106,6 +106,9 @@ public sealed partial class TextureImporterSettings [SerializeField] int m_SingleChannelComponent; + [SerializeField] + int m_PushPullDilation; + // memory layout of these is in TextureSettings.h [SerializeField] [NativeName("m_TextureSettings.m_FilterMode")] @@ -255,6 +258,13 @@ public TextureImporterSingleChannelComponent singleChannelComponent get {return (TextureImporterSingleChannelComponent)m_SingleChannelComponent; } set { m_SingleChannelComponent = (int)value; } } + + public bool pushPullDilation + { + get { return m_PushPullDilation != 0; } + set { m_PushPullDilation = value ? 1 : 0; } + } + public bool readable { get {return m_IsReadable != 0; } diff --git a/Editor/Mono/BuildPlayerWindow.cs b/Editor/Mono/BuildPlayerWindow.cs index b25aabfec7..309b1b9d7e 100644 --- a/Editor/Mono/BuildPlayerWindow.cs +++ b/Editor/Mono/BuildPlayerWindow.cs @@ -871,7 +871,7 @@ private static void GUIBuildButtons(IBuildWindowExtension buildWindowExtension, GUI.enabled = enableBuildButton; if (GUILayout.Button(buildButton, GUILayout.Width(Styles.kButtonWidth))) { - CallBuildMethods(true, BuildOptions.ShowBuiltPlayer | BuildOptions.StrictMode); + CallBuildMethods(true, BuildOptions.ShowBuiltPlayer); GUIUtility.ExitGUI(); } // Build and Run button diff --git a/Editor/Mono/EditorApplication.bindings.cs b/Editor/Mono/EditorApplication.bindings.cs index 4d7f648774..9b6aed47b2 100644 --- a/Editor/Mono/EditorApplication.bindings.cs +++ b/Editor/Mono/EditorApplication.bindings.cs @@ -105,7 +105,15 @@ internal static extern bool useLibmonoBackendForIl2cpp // Prevents loading of assemblies when it is inconvenient. [StaticAccessor("GetApplication()", StaticAccessorType.Dot)] - public static extern void LockReloadAssemblies(); + public static extern void LockReloadAssemblies(); + + // Must be called after LockReloadAssemblies, to reenable loading of assemblies. + [StaticAccessor("GetApplication()", StaticAccessorType.Dot)] + public static extern void UnlockReloadAssemblies(); + + // Check if assemblies are unlocked. + [StaticAccessor("GetApplication()", StaticAccessorType.Dot)] + internal static extern bool CanReloadAssemblies(); // Invokes the menu item in the specified path. public static extern bool ExecuteMenuItem(string menuItemPath); @@ -116,10 +124,6 @@ internal static extern bool useLibmonoBackendForIl2cpp // Like ExecuteMenuItem, but applies action to specified GameObjects if the menu action supports it. internal static extern bool ExecuteMenuItemWithTemporaryContext(string menuItemPath, Object[] objects); - // Must be called after LockReloadAssemblies, to reenable loading of assemblies. - [StaticAccessor("GetApplication()", StaticAccessorType.Dot)] - public static extern void UnlockReloadAssemblies(); - // Path to the Unity editor contents folder (RO) [ThreadAndSerializationSafe] public static extern string applicationContentsPath diff --git a/Editor/Mono/EditorGUI.cs b/Editor/Mono/EditorGUI.cs index 09efd6d368..f896191310 100644 --- a/Editor/Mono/EditorGUI.cs +++ b/Editor/Mono/EditorGUI.cs @@ -626,6 +626,58 @@ private static void Draw4(Rect position, GUIContent content, float offset, float style.Draw(position, content, false, false, false, false); } + static bool MightBePrintableKey(Event evt) + { + if (evt.command || evt.control) + return false; + if (evt.keyCode >= KeyCode.Mouse0 && evt.keyCode <= KeyCode.Mouse6) + return false; + if (evt.keyCode >= KeyCode.JoystickButton0 && evt.keyCode <= KeyCode.Joystick8Button19) + return false; + if (evt.keyCode >= KeyCode.F1 && evt.keyCode <= KeyCode.F15) + return false; + switch (evt.keyCode) + { + case KeyCode.AltGr: + case KeyCode.Backspace: + case KeyCode.CapsLock: + case KeyCode.Clear: + case KeyCode.Delete: + case KeyCode.DownArrow: + case KeyCode.End: + case KeyCode.Escape: + case KeyCode.Help: + case KeyCode.Home: + case KeyCode.Insert: + case KeyCode.LeftAlt: + case KeyCode.LeftArrow: + case KeyCode.LeftCommand: // same as LeftApple + case KeyCode.LeftControl: + case KeyCode.LeftShift: + case KeyCode.LeftWindows: + case KeyCode.Menu: + case KeyCode.Numlock: + case KeyCode.PageDown: + case KeyCode.PageUp: + case KeyCode.Pause: + case KeyCode.Print: + case KeyCode.RightAlt: + case KeyCode.RightArrow: + case KeyCode.RightCommand: // same as RightApple + case KeyCode.RightControl: + case KeyCode.RightShift: + case KeyCode.RightWindows: + case KeyCode.ScrollLock: + case KeyCode.SysReq: + case KeyCode.UpArrow: + return false; + case KeyCode.None: + return evt.character != 0; + default: + return true; + } + } + // Should we select all text from the current field when the mouse goes up? // (We need to keep track of this to support both SwipeSelection & initial click selects all) internal static string DoTextField(RecycledTextEditor editor, int id, Rect position, string text, GUIStyle style, string allowedletters, out bool changed, bool reset, bool multiline, bool passwordField) @@ -889,6 +941,7 @@ internal static string DoTextField(RecycledTextEditor editor, int id, Rect posit break; case EventType.KeyDown: + var nonPrintableTab = false; if (GUIUtility.keyboardControl == id) { char c = evt.character; @@ -951,6 +1004,10 @@ internal static string DoTextField(RecycledTextEditor editor, int id, Rect posit mayHaveChanged = true; } } + else + { + nonPrintableTab = true; + } } else if (c == 25 || c == 27) { @@ -977,6 +1034,15 @@ internal static string DoTextField(RecycledTextEditor editor, int id, Rect posit } } } + // consume Keycode events that might result in a printable key so they aren't passed on to other controls or shortcut manager later + if ( + editor.IsEditingControl(id) && + MightBePrintableKey(evt) && + !nonPrintableTab // only consume tabs that actually result in a character (above) so we don't disable tabbing between keyboard controls + ) + { + evt.Use(); + } } break; diff --git a/Editor/Mono/GUI/AppStatusBar.cs b/Editor/Mono/GUI/AppStatusBar.cs index 04d30d34f1..3643461101 100644 --- a/Editor/Mono/GUI/AppStatusBar.cs +++ b/Editor/Mono/GUI/AppStatusBar.cs @@ -13,6 +13,7 @@ internal class AppStatusBar : GUIView { static AppStatusBar s_AppStatusBar; static GUIContent[] s_StatusWheel; + static GUIContent s_AssemblyLock; string m_LastMiniMemoryOverview = ""; protected override void OnEnable() @@ -24,6 +25,7 @@ protected override void OnEnable() s_StatusWheel = new GUIContent[12]; for (int i = 0; i < 12; i++) s_StatusWheel[i] = EditorGUIUtility.IconContent("WaitSpin" + i.ToString("00")); + s_AssemblyLock = EditorGUIUtility.IconContent("AssemblyLock", "|Assemblies are currently locked. Compilation will resume once they are unlocked"); } [RequiredByNativeCode] @@ -57,7 +59,8 @@ protected override void OldOnGUI() if (Event.current.type == EventType.Repaint) background.Draw(new Rect(0, 0, position.width, position.height), false, false, false, false); - bool compiling = EditorApplication.isCompiling; + var compiling = EditorApplication.isCompiling; + var assembliesLocked = !EditorApplication.CanReloadAssemblies(); GUILayout.Space(2); GUILayout.BeginHorizontal(); @@ -110,8 +113,15 @@ protected override void OldOnGUI() if (compiling) { - int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f); - GUI.Label(new Rect(position.width - statusWheelWidth, 0, s_StatusWheel[frame].image.width, s_StatusWheel[frame].image.height), s_StatusWheel[frame], GUIStyle.none); + if (assembliesLocked) + { + GUI.Label(new Rect(position.width - statusWheelWidth, 0, s_AssemblyLock.image.width, s_AssemblyLock.image.height), s_AssemblyLock, GUIStyle.none); + } + else + { + int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f); + GUI.Label(new Rect(position.width - statusWheelWidth, 0, s_StatusWheel[frame].image.width, s_StatusWheel[frame].image.height), s_StatusWheel[frame], GUIStyle.none); + } } if (Unsupported.IsBleedingEdgeBuild()) diff --git a/Editor/Mono/GUI/TreeView/AssetOrGameObjectTreeViewDragging.cs b/Editor/Mono/GUI/TreeView/AssetOrGameObjectTreeViewDragging.cs index 1879991f1f..c3213f8aa0 100644 --- a/Editor/Mono/GUI/TreeView/AssetOrGameObjectTreeViewDragging.cs +++ b/Editor/Mono/GUI/TreeView/AssetOrGameObjectTreeViewDragging.cs @@ -64,10 +64,10 @@ public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewIt if (string.IsNullOrEmpty(path)) return DragAndDropVisualMode.Rejected; - var pathComponents = path.Split('/'); - if (pathComponents.Length > 1 && pathComponents[0] == UnityEditor.PackageManager.Folders.GetPackagesMountPoint()) + var packageInfo = PackageManager.Packages.GetForAssetPath(path); + if (packageInfo != null) { - hierarchyProperty = new HierarchyProperty(pathComponents[0] + "/" + pathComponents[1]); + hierarchyProperty = new HierarchyProperty(packageInfo.assetPath); if (hierarchyProperty.Find(parentItem.id, null)) return InternalEditorUtility.ProjectWindowDrag(hierarchyProperty, perform); } diff --git a/Editor/Mono/GUI/TreeView/AssetsTreeViewDataSource.cs b/Editor/Mono/GUI/TreeView/AssetsTreeViewDataSource.cs index b78e7091fe..de0ff91453 100644 --- a/Editor/Mono/GUI/TreeView/AssetsTreeViewDataSource.cs +++ b/Editor/Mono/GUI/TreeView/AssetsTreeViewDataSource.cs @@ -2,8 +2,10 @@ // Copyright (c) Unity Technologies. For terms of use, see // https://unity3d.com/legal/licenses/Unity_Reference_Only_License +using System.Collections; using System.Collections.Generic; using System.IO; +using System.Linq; using UnityEditor.IMGUI.Controls; using UnityEditor.ProjectWindowCallback; using UnityEngine; @@ -17,17 +19,48 @@ namespace UnityEditor internal class AssetsTreeViewDataSource : LazyTreeViewDataSource { + public class RootItem + { + public int instanceID { get; } + public string displayName { get; } + public string path { get; } + public bool skipValidation { get; } + + public RootItem(int instanceID, string displayName, string path, bool skipValidation = false) + { + this.instanceID = instanceID; + this.displayName = displayName; + this.path = path; + this.skipValidation = skipValidation; + } + } + public bool foldersOnly { get; set; } public bool foldersFirst { get; set; } - readonly int m_RootInstanceID; + private List m_Roots; + private Dictionary m_RootsTreeViewItem; + private bool m_ExpandAtFirstTime; const HierarchyType k_HierarchyType = HierarchyType.Assets; - public AssetsTreeViewDataSource(TreeViewController treeView, int rootInstanceID, bool showRootItem, bool rootItemIsCollapsable) + private AssetsTreeViewDataSource(TreeViewController treeView) : base(treeView) { - m_RootInstanceID = rootInstanceID; - ((TreeViewDataSource)this).showRootItem = showRootItem; - rootIsCollapsable = rootItemIsCollapsable; + m_ExpandAtFirstTime = true; + showRootItem = false; + rootIsCollapsable = false; + } + + public AssetsTreeViewDataSource(TreeViewController treeView, List roots) + : this(treeView) + { + m_Roots = roots; + } + + public AssetsTreeViewDataSource(TreeViewController treeView, int rootInstanceID) + : this(treeView) + { + m_Roots = new List(); + m_Roots.Add(new RootItem(rootInstanceID, null, null)); } static string CreateDisplayName(int instanceID) @@ -39,50 +72,128 @@ public override void FetchData() { // Create root Item int depth = 0; - m_RootItem = new TreeViewItem(m_RootInstanceID, depth, null, CreateDisplayName(m_RootInstanceID)); - if (!showRootItem) + var multiRoot = (m_Roots.Count > 1); + if (multiRoot) + { + m_RootItem = new TreeViewItem(-1, depth, null, "Invisible Root Item"); SetExpanded(m_RootItem, true); + } + else + { + var rootInstanceID = m_Roots[0].instanceID; + var displayName = m_Roots[0].displayName ?? CreateDisplayName(rootInstanceID); + m_RootItem = new TreeViewItem(rootInstanceID, depth, null, displayName); + SetExpanded(m_RootItem, true); + } - // Find start Item - var property = new HierarchyProperty(k_HierarchyType, false); - - property.Reset(); - bool found = property.Find(m_RootInstanceID, null); - if (!found) - Debug.LogError("Root Asset with id " + m_RootInstanceID + " not found!!"); - - int minDepth = property.depth + (showRootItem ? 0 : 1); - int[] expanded = expandedIDs.ToArray(); + m_Rows = new List(m_Roots.Count * 256); Texture2D emptyFolderIcon = EditorGUIUtility.FindTexture(EditorResources.emptyFolderIconName); + Texture2D folderIcon = EditorGUIUtility.FindTexture(EditorResources.folderIconName); + var assetsInstanceIDs = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); + var projectPath = Path.GetFileName(Directory.GetCurrentDirectory()); - // Fetch visible items - m_Rows = new List(); - while (property.NextWithDepthCheck(expanded, minDepth)) + // Fetch root Items + m_RootsTreeViewItem = new Dictionary(m_Roots.Count); + foreach (var root in m_Roots) { - if (!foldersOnly || property.isFolder) + var rootInstanceID = root.instanceID; + var displayName = root.displayName ?? CreateDisplayName(rootInstanceID); + var rootPath = root.path ?? AssetDatabase.GetAssetPath(rootInstanceID); + + var property = new HierarchyProperty(rootPath); + if (!root.skipValidation && !property.Find(rootInstanceID, null)) { - depth = property.depth - minDepth; - TreeViewItem item; - if (property.isFolder) - item = new FolderTreeItem(property.instanceID, depth, null, property.name); - else - item = new NonFolderTreeItem(property.instanceID, depth, null, property.name); + Debug.LogError("Root Asset with id " + rootInstanceID + " not valid!!"); + continue; + } + + var minDepth = property.depth; + var subDepth = multiRoot ? 0 : -1; + TreeViewItem rootItem; + if (multiRoot) + { + var parentItem = m_RootItem; + var rootDepth = minDepth; + rootDepth++; - if (property.isFolder && !property.hasChildren) - item.icon = emptyFolderIcon; + // Find parent treeView item + var parentPath = Directory.GetParent(rootPath).Name; + if (parentPath != projectPath) + { + if (!m_RootsTreeViewItem.TryGetValue(parentPath, out parentItem)) + { + Debug.LogError("Cannot find parent for " + rootInstanceID); + continue; + } + + rootDepth++; + subDepth++; + } + + // Create root item TreeView item + if (subDepth > 0) + rootItem = new FolderTreeItem(rootInstanceID, rootDepth, parentItem, displayName); else - item.icon = property.icon; + rootItem = new RootTreeItem(rootInstanceID, rootDepth, parentItem, displayName); + rootItem.icon = folderIcon; + parentItem.AddChild(rootItem); + } + else + { + rootItem = m_RootItem; + } + + m_RootsTreeViewItem[rootPath] = rootItem; - if (property.hasChildren) + var expandIDs = GetExpandedIDs(); + var rows = new List(); + bool shouldExpandIt = m_ExpandAtFirstTime && (rootItem.id == assetsInstanceIDs); + if (IsExpanded(rootItem.id) && (rootItem == m_RootItem || IsExpanded(rootItem.parent.id)) || shouldExpandIt) + { + m_ExpandAtFirstTime = false; + + while (property.NextWithDepthCheck(expandIDs, minDepth)) { - item.AddChild(null); // add a dummy child in children list to ensure we show the collapse arrow (because we do not fetch data for collapsed items) + if (!foldersOnly || property.isFolder) + { + depth = property.depth - minDepth; + TreeViewItem item; + if (property.isFolder) + item = new FolderTreeItem(property.instanceID, depth + subDepth, null, property.name); + else + item = new NonFolderTreeItem(property.instanceID, depth + subDepth, null, property.name); + + if (property.isFolder && !property.hasChildren) + item.icon = emptyFolderIcon; + else + item.icon = property.icon; + + if (property.hasChildren) + { + item.AddChild(null); // add a dummy child in children list to ensure we show the collapse arrow (because we do not fetch data for collapsed items) + } + rows.Add(item); + } } - m_Rows.Add(item); + + // Setup reference between child and parent items + TreeViewUtility.SetChildParentReferences(rows, rootItem); + } + else + { + rootItem.AddChild(null); } - } - // Setup reference between child and parent items - TreeViewUtility.SetChildParentReferences(m_Rows, m_RootItem); + if (shouldExpandIt && !IsExpanded(rootItem)) + SetExpanded(rootItem, true); + + if (multiRoot && IsExpanded(rootItem.parent.id)) + { + m_Rows.Add(rootItem); + } + + ((List)m_Rows).AddRange(rows); + } if (foldersFirst) { @@ -143,16 +254,43 @@ protected override HashSet GetParentsBelow(int id) { // Add all children expanded ids to hashset HashSet parentsBelow = new HashSet(); - IHierarchyProperty search = new HierarchyProperty(k_HierarchyType); - if (search.Find(id, null)) + + if (m_Roots.Count > 1) { - parentsBelow.Add(id); + var assetsInstanceIDs = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); + if (id != assetsInstanceIDs) + { + // Search in created first-level root items + var item = m_RootsTreeViewItem.Values.FirstOrDefault(tvi => tvi.id == id && tvi.depth == 0); + if (item != null) + { + parentsBelow.Add(id); + foreach (var child in item.children) + { + if (child != null && child.hasChildren) + parentsBelow.UnionWith(GetParentsBelow(child.id)); + } + return parentsBelow; + } + } + } - int depth = search.depth; - while (search.Next(null) && search.depth > depth) + // Search in all roots + foreach (var root in m_Roots) + { + var rootPath = root.path ?? AssetDatabase.GetAssetPath(root.instanceID); + IHierarchyProperty search = new HierarchyProperty(rootPath); + if (search.Find(id, null)) { - if (search.hasChildren) - parentsBelow.Add(search.instanceID); + parentsBelow.Add(id); + + int depth = search.depth; + while (search.Next(null) && search.depth > depth) + { + if (search.hasChildren) + parentsBelow.Add(search.instanceID); + } + break; } } return parentsBelow; @@ -173,6 +311,10 @@ override public bool IsRenamingItemAllowed(TreeViewItem item) if (AssetDatabase.IsSubAsset(item.id) || (item.parent == null)) return false; + // Root items cannot be renamed + if (item is RootTreeItem) + return false; + return InternalEditorUtility.CanRenameAsset(item.id); } @@ -299,6 +441,13 @@ public int Compare(TreeViewItem x, TreeViewItem y) } // Classes used for type checking + internal class RootTreeItem : TreeViewItem + { + public RootTreeItem(int id, int depth, TreeViewItem parent, string displayName) + : base(id, depth, parent, displayName) + { + } + } class FolderTreeItem : TreeViewItem { public FolderTreeItem(int id, int depth, TreeViewItem parent, string displayName) diff --git a/Editor/Mono/GUI/TreeView/AssetsTreeViewGUI.cs b/Editor/Mono/GUI/TreeView/AssetsTreeViewGUI.cs index df1f61e54b..d7b8f6a96d 100644 --- a/Editor/Mono/GUI/TreeView/AssetsTreeViewGUI.cs +++ b/Editor/Mono/GUI/TreeView/AssetsTreeViewGUI.cs @@ -135,6 +135,15 @@ protected override Texture GetIconForItem(TreeViewItem item) return icon; } + protected override void DoItemGUI(Rect rect, int row, TreeViewItem item, bool selected, bool focused, bool useBoldFont) + { + if (item is AssetsTreeViewDataSource.RootTreeItem) + { + useBoldFont = true; + } + base.DoItemGUI(rect, row, item, selected, focused, useBoldFont); + } + private void OnIconOverlayGUI(TreeViewItem item, Rect overlayRect) { if (postAssetIconDrawCallback != null && AssetDatabase.IsMainAsset(item.id)) diff --git a/Editor/Mono/Inspector/LightProbeProxyVolumeEditor.cs b/Editor/Mono/Inspector/LightProbeProxyVolumeEditor.cs index dea9898f48..b849130b70 100644 --- a/Editor/Mono/Inspector/LightProbeProxyVolumeEditor.cs +++ b/Editor/Mono/Inspector/LightProbeProxyVolumeEditor.cs @@ -28,6 +28,7 @@ internal class LightProbeProxyVolumeEditor : Editor private SerializedProperty m_ResolutionProbesPerUnit; private SerializedProperty m_ProbePositionMode; private SerializedProperty m_RefreshMode; + private SerializedProperty m_QualityMode; // Should match gizmo color in GizmoDrawers.cpp! internal static Color kGizmoLightProbeProxyVolumeColor = new Color(0xFF / 255f, 0xE5 / 255f, 0x94 / 255f, 0x80 / 255f); @@ -54,10 +55,12 @@ static Styles() public static GUIContent resModeText = EditorGUIUtility.TrTextContent("Resolution Mode", "The mode in which the resolution of the 3D grid of interpolated light probes is specified:\n\nAutomatic - the resolution on each axis is computed using a user-specified number of interpolated light probes per unit area(Density).\n\nCustom - the user can specify a different resolution on each axis."); public static GUIContent probePositionText = EditorGUIUtility.TrTextContent("Probe Position Mode", "The mode in which the interpolated probe positions are generated.\n\nCellCorner - divide the volume in cells and generate interpolated probe positions in the corner/edge of the cells.\n\nCellCenter - divide the volume in cells and generate interpolated probe positions in the center of the cells."); public static GUIContent refreshModeText = EditorGUIUtility.TrTextContent("Refresh Mode"); + public static GUIContent qualityText = EditorGUIUtility.TrTextContent("Quality", "Affects the total number of evaluated Spherical Harmonics(SH) bands for Renderers that use a Light Probe Proxy Volume:\n\nLow Quality - uses only 2 bands(L0 and L1) sampled from a LPPV texture. This option might improve the performance by not breaking batching.\n\nNormal Quality - uses all the bands to evaluate the SH. L0 and L1 are sampled from a LPPV texture and L2 is constant per Renderer."); public static GUIContent[] bbMode = (Enum.GetNames(typeof(LightProbeProxyVolume.BoundingBoxMode)).Select(x => ObjectNames.NicifyVariableName(x)).ToArray()).Select(x => new GUIContent(x)).ToArray(); public static GUIContent[] resMode = (Enum.GetNames(typeof(LightProbeProxyVolume.ResolutionMode)).Select(x => ObjectNames.NicifyVariableName(x)).ToArray()).Select(x => new GUIContent(x)).ToArray(); public static GUIContent[] probePositionMode = (Enum.GetNames(typeof(LightProbeProxyVolume.ProbePositionMode)).Select(x => ObjectNames.NicifyVariableName(x)).ToArray()).Select(x => new GUIContent(x)).ToArray(); public static GUIContent[] refreshMode = (Enum.GetNames(typeof(LightProbeProxyVolume.RefreshMode)).Select(x => ObjectNames.NicifyVariableName(x)).ToArray()).Select(x => new GUIContent(x)).ToArray(); + public static GUIContent[] qualityMode = (Enum.GetNames(typeof(LightProbeProxyVolume.QualityMode)).Select(x => ObjectNames.NicifyVariableName(x)).ToArray()).Select(x => new GUIContent(x)).ToArray(); public static GUIContent resProbesPerUnit = EditorGUIUtility.TrTextContent("Density", "Density in probes per world unit."); public static GUIContent componentUnusedNote = EditorGUIUtility.TrTextContent("In order to use the component on this game object, the Light Probes property should be set to 'Use Proxy Volume' in Renderer."); public static GUIContent noRendererNode = EditorGUIUtility.TrTextContent("The component is unused by this game object because there is no Renderer component attached."); @@ -163,6 +166,7 @@ public void OnEnable() m_ResolutionProbesPerUnit = serializedObject.FindProperty("m_ResolutionProbesPerUnit"); m_ProbePositionMode = serializedObject.FindProperty("m_ProbePositionMode"); m_RefreshMode = serializedObject.FindProperty("m_RefreshMode"); + m_QualityMode = serializedObject.FindProperty("m_QualityMode"); m_BoundsHandle.handleColor = kGizmoLightProbeProxyVolumeHandleColor; m_BoundsHandle.wireframeColor = Color.clear; @@ -229,6 +233,8 @@ public override void OnInspectorGUI() EditorGUILayout.Popup(m_RefreshMode, Styles.refreshMode, Styles.refreshModeText); + EditorGUILayout.Popup(m_QualityMode, Styles.qualityMode, Styles.qualityText); + EditorGUILayout.Popup(m_BoundingBoxMode, Styles.bbMode, Styles.bbModeText); if (EditorGUILayout.BeginFadeGroup(m_ShowBoundingBoxOptions.faded)) diff --git a/Editor/Mono/LookDevView/CameraControllerStandard.cs b/Editor/Mono/LookDevView/CameraControllerStandard.cs index 71e4a38ad9..2353a94e22 100644 --- a/Editor/Mono/LookDevView/CameraControllerStandard.cs +++ b/Editor/Mono/LookDevView/CameraControllerStandard.cs @@ -191,7 +191,8 @@ public override void Update(CameraState cameraState, Camera cam, EditorWindow wi } m_CameraFlyModeContext.active = m_CurrentViewTool == ViewTool.FPS; - using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(m_CameraFlyModeContext)) + var id = GUIUtility.GetControlID(FocusType.Passive); + using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(m_CameraFlyModeContext, id)) { if (inputSamplingScope.inputVectorChanged) m_FlySpeed = 0; diff --git a/Editor/Mono/ObjectListArea.cs b/Editor/Mono/ObjectListArea.cs index 7f022be2d2..2a3f68390d 100644 --- a/Editor/Mono/ObjectListArea.cs +++ b/Editor/Mono/ObjectListArea.cs @@ -1659,10 +1659,10 @@ public void BeginPing(int instanceID) if (string.IsNullOrEmpty(path)) return; - var pathComponents = path.Split('/'); - if (pathComponents.Length > 1 && pathComponents[0] == UnityEditor.PackageManager.Folders.GetPackagesMountPoint()) + var packageInfo = PackageManager.Packages.GetForAssetPath(path); + if (packageInfo != null) { - hierarchyProperty = new HierarchyProperty(pathComponents[0] + "/" + pathComponents[1]); + hierarchyProperty = new HierarchyProperty(packageInfo.assetPath); if (hierarchyProperty.Find(instanceID, null)) { name = hierarchyProperty.name; diff --git a/Editor/Mono/ObjectListLocalGroup.cs b/Editor/Mono/ObjectListLocalGroup.cs index efe5481657..cfc77cff7c 100644 --- a/Editor/Mono/ObjectListLocalGroup.cs +++ b/Editor/Mono/ObjectListLocalGroup.cs @@ -1254,10 +1254,10 @@ public DragAndDropVisualMode DoDrag(int dragToInstanceID, bool perform) if (string.IsNullOrEmpty(path)) return DragAndDropVisualMode.Rejected; - var pathComponents = path.Split('/'); - if (pathComponents.Length > 1 && pathComponents[0] == UnityEditor.PackageManager.Folders.GetPackagesMountPoint()) + var packageInfo = PackageManager.Packages.GetForAssetPath(path); + if (packageInfo != null) { - search = new HierarchyProperty(pathComponents[0] + "/" + pathComponents[1]); + search = new HierarchyProperty(packageInfo.assetPath); if (search.Find(dragToInstanceID, null)) return InternalEditorUtility.ProjectWindowDrag(search, perform); } diff --git a/Editor/Mono/ProjectBrowser.cs b/Editor/Mono/ProjectBrowser.cs index ad07647bd9..8b06b15759 100644 --- a/Editor/Mono/ProjectBrowser.cs +++ b/Editor/Mono/ProjectBrowser.cs @@ -21,6 +21,8 @@ namespace UnityEditor [EditorWindowTitle(title = "Project", icon = "Project")] internal class ProjectBrowser : EditorWindow, IHasCustomMenu { + public const int kPackagesFolderInstanceId = int.MaxValue; + // Alive ProjectBrowsers private static List s_ProjectBrowsers = new List(); public static List GetAllProjectBrowsers() @@ -174,7 +176,7 @@ bool useTreeViewSelectionInsteadOfMainSelection // Used by search menu bar [NonSerialized] - public GUIContent m_SearchAllAssets = EditorGUIUtility.TrTextContent("Assets"); // do not localize this: Assets=folder name + public GUIContent m_SearchAllAssets = EditorGUIUtility.TrTextContent("All Assets"); // do not localize this: Assets=folder name [NonSerialized] public GUIContent m_SearchInFolders = new GUIContent(""); // updated when needed [NonSerialized] @@ -306,6 +308,11 @@ void EnsureValidFolders() HashSet validFolders = new HashSet(); foreach (string folder in m_SearchFilter.folders) { + if (folder == PackageManager.Folders.GetPackagesMountPoint()) + { + validFolders.Add(folder); + continue; + } if (AssetDatabase.IsValidFolder(folder)) { validFolders.Add(folder); @@ -568,13 +575,17 @@ void RefreshSearchText() int maxShow = 3; for (int i = 0; i < baseFolders.Length && i < maxShow; ++i) { + var baseFolder = baseFolders[i]; + var packageInfo = PackageManager.Packages.GetForAssetPath(baseFolder); + if (packageInfo != null && !string.IsNullOrEmpty(packageInfo.displayName)) + baseFolder = Regex.Replace(baseFolder, @"^" + packageInfo.assetPath, PackageManager.Folders.GetPackagesMountPoint() + "/" + packageInfo.displayName); if (i > 0) folderText += ", "; - string folderName = Path.GetFileName(baseFolders[i]); + string folderName = Path.GetFileName(baseFolder); folderText += "'" + folderName + "'"; - if (i == 0 && folderName != "Assets") // We dont show tooltip for the root folder: Assets - toolTip = baseFolders[i]; + if (i == 0 && folderName != "Assets" && folderName != PackageManager.Folders.GetPackagesMountPoint()) + toolTip = baseFolder; } if (baseFolders.Length > maxShow) folderText += " +"; @@ -651,7 +662,22 @@ void InitViewMode(ViewMode viewMode) m_AssetTree.onGUIRowCallback += OnGUIAssetCallback; m_AssetTree.dragEndedCallback += AssetTreeDragEnded; - var data = new AssetsTreeViewDataSource(m_AssetTree, AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"), false, false); + var assetsFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); + var roots = new List(); + var packagesMountPoint = PackageManager.Folders.GetPackagesMountPoint(); + + roots.Add(new AssetsTreeViewDataSource.RootItem(assetsFolderInstanceID, null, null)); + roots.Add(new AssetsTreeViewDataSource.RootItem(kPackagesFolderInstanceId, packagesMountPoint, packagesMountPoint, true)); + foreach (var package in PackageManager.Packages.GetAll()) + { + if (package.source == PackageManager.PackageSource.BuiltIn) + continue; + + var displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name; + roots.Add(new AssetsTreeViewDataSource.RootItem(AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath), displayName, package.assetPath)); + } + + var data = new AssetsTreeViewDataSource(m_AssetTree, roots); data.foldersFirst = GetShouldShowFoldersFirst(); m_AssetTree.Init(m_TreeViewRect, @@ -878,6 +904,8 @@ void ShowFolderContents(int folderInstanceID, bool revealAndFrameInFolderTree) return; string folderPath = AssetDatabase.GetAssetPath(folderInstanceID); + if (folderInstanceID == kPackagesFolderInstanceId) + folderPath = PackageManager.Folders.GetPackagesMountPoint(); m_SearchFilter.ClearSearch(); m_SearchFilter.folders = new[] {folderPath}; m_FolderTree.SetSelection(new[] {folderInstanceID}, revealAndFrameInFolderTree); @@ -953,7 +981,7 @@ void ShowParentFolderOfCurrentlySelected() if (selectedFolderInstanceIDs.Length == 1) { TreeViewItem item = m_FolderTree.FindItem(selectedFolderInstanceIDs[0]); - if (item != null && item.parent != null && item.id != ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID()) + if (item != null && item.parent != null && item.id != AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets")) { SetFolderSelection(new[] {item.parent.id}, true); m_ListArea.Frame(item.id, true, false); @@ -1069,7 +1097,21 @@ void OnLostFocus() bool ShouldFrameAsset(int instanceID) { HierarchyProperty h = new HierarchyProperty(HierarchyType.Assets, false); - return h.Find(instanceID, null); + if (h.Find(instanceID, null)) + return true; + + var path = AssetDatabase.GetAssetPath(instanceID); + if (string.IsNullOrEmpty(path)) + return false; + + var packageInfo = PackageManager.Packages.GetForAssetPath(path); + if (packageInfo != null) + { + h = new HierarchyProperty(packageInfo.assetPath, false); + if (h.Find(instanceID, null)) + return true; + } + return false; } void OnSelectionChange() @@ -1196,6 +1238,12 @@ void SetSearchFoldersFromCurrentSelection() foreach (int instanceID in Selection.instanceIDs) { + if (instanceID == kPackagesFolderInstanceId) + { + folders.Add(PackageManager.Folders.GetPackagesMountPoint()); + continue; + } + if (!AssetDatabase.Contains(instanceID)) continue; @@ -1361,7 +1409,7 @@ static internal int[] DuplicateFolders(int[] instanceIDs) List copiedPaths = new List(); bool failed = false; - int asssetsFolderInstanceID = ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID(); + int asssetsFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); foreach (int instanceID in instanceIDs) { @@ -1411,6 +1459,50 @@ static void DeleteFilter(int filterInstanceID) } } + // Also called from C++ (used for AssetsMenu check if selection is Packages folder) + [UsedByNativeCode] + internal static bool SelectionIsPackagesRootFolder() + { + if (s_LastInteractedProjectBrowser == null) + return false; + + if (s_LastInteractedProjectBrowser.m_ViewMode == ViewMode.OneColumn && + s_LastInteractedProjectBrowser.m_AssetTree != null && + s_LastInteractedProjectBrowser.m_AssetTree.IsSelected(kPackagesFolderInstanceId)) + { + return true; + } + + if (s_LastInteractedProjectBrowser.m_ViewMode == ViewMode.TwoColumns && + s_LastInteractedProjectBrowser.m_FolderTree != null && + s_LastInteractedProjectBrowser.m_FolderTree.IsSelected(kPackagesFolderInstanceId)) + { + return true; + } + + return false; + } + + private bool ShouldDiscardCommandsEventsForImmmutablePackages() + { + if ((Event.current.type == EventType.ExecuteCommand || Event.current.type == EventType.ValidateCommand) && + (Event.current.commandName == EventCommandNames.Cut || + Event.current.commandName == EventCommandNames.Paste || + Event.current.commandName == EventCommandNames.Delete || + Event.current.commandName == EventCommandNames.SoftDelete || + Event.current.commandName == EventCommandNames.Duplicate)) + { + if (AssetsMenuUtility.SelectionHasImmutable()) + return true; + + if (SelectionIsPackagesRootFolder()) + return true; + } + + return false; + } + + // Returns true if we should early out of OnGUI bool HandleCommandEventsForTreeView() { @@ -1427,6 +1519,15 @@ bool HandleCommandEventsForTreeView() // Only one type can be selected at a time (and savedfilters can only be single-selected) ItemType itemType = GetItemType(instanceIDs[0]); + // Check if event made on immutable package + if (itemType == ItemType.Asset) + { + if (ShouldDiscardCommandsEventsForImmmutablePackages()) + { + return false; + } + } + if (Event.current.commandName == EventCommandNames.Delete || Event.current.commandName == EventCommandNames.SoftDelete) { Event.current.Use(); @@ -1478,6 +1579,12 @@ bool HandleCommandEventsForTreeView() // Returns true if we should early out of OnGUI bool HandleCommandEvents() { + // Check if event made on immutable package + if (ShouldDiscardCommandsEventsForImmmutablePackages()) + { + return false; + } + EventType eventType = Event.current.type; if (eventType == EventType.ExecuteCommand || eventType == EventType.ValidateCommand) { @@ -1590,12 +1697,22 @@ void RefreshSplittedSelectedPath() else { string displayPath = m_SelectedPath; - if (m_SelectedPath.StartsWith("assets/", StringComparison.CurrentCultureIgnoreCase)) - displayPath = m_SelectedPath.Substring("assets/".Length); + string rootPath = "Assets/"; + if (m_SelectedPath.StartsWith(rootPath, StringComparison.CurrentCultureIgnoreCase)) + displayPath = m_SelectedPath.Substring(rootPath.Length); + else if (m_SelectedPath.StartsWith(PackageManager.Folders.GetPackagesMountPoint() + "/", StringComparison.CurrentCultureIgnoreCase)) + { + rootPath = PackageManager.Folders.GetPackagesMountPoint() + "/"; + var packageInfo = PackageManager.Packages.GetForAssetPath(m_SelectedPath); + if (packageInfo != null && !string.IsNullOrEmpty(packageInfo.displayName)) + displayPath = Regex.Replace(m_SelectedPath, @"^" + packageInfo.assetPath, packageInfo.displayName); + else + displayPath = m_SelectedPath.Substring(rootPath.Length); + } if (m_SearchFilter.GetState() == SearchFilter.State.FolderBrowsing) { - m_SelectedPathSplitted.Add(new GUIContent(Path.GetFileName(m_SelectedPath), AssetDatabase.GetCachedIcon(m_SelectedPath))); + m_SelectedPathSplitted.Add(new GUIContent(rootPath + displayPath, AssetDatabase.GetCachedIcon(m_SelectedPath))); } else { @@ -1616,10 +1733,11 @@ void RefreshSplittedSelectedPath() */ string[] split = displayPath.Split('/'); - string curPath = "Assets/"; - for (int i = 0; i < split.Length; ++i) + string[] splitPath = m_SelectedPath.Split('/'); + string curPath = rootPath; + for (int i = 0, j = 1; i < split.Length; ++i, ++j) { - curPath += split[i]; + curPath += splitPath[j]; Texture icon = AssetDatabase.GetCachedIcon(curPath); m_SelectedPathSplitted.Add(new GUIContent(split[i], icon)); @@ -1968,14 +2086,6 @@ void ToggleExpansionAnimationPreference() InternalEditorUtility.RequestScriptReload(); } - void ToggleShowPackagesInAssetsFolder() - { - bool showPackagesInAssetsFolder = EditorPrefs.GetBool("ShowPackagesFolder", false); - EditorPrefs.SetBool("ShowPackagesFolder", !showPackagesInAssetsFolder); - OnProjectChanged(); - } - - public virtual void AddItemsToMenu(GenericMenu menu) { if (m_EnableOldAssetTree) @@ -2069,6 +2179,8 @@ void ButtonSaveFilter() void CreateDropdown() { var isInReadOnlyContext = AssetsMenuUtility.SelectionHasImmutable(); + if (!isInReadOnlyContext) + isInReadOnlyContext = SelectionIsPackagesRootFolder(); EditorGUI.BeginDisabledGroup(isInReadOnlyContext); Rect r = GUILayoutUtility.GetRect(s_Styles.m_CreateDropdownContent, EditorStyles.toolbarDropDown); if (EditorGUI.DropdownButton(r, s_Styles.m_CreateDropdownContent, FocusType.Passive, EditorStyles.toolbarDropDown)) @@ -2176,8 +2288,16 @@ void TopBarSearchSettingsChanged() static int[] GetFolderInstanceIDs(string[] folders) { int[] folderInstanceIDs = new int[folders.Length]; + for (int i = 0; i < folders.Length; ++i) + { + if (folders[i] == PackageManager.Folders.GetPackagesMountPoint()) + { + folderInstanceIDs[i] = kPackagesFolderInstanceId; + continue; + } folderInstanceIDs[i] = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folders[i]); + } return folderInstanceIDs; } @@ -2186,6 +2306,11 @@ static string[] GetFolderPathsFromInstanceIDs(int[] instanceIDs) List paths = new List(); foreach (int instanceID in instanceIDs) { + if (instanceID == kPackagesFolderInstanceId) + { + paths.Add(PackageManager.Folders.GetPackagesMountPoint()); + continue; + } string path = AssetDatabase.GetAssetPath(instanceID); if (!String.IsNullOrEmpty(path)) paths.Add(path); @@ -2281,27 +2406,63 @@ void BreadCrumbBar() if (m_BreadCrumbs.Count == 0) { - string path = m_SearchFilter.folders[0]; + var path = m_SearchFilter.folders[0]; + + var folderNames = new List(); + var folderDisplayNames = new List(); + var packagesMountPoint = PackageManager.Folders.GetPackagesMountPoint(); + var packageInfo = PackageManager.Packages.GetForAssetPath(path); + if (packageInfo != null) + { + // Packages root + folderNames.Add(packagesMountPoint); + folderDisplayNames.Add(packagesMountPoint); - string[] folderNames = path.Split('/'); - var packagesRoot = UnityEditor.PackageManager.Folders.GetPackagesMountPoint(); - if (path.StartsWith(packagesRoot)) + // Package name/displayname + folderNames.Add(packageInfo.name); + folderDisplayNames.Add(packageInfo.displayName ?? packageInfo.name); + + // Rest of the path; + if (path != packageInfo.assetPath) + { + var subpaths = Regex.Replace(path, @"^" + packageInfo.assetPath + "/", "").Split('/'); + folderNames.AddRange(subpaths); + folderDisplayNames.AddRange(subpaths); + } + } + else { - // Translate the packages root mount point - folderNames = Regex.Replace(path, "^" + packagesRoot, PackageManager.Folders.GetPackagesMountPoint()).Split('/'); + folderNames.AddRange(path.Split('/')); + folderDisplayNames = folderNames; } - string folderPath = ""; - foreach (string folderName in folderNames) + var folderPath = ""; + var i = 0; + foreach (var folderName in folderNames) { - if (!String.IsNullOrEmpty(folderPath)) + if (!string.IsNullOrEmpty(folderPath)) folderPath += "/"; folderPath += folderName; - m_BreadCrumbs.Add(new KeyValuePair(new GUIContent(folderName), folderPath)); + m_BreadCrumbs.Add(new KeyValuePair(new GUIContent(folderDisplayNames[i++]), folderPath)); } - m_BreadCrumbLastFolderHasSubFolders = AssetDatabase.GetSubFolders(path).Length > 0; + if (path == packagesMountPoint) + { + m_BreadCrumbLastFolderHasSubFolders = false; + foreach (var package in PackageManager.Packages.GetAll()) + { + if (package.source == PackageManager.PackageSource.BuiltIn) + continue; + + m_BreadCrumbLastFolderHasSubFolders = true; + break; + } + } + else + { + m_BreadCrumbLastFolderHasSubFolders = AssetDatabase.GetSubFolders(path).Length > 0; + } } // Background @@ -2323,6 +2484,11 @@ void BreadCrumbBar() rect.width = size.x; if (GUI.Button(rect, folderContent, style)) { + if (folderPath == PackageManager.Folders.GetPackagesMountPoint()) + { + ShowFolderContents(kPackagesFolderInstanceId, false); + continue; + } ShowFolderContents(AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folderPath), false); } @@ -2378,7 +2544,7 @@ void BottomBar() void SelectAssetsFolder() { - ShowFolderContents(ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID(), true); + ShowFolderContents(AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"), true); } string ValidateCreateNewAssetPath(string pathName) @@ -2490,7 +2656,7 @@ private void FrameObjectInTwoColumnMode(int instanceID, bool frame, bool ping) folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(containingFolder); if (folderInstanceID == 0) - folderInstanceID = ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID(); + folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); } // Could be a scene gameobject @@ -2504,7 +2670,8 @@ private void FrameObjectInTwoColumnMode(int instanceID, bool frame, bool ping) } // Also called from C++ (used for AssetSelection overriding) - static int[] GetTreeViewFolderSelection(bool forceUseTreeViewSelection = false) + [UsedByNativeCode] + internal static int[] GetTreeViewFolderSelection(bool forceUseTreeViewSelection = false) { // Since we can delete entire folder hierarchies with the returned selection we need to be very careful. We therefore require the following: // - The folder/favorite tree view must have keyboard focus @@ -2661,15 +2828,34 @@ static internal void Show(string folder, string currentSubFolder, Rect activator m_Caller = caller; // List of sub folders - string[] subFolders = AssetDatabase.GetSubFolders(folder); + var subFolders = new List(); + var subFolderDisplayNames = new List(); + if (folder == PackageManager.Folders.GetPackagesMountPoint()) + { + foreach (var package in PackageManager.Packages.GetAll()) + { + if (package.source == PackageManager.PackageSource.BuiltIn) + continue; + + subFolders.Add(package.assetPath); + var displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name; + subFolderDisplayNames.Add(displayName); + } + } + else + { + subFolders.AddRange(AssetDatabase.GetSubFolders(folder)); + foreach (var subFolderPath in subFolders) + subFolderDisplayNames.Add(Path.GetFileName(subFolderPath)); + } + GenericMenu menu = new GenericMenu(); - if (subFolders.Length >= 0) + if (subFolders.Count >= 0) { - currentSubFolder = Path.GetFileName(currentSubFolder); - foreach (string subFolderPath in subFolders) + var i = 0; + foreach (var subFolderPath in subFolders) { - string subFolderName = Path.GetFileName(subFolderPath); - menu.AddItem(new GUIContent(subFolderName), subFolderName == currentSubFolder, new BreadCrumbListMenu(subFolderPath).SelectSubFolder); + menu.AddItem(new GUIContent(subFolderDisplayNames[i++]), subFolderPath == currentSubFolder, new BreadCrumbListMenu(subFolderPath).SelectSubFolder); menu.ShowAsContext(); } } diff --git a/Editor/Mono/ProjectBrowserColumnOne.cs b/Editor/Mono/ProjectBrowserColumnOne.cs index 52f855d80a..eaaaf166b6 100644 --- a/Editor/Mono/ProjectBrowserColumnOne.cs +++ b/Editor/Mono/ProjectBrowserColumnOne.cs @@ -3,8 +3,8 @@ // https://unity3d.com/legal/licenses/Unity_Reference_Only_License using System.IO; +using System.Linq; using System.Collections.Generic; -using System.Globalization; using UnityEditor.IMGUI.Controls; using UnityEngine; using UnityEditor.Experimental; @@ -257,32 +257,28 @@ public override bool IsRenamingItemAllowed(TreeViewItem item) } } - public static int GetAssetsFolderInstanceID() - { - int instanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); - return instanceID; - } - public override void FetchData() { - m_RootItem = new TreeViewItem(System.Int32.MaxValue, 0, null, "Invisible Root Item"); + m_RootItem = new TreeViewItem(0, 0, null, "Invisible Root Item"); SetExpanded(m_RootItem, true); // ensure always visible // We want three roots: Favorites, Assets, and Saved Filters List visibleRoots = new List(); // Fetch asset folders - int assetsFolderInstanceID = GetAssetsFolderInstanceID(); + int assetsFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); int depth = 0; string displayName = "Assets"; //CreateDisplayName (assetsFolderInstanceID); TreeViewItem assetRootItem = new TreeViewItem(assetsFolderInstanceID, depth, m_RootItem, displayName); ReadAssetDatabase("Assets", assetRootItem, depth + 1); - TreeViewItem packagesRootItem = new TreeViewItem(0, depth, m_RootItem, "Packages"); + var packagesMountPoint = PackageManager.Folders.GetPackagesMountPoint(); + TreeViewItem packagesRootItem = new TreeViewItem(ProjectBrowser.kPackagesFolderInstanceId, depth, m_RootItem, packagesMountPoint); depth++; Texture2D folderIcon = EditorGUIUtility.FindTexture(EditorResources.folderIconName); Texture2D emptyFolderIcon = EditorGUIUtility.FindTexture(EditorResources.emptyFolderIconName); + packagesRootItem.icon = emptyFolderIcon; var packages = PackageManager.Packages.GetAll(); @@ -291,13 +287,12 @@ public override void FetchData() if (package.source == PackageManager.PackageSource.BuiltIn) continue; - var packagePath = Path.Combine(PackageManager.Folders.GetPackagesMountPoint(), package.name); - var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(packagePath); + var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath); - displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : CultureInfo.InvariantCulture.TextInfo.ToTitleCase(package.name.Replace("com.unity.", "")); - TreeViewItem packageItem = new TreeViewItem(packageFolderInstanceId, depth, null, displayName); + displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name; + TreeViewItem packageItem = new TreeViewItem(packageFolderInstanceId, depth, packagesRootItem, displayName); packagesRootItem.AddChild(packageItem); - ReadAssetDatabase(packagePath, packageItem, depth + 1); + ReadAssetDatabase(package.assetPath, packageItem, depth + 1); packagesRootItem.icon = folderIcon; } @@ -317,6 +312,9 @@ public override void FetchData() // Get global expanded state of roots foreach (TreeViewItem item in m_RootItem.children) { + // Do not expand Packages root item + if (item.id == ProjectBrowser.kPackagesFolderInstanceId) + continue; bool expanded = EditorPrefs.GetBool(kProjectBrowserString + item.displayName, true); SetExpanded(item, expanded); } @@ -347,6 +345,55 @@ private void ReadAssetDatabase(string assetFolderRootPath, TreeViewItem parent, // Fix references TreeViewUtility.SetChildParentReferences(allFolders, parent); } + + private HashSet GetParentsBelow(int id) + { + // Add all children expanded ids to hashset + HashSet parentsBelow = new HashSet(); + + // Check if packages instance + if (id == ProjectBrowser.kPackagesFolderInstanceId) + { + parentsBelow.Add(id); + var item = m_TreeView.FindItem(id); + foreach (var child in item.children) + { + if (child.hasChildren) + parentsBelow.UnionWith(GetParentsBelow(child.id)); + } + return parentsBelow; + } + + var path = AssetDatabase.GetAssetPath(id); + var pathComponents = path.Split('/'); + IHierarchyProperty search = new HierarchyProperty(pathComponents[0]); + if (search.Find(id, null)) + { + parentsBelow.Add(id); + + int depth = search.depth; + while (search.Next(null) && search.depth > depth) + { + if (search.hasChildren) + parentsBelow.Add(search.instanceID); + } + } + return parentsBelow; + } + + override public void SetExpandedWithChildren(int id, bool expand) + { + HashSet oldExpandedSet = new HashSet(expandedIDs); + HashSet candidates = GetParentsBelow(id); + + if (expand) + oldExpandedSet.UnionWith(candidates); + else + oldExpandedSet.ExceptWith(candidates); + + SetExpandedIDs(oldExpandedSet.ToArray()); + } + } internal class ProjectBrowserColumnOneTreeViewDragging : AssetsTreeViewDragging diff --git a/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs b/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs index 8eac45eb29..c9a02e44eb 100644 --- a/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs +++ b/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs @@ -119,10 +119,10 @@ public void SetResults(int[] instanceIDs) var rootPath = "Assets"; var path = AssetDatabase.GetAssetPath(instanceIDs[i]); - var pathComponents = path.Split('/'); + var packageInfo = PackageManager.Packages.GetForAssetPath(path); // Find the right rootPath if folderPath is part of a package - if (pathComponents.Length > 1 && pathComponents[0] == UnityEditor.PackageManager.Folders.GetPackagesMountPoint()) - rootPath = pathComponents[0] + "/" + pathComponents[1]; + if (packageInfo != null) + rootPath = packageInfo.assetPath; rootPaths[i] = rootPath; } @@ -215,7 +215,20 @@ void SearchAllAssets() void SearchInFolders() { List list = new List(); - string[] baseFolders = ProjectWindowUtil.GetBaseFolders(m_SearchFilter.folders); + List baseFolders = new List(); + baseFolders.AddRange(ProjectWindowUtil.GetBaseFolders(m_SearchFilter.folders)); + if (baseFolders.Remove(PackageManager.Folders.GetPackagesMountPoint())) + { + var packages = PackageManager.Packages.GetAll(); + foreach (var package in packages) + { + if (package.source == PackageManager.PackageSource.BuiltIn) + continue; + + if (!baseFolders.Contains(package.assetPath)) + baseFolders.Add(package.assetPath); + } + } foreach (string folderPath in baseFolders) { @@ -241,10 +254,32 @@ void FolderBrowsing() // We are not concerned with assets being added multiple times as we only show the contents // of each selected folder. This is an issue when searching recursively into child folders. List list = new List(); + HierarchyProperty property; foreach (string folderPath in m_SearchFilter.folders) { + if (folderPath == PackageManager.Folders.GetPackagesMountPoint()) + { + var packages = PackageManager.Packages.GetAll(); + foreach (var package in packages) + { + if (package.source == PackageManager.PackageSource.BuiltIn) + continue; + + var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath); + property = new HierarchyProperty(package.assetPath); + if (property.Find(packageFolderInstanceId, null)) + { + FilterResult result = new FilterResult(); + CopyPropertyData(ref result, property); + result.name = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name; + list.Add(result); + } + } + continue; + } + int folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folderPath); - HierarchyProperty property = new HierarchyProperty(folderPath); + property = new HierarchyProperty(folderPath); property.SetSearchFilter(m_SearchFilter); int folderDepth = property.depth; diff --git a/Editor/Mono/ProjectWindow/ProjectWindowUtil.cs b/Editor/Mono/ProjectWindow/ProjectWindowUtil.cs index 8a65752064..60dc55732d 100644 --- a/Editor/Mono/ProjectWindow/ProjectWindowUtil.cs +++ b/Editor/Mono/ProjectWindow/ProjectWindowUtil.cs @@ -669,7 +669,7 @@ internal static bool DeleteAssets(List instanceIDs, bool askIfSure) if (instanceIDs.Count == 0) return true; - bool foundAssetsFolder = instanceIDs.IndexOf(ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID()) >= 0; + bool foundAssetsFolder = instanceIDs.IndexOf(AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets")) >= 0; if (foundAssetsFolder) { string title = "Cannot Delete"; diff --git a/Editor/Mono/SceneView/CameraFlyModeContext.cs b/Editor/Mono/SceneView/CameraFlyModeContext.cs index d5afe0d884..64373836fb 100644 --- a/Editor/Mono/SceneView/CameraFlyModeContext.cs +++ b/Editor/Mono/SceneView/CameraFlyModeContext.cs @@ -3,6 +3,7 @@ // https://unity3d.com/legal/licenses/Unity_Reference_Only_License using System; +using System.Collections.Generic; using UnityEditor.ShortcutManagement; using UnityEngine; @@ -12,25 +13,33 @@ class CameraFlyModeContext : IShortcutPriorityContext { public struct InputSamplingScope : IDisposable { - public bool currentlyMoving => m_Context.active && !Mathf.Approximately(currentInputVector.sqrMagnitude, 0f); + bool active => m_ArrowKeysActive || m_Context.active; - public Vector3 currentInputVector => m_Context.active ? s_CurrentInputVector : Vector3.zero; + public bool currentlyMoving => active && !Mathf.Approximately(currentInputVector.sqrMagnitude, 0f); - public bool inputVectorChanged => m_Context.active && !Mathf.Approximately((s_CurrentInputVector - m_Context.m_PreviousVector).sqrMagnitude, 0f); + public Vector3 currentInputVector => active ? s_CurrentInputVector : Vector3.zero; + public bool inputVectorChanged => active && !Mathf.Approximately((s_CurrentInputVector - m_Context.m_PreviousVector).sqrMagnitude, 0f); + + readonly bool m_ArrowKeysActive; bool m_Disposed; readonly CameraFlyModeContext m_Context; - public InputSamplingScope(CameraFlyModeContext context) + // controlID will get hotControl if using arrow keys while shortcut context is not active + // passing a value of zero disables the arrow keys + public InputSamplingScope(CameraFlyModeContext context, int controlID, bool orthographic = false) { + m_ArrowKeysActive = false; m_Disposed = false; m_Context = context; + if (!context.active) + m_ArrowKeysActive = DoArrowKeys(controlID, orthographic); + else + ShortcutController.priorityContext = context; + if (currentlyMoving && Mathf.Approximately(m_Context.m_PreviousVector.sqrMagnitude, 0f)) s_Timer.Begin(); - - if (context.active) - ShortcutController.priorityContext = context; } public void Dispose() @@ -40,6 +49,49 @@ public void Dispose() m_Disposed = true; m_Context.m_PreviousVector = currentInputVector; } + + static readonly Dictionary> s_ArrowKeyBindings = + new Dictionary> + { + { KeyCode.UpArrow, (orthographic, args) => { if (orthographic) WalkUp(args); else WalkForward(args); } }, + { KeyCode.DownArrow, (orthographic, args) => { if (orthographic) WalkDown(args); else WalkBackward(args); } }, + { KeyCode.LeftArrow, (orthographic, args) => WalkLeft(args) }, + { KeyCode.RightArrow, (orthographic, args) => WalkRight(args) }, + }; + static readonly HashSet s_ArrowKeysDown = new HashSet(); + + bool DoArrowKeys(int id, bool orthographic) + { + if (id == 0 || GUIUtility.hotControl != 0 && GUIUtility.hotControl != id) + return false; + if (EditorGUI.actionKey) + return false; + + Action action; + var evt = Event.current; + switch (evt.GetTypeForControl(id)) + { + case EventType.KeyDown: + if (!s_ArrowKeyBindings.TryGetValue(evt.keyCode, out action)) + return false; + action(orthographic, new ShortcutArguments { state = ShortcutState.Begin }); + GUIUtility.hotControl = id; + s_ArrowKeysDown.Add(evt.keyCode); + evt.Use(); + return true; + case EventType.KeyUp: + if (!s_ArrowKeyBindings.TryGetValue(evt.keyCode, out action)) + return false; + action(orthographic, new ShortcutArguments { state = ShortcutState.End }); + s_ArrowKeysDown.Remove(evt.keyCode); + if (s_ArrowKeysDown.Count == 0) + GUIUtility.hotControl = 0; + evt.Use(); + return true; + default: + return GUIUtility.hotControl == id; + } + } } public bool active { get; set; } diff --git a/Editor/Mono/SceneView/SceneView.cs b/Editor/Mono/SceneView/SceneView.cs index 353bdccf4e..cec11c8283 100644 --- a/Editor/Mono/SceneView/SceneView.cs +++ b/Editor/Mono/SceneView/SceneView.cs @@ -1805,7 +1805,6 @@ internal void OnGUI() // Do not pass the camera transform to the SceneViewMotion calculations. // The camera transform is calculation *output* not *input*. // Avoiding using it as input too avoids errors accumulating. - SceneViewMotion.ArrowKeys(this); SceneViewMotion.DoViewTool(this); } diff --git a/Editor/Mono/SceneView/SceneViewMotion.cs b/Editor/Mono/SceneView/SceneViewMotion.cs index ac327728ee..930ee6e024 100644 --- a/Editor/Mono/SceneView/SceneViewMotion.cs +++ b/Editor/Mono/SceneView/SceneViewMotion.cs @@ -28,109 +28,6 @@ enum MotionState static readonly CameraFlyModeContext s_CameraFlyModeContext = new CameraFlyModeContext(); - // CURSOR KEYS - public static void ArrowKeys(SceneView sv) - { - Event evt = Event.current; - int id = GUIUtility.GetControlID(FocusType.Passive); - if (GUIUtility.hotControl == 0 || GUIUtility.hotControl == id) - { - if (EditorGUI.actionKey) - return; - switch (evt.GetTypeForControl(id)) - { - case EventType.KeyDown: - switch (evt.keyCode) - { - case KeyCode.UpArrow: - sv.viewIsLockedToObject = false; - if (sv.m_Ortho.value) - s_Motion.y = 1; - else - s_Motion.z = 1; - GUIUtility.hotControl = id; - evt.Use(); - break; - case KeyCode.DownArrow: - sv.viewIsLockedToObject = false; - if (sv.m_Ortho.value) - s_Motion.y = -1; - else - s_Motion.z = -1; - GUIUtility.hotControl = id; - evt.Use(); - break; - case KeyCode.LeftArrow: - sv.viewIsLockedToObject = false; - s_Motion.x = -1; - GUIUtility.hotControl = id; - evt.Use(); - break; - case KeyCode.RightArrow: - sv.viewIsLockedToObject = false; - s_Motion.x = 1; - GUIUtility.hotControl = id; - evt.Use(); - break; - } - break; - - case EventType.KeyUp: - if (GUIUtility.hotControl == id) - { - switch (evt.keyCode) - { - case KeyCode.UpArrow: - case KeyCode.DownArrow: - s_Motion.z = 0; - s_Motion.y = 0; - evt.Use(); - break; - case KeyCode.LeftArrow: - case KeyCode.RightArrow: - s_Motion.x = 0; - evt.Use(); - break; - } - } - - break; - - case EventType.Layout: - if (GUIUtility.hotControl == id) - { - Vector3 fwd; - if (!sv.m_Ortho.value) - { - fwd = Camera.current.transform.forward + Camera.current.transform.up * .3f; - fwd.y = 0; - fwd.Normalize(); - } - else - { - fwd = Camera.current.transform.forward; - } - Vector3 motion = GetMovementDirection(); - sv.LookAtDirect(sv.pivot + Quaternion.LookRotation(fwd) * motion, sv.rotation); - - // If we're done, stop animating - if (s_Motion.sqrMagnitude == 0) - { - sv.pivot = sv.pivot; - s_FlySpeed = 0; - GUIUtility.hotControl = 0; - } - else - { - sv.Repaint(); - } - } - break; - } - } - } - - // HANDLE THE VIEW TOOL & ALT COMBOS public static void DoViewTool(SceneView view) { Event evt = Event.current; @@ -147,7 +44,7 @@ public static void DoViewTool(SceneView view) } s_CameraFlyModeContext.active = Tools.viewTool == ViewTool.FPS; - using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(s_CameraFlyModeContext)) + using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(s_CameraFlyModeContext, id, view.orthographic)) { if (inputSamplingScope.currentlyMoving) view.viewIsLockedToObject = false; @@ -435,10 +332,6 @@ private static void HandleMouseDrag(SceneView view, int id) } } break; - - default: - Debug.Log("Enum value Tools.s_LockViewTool not handled"); - break; } evt.Use(); } diff --git a/Modules/Audio/Public/ScriptBindings/AudioPlayableOutput.bindings.cs b/Modules/Audio/Public/ScriptBindings/AudioPlayableOutput.bindings.cs index 2f931407af..c0f628da39 100644 --- a/Modules/Audio/Public/ScriptBindings/AudioPlayableOutput.bindings.cs +++ b/Modules/Audio/Public/ScriptBindings/AudioPlayableOutput.bindings.cs @@ -72,9 +72,21 @@ public void SetTarget(AudioSource value) InternalSetTarget(ref m_Handle, value); } + public bool GetEvaluateOnSeek() + { + return InternalGetEvaluateOnSeek(ref m_Handle); + } + + public void SetEvaluateOnSeek(bool value) + { + InternalSetEvaluateOnSeek(ref m_Handle, value); + } + // Bindings methods. extern private static AudioSource InternalGetTarget(ref PlayableOutputHandle output); extern private static void InternalSetTarget(ref PlayableOutputHandle output, AudioSource target); + extern private static bool InternalGetEvaluateOnSeek(ref PlayableOutputHandle output); + extern private static void InternalSetEvaluateOnSeek(ref PlayableOutputHandle output, bool value); } } diff --git a/Modules/GraphViewEditor/Manipulators/EdgeDragHelper.cs b/Modules/GraphViewEditor/Manipulators/EdgeDragHelper.cs index e98eeea7ff..d9b33ec298 100644 --- a/Modules/GraphViewEditor/Manipulators/EdgeDragHelper.cs +++ b/Modules/GraphViewEditor/Manipulators/EdgeDragHelper.cs @@ -56,10 +56,11 @@ public override void Reset(bool didConnect = false) if (m_CompatiblePorts != null) { // Reset the highlights. - foreach (Port compatiblePort in m_CompatiblePorts) - { - compatiblePort.highlight = true; - } + m_GraphView.ports.ForEach((p) => { + p.highlight = true; + p.SetEnabled(true); + }); + m_CompatiblePorts = null; } // Clean up ghost edge. @@ -87,10 +88,15 @@ public override void Reset(bool didConnect = false) m_GhostEdge.output = null; } + if (draggedPort != null && !didConnect) + { + draggedPort.portCapLit = false; + draggedPort = null; + } + m_GhostEdge = null; edgeCandidate = null; - draggedPort = null; - m_CompatiblePorts = null; + m_GraphView = null; } @@ -137,7 +143,10 @@ public override bool HandleMouseDown(MouseDownEvent evt) m_CompatiblePorts = m_GraphView.GetCompatiblePorts(draggedPort, s_nodeAdapter); // Only light compatible anchors when dragging an edge. - m_GraphView.ports.ForEach((p) => p.highlight = false); + m_GraphView.ports.ForEach((p) => { + p.highlight = false; + p.SetEnabled(false); + }); foreach (Port compatiblePort in m_CompatiblePorts) { @@ -258,7 +267,10 @@ public override void HandleMouseUp(MouseUpEvent evt) Vector2 mousePosition = evt.mousePosition; // Reset the highlights. - m_GraphView.ports.ForEach((p) => p.highlight = true); + m_GraphView.ports.ForEach((p) => { + p.highlight = true; + p.SetEnabled(true); + }); // Clean up ghost edges. if (m_GhostEdge != null) diff --git a/Modules/PackageManager/Editor/Managed/PackageInfo.cs b/Modules/PackageManager/Editor/Managed/PackageInfo.cs index 813609297f..ddfe435f4f 100644 --- a/Modules/PackageManager/Editor/Managed/PackageInfo.cs +++ b/Modules/PackageManager/Editor/Managed/PackageInfo.cs @@ -35,6 +35,10 @@ public class PackageInfo [NativeName("resolvedPath")] private string m_ResolvedPath = ""; + [SerializeField] + [NativeName("assetPath")] + private string m_AssetPath = ""; + [SerializeField] [NativeName("name")] private string m_Name = ""; @@ -77,6 +81,7 @@ private PackageInfo() {} public string version { get { return m_Version; } } public PackageSource source { get { return m_Source; } } public string resolvedPath { get { return m_ResolvedPath; } } + public string assetPath { get { return m_AssetPath; } } public string name { get { return m_Name; } } public string displayName { get { return m_DisplayName; } } public string category { get { return m_Category; } } diff --git a/Modules/PackageManager/Editor/Managed/PackageManager.cs b/Modules/PackageManager/Editor/Managed/PackageManager.cs index 95f2794ce2..b6b7a3331c 100644 --- a/Modules/PackageManager/Editor/Managed/PackageManager.cs +++ b/Modules/PackageManager/Editor/Managed/PackageManager.cs @@ -18,11 +18,9 @@ public static PackageInfo GetForAssetPath(string assetPath) if (assetPath == string.Empty) throw new ArgumentException("Asset path cannot be empty.", "assetPath"); - var mountPoint = Folders.GetPackagesMountPoint(); foreach (var package in Packages.GetAll()) { - var logicalPath = mountPoint + '/' + package.name; - if (assetPath.StartsWith(logicalPath + '/')) + if (assetPath == package.assetPath || assetPath.StartsWith(package.assetPath + '/')) return package; } diff --git a/README.md b/README.md index 065bae3be6..5cbfd41b62 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b1 C# reference source code +## Unity 2018.2.0b2 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Export/GraphicsEnums.cs b/Runtime/Export/GraphicsEnums.cs index a6fbab7b2d..f488e68fb0 100644 --- a/Runtime/Export/GraphicsEnums.cs +++ b/Runtime/Export/GraphicsEnums.cs @@ -678,6 +678,12 @@ public enum RefreshMode EveryFrame = 1, ViaScripting = 2, } + + public enum QualityMode + { + Low = 0, + Normal = 1, + } } public enum CustomRenderTextureInitializationSource diff --git a/Runtime/Export/LightProbeProxyVolume.bindings.cs b/Runtime/Export/LightProbeProxyVolume.bindings.cs index 3ce4f0ad5d..e391212de2 100644 --- a/Runtime/Export/LightProbeProxyVolume.bindings.cs +++ b/Runtime/Export/LightProbeProxyVolume.bindings.cs @@ -37,6 +37,8 @@ public sealed partial class LightProbeProxyVolume : Behaviour public extern LightProbeProxyVolume.RefreshMode refreshMode { get; set; } + public extern LightProbeProxyVolume.QualityMode qualityMode { get; set; } + public void Update() { SetDirtyFlag(true); From fdf1203189e02d257a055dce21206434476b84bc Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Fri, 4 May 2018 00:29:00 +0000 Subject: [PATCH 02/13] Unity 2018.2.0b3 C# reference source code --- .../SpriteFrameModule/SpriteFrameModule.cs | 6 + .../SpriteFrameModuleBase.cs | 31 +- .../SpriteFrameModuleBaseView.cs | 65 ++- .../SpritePolygonModeModule.cs | 20 + .../SpritePolygonModeModuleView.cs | 6 + Editor/Mono/AssemblyInfo/AssemblyInfo.cs | 1 + .../AssetPipeline/TextureImporter.bindings.cs | 1 - .../TextureImporterTypes.bindings.cs | 9 - .../Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs | 2 +- Editor/Mono/BuildPlayerSceneTreeView.cs | 7 +- Editor/Mono/EditorBuildSettings.bindings.cs | 14 +- Editor/Mono/GameView/GameView.cs | 2 +- .../Inspector/Avatar/AvatarMuscleEditor.cs | 390 +++++++++--------- Editor/Mono/Inspector/CameraEditor.cs | 15 +- .../HolographicEmulationWindow.cs | 38 +- Editor/Mono/SceneView/SceneView.cs | 8 + .../ScriptCompilation/EditorCompilation.cs | 15 + .../EditorCompilationInterface.cs | 7 + .../ScriptBindings/Physics2D.bindings.cs | 136 ++++-- .../ProfilerDetailedCallsView.cs | 274 ++++++------ .../ProfilerWindow/ProfilerWindow.cs | 12 +- .../EditorAnalytics.bindings.cs | 5 + Projects/CSharp/UnityEditor.csproj | 4 +- Projects/CSharp/UnityEngine.csproj | 17 +- README.md | 2 +- .../Managed/IAnimationJobPlayable.cs | 2 +- .../AnimationHumanStream.bindings.cs | 46 ++- .../AnimationScriptPlayable.bindings.cs | 12 +- .../AnimationStream.bindings.cs | 42 +- .../AnimationStreamHandles.bindings.cs | 122 +++--- .../ScriptBindings/Animator.bindings.cs | 8 +- .../ScriptBindings/Avatar.bindings.cs | 68 +-- .../ScriptBindings/HumanTrait.bindings.cs | 3 +- .../ScriptBindings/MuscleHandle.bindings.cs | 67 ++- Runtime/Export/AssemblyInfo.cs | 2 + Runtime/Export/PlayerLoop.bindings.cs | 4 +- .../HolographicRemoting.cs | 2 +- .../HolographicAutomation.bindings.cs | 80 ++++ ...ation.cs => HolographicAutomationUtils.cs} | 80 ++-- .../HolographicEmulation.bindings.cs | 65 +++ .../VR/HolographicEmulationBindings.gen.cs | 124 ------ 41 files changed, 1046 insertions(+), 768 deletions(-) create mode 100644 Runtime/VR/HoloLens/ScriptBindings/HolographicAutomation.bindings.cs rename Runtime/VR/HoloLens/ScriptBindings/{HolographicEmulation.cs => HolographicAutomationUtils.cs} (70%) create mode 100644 Runtime/VR/HoloLens/ScriptBindings/HolographicEmulation.bindings.cs delete mode 100644 artifacts/generated/bindings_old/common/VR/HolographicEmulationBindings.gen.cs diff --git a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModule.cs b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModule.cs index ab55b461b2..a9fd657495 100644 --- a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModule.cs +++ b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModule.cs @@ -37,6 +37,12 @@ public override void OnModuleActivate() spriteEditor.enableMouseMoveEvent = true; } + public override void OnModuleDeactivate() + { + base.OnModuleDeactivate(); + m_AlphaPixelCache = null; + } + public override bool CanBeActivated() { return SpriteUtility.GetSpriteImportMode(spriteEditor.GetDataProvider()) != SpriteImportMode.Polygon; diff --git a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBase.cs b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBase.cs index d02d3f8086..c5b430f180 100644 --- a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBase.cs +++ b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBase.cs @@ -28,6 +28,14 @@ internal abstract partial class SpriteFrameModuleBase : SpriteEditorModuleBase protected ISpriteEditorDataProvider m_SpriteDataProvider; string m_ModuleName; + internal enum PivotUnitMode + { + Normalized, + Pixels + } + + private PivotUnitMode m_PivotUnitMode = PivotUnitMode.Normalized; + protected SpriteFrameModuleBase(string name, ISpriteEditor sw, IEventSystem es, IUndoSystem us, IAssetDatabase ad) { spriteEditor = sw; @@ -169,6 +177,16 @@ public Vector2 selectedSpritePivot get { return selected.pivot; } } + private Vector2 selectedSpritePivotInCurUnitMode + { + get + { + return m_PivotUnitMode == PivotUnitMode.Pixels + ? ConvertFromNormalizedToRectSpace(selectedSpritePivot, selectedSpriteRect) + : selectedSpritePivot; + } + } + public int CurrentSelectedSpriteIndex() { if (m_RectsCache != null && selected != null) @@ -261,7 +279,7 @@ public bool containsMultipleSprites get { return spriteImportMode == SpriteImportMode.Multiple; } } - protected void SnapPivot(Vector2 pivot, out Vector2 outPivot, out SpriteAlignment outAlignment) + protected void SnapPivotToSnapPoints(Vector2 pivot, out Vector2 outPivot, out SpriteAlignment outAlignment) { Rect rect = selectedSpriteRect; @@ -287,6 +305,17 @@ protected void SnapPivot(Vector2 pivot, out Vector2 outPivot, out SpriteAlignmen outPivot = ConvertFromTextureToNormalizedSpace(snapPoints[(int)snappedAlignment], rect); } + protected void SnapPivotToPixels(Vector2 pivot, out Vector2 outPivot, out SpriteAlignment outAlignment) + { + outAlignment = SpriteAlignment.Custom; + + Rect rect = selectedSpriteRect; + float unitsPerPixelX = 1.0f / rect.width; + float unitsPerPixelY = 1.0f / rect.height; + outPivot.x = Mathf.Round(pivot.x / unitsPerPixelX) * unitsPerPixelX; + outPivot.y = Mathf.Round(pivot.y / unitsPerPixelY) * unitsPerPixelY; + } + private void UndoCallback() { UIUndoCallback(); diff --git a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBaseView.cs b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBaseView.cs index 21f5e6f8f5..055a6b2477 100644 --- a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBaseView.cs +++ b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBaseView.cs @@ -63,6 +63,7 @@ protected static Styles styles private const float kInspectorWidth = 330f; private const float kInspectorHeight = 170; + private const float kPivotFieldPrecision = 0.0001f; private float m_Zoom = 1.0f; private GizmoMode m_GizmoMode; @@ -78,6 +79,7 @@ protected static Styles styles private PropertyControl m_BorderFieldR; private PropertyControl m_BorderFieldB; private EnumField m_PivotField; + private EnumField m_PivotUnitModeField; private VisualElement m_CustomPivotElement; private PropertyControl m_CustomPivotFieldX; private PropertyControl m_CustomPivotFieldY; @@ -221,8 +223,25 @@ private void AddMainUI(VisualElement mainView) SpriteAlignment alignment = (SpriteAlignment)evt.newValue; SetSpritePivotAndAlignment(selectedSpritePivot, alignment); m_CustomPivotElement.SetEnabled(selectedSpriteAlignment == SpriteAlignment.Custom); - m_CustomPivotFieldX.value = selectedSpritePivot.x; - m_CustomPivotFieldY.value = selectedSpritePivot.y; + + Vector2 pivot = selectedSpritePivotInCurUnitMode; + m_CustomPivotFieldX.value = pivot.x; + m_CustomPivotFieldY.value = pivot.y; + } + }); + + + m_PivotUnitModeField = m_SelectedFrameInspector.Q("pivotUnitModeField"); + m_PivotUnitModeField.Init(PivotUnitMode.Normalized); + m_PivotUnitModeField.OnValueChanged((evt) => + { + if (hasSelected) + { + m_PivotUnitMode = (PivotUnitMode)evt.newValue; + + Vector2 pivot = selectedSpritePivotInCurUnitMode; + m_CustomPivotFieldX.value = pivot.x; + m_CustomPivotFieldY.value = pivot.y; } }); @@ -233,8 +252,13 @@ private void AddMainUI(VisualElement mainView) { if (hasSelected) { + float newValue = (float)evt.newValue; + float pivotX = m_PivotUnitMode == PivotUnitMode.Pixels + ? ConvertFromRectToNormalizedSpace(new Vector2(newValue, 0.0f), selectedSpriteRect).x + : newValue; + var pivot = selectedSpritePivot; - pivot.x = (float)evt.newValue; + pivot.x = pivotX; SetSpritePivotAndAlignment(pivot, selectedSpriteAlignment); } }); @@ -244,8 +268,13 @@ private void AddMainUI(VisualElement mainView) { if (hasSelected) { + float newValue = (float)evt.newValue; + float pivotY = m_PivotUnitMode == PivotUnitMode.Pixels + ? ConvertFromRectToNormalizedSpace(new Vector2(0.0f, newValue), selectedSpriteRect).y + : newValue; + var pivot = selectedSpritePivot; - pivot.y = (float)evt.newValue; + pivot.y = pivotY; SetSpritePivotAndAlignment(pivot, selectedSpriteAlignment); } }); @@ -294,8 +323,12 @@ protected void PopulateSpriteFrameInspectorField() m_BorderFieldR.value = Mathf.RoundToInt(spriteBorder.z); m_BorderFieldB.value = Mathf.RoundToInt(spriteBorder.w); m_PivotField.value = selectedSpriteAlignment; - m_CustomPivotFieldX.value = (selectedSpritePivot.x); - m_CustomPivotFieldY.value = (selectedSpritePivot.y); + m_PivotUnitModeField.value = m_PivotUnitMode; + + Vector2 pivot = selectedSpritePivotInCurUnitMode; + m_CustomPivotFieldX.value = pivot.x; + m_CustomPivotFieldY.value = pivot.y; + m_CustomPivotElement.SetEnabled(hasSelected && selectedSpriteAlignment == SpriteAlignment.Custom); } @@ -315,6 +348,22 @@ private static Vector2 ConvertFromTextureToNormalizedSpace(Vector2 texturePos, R return new Vector2((texturePos.x - rect.xMin) / rect.width, (texturePos.y - rect.yMin) / rect.height); } + private static Vector2 ConvertFromNormalizedToRectSpace(Vector2 normalizedPos, Rect rect) + { + Vector2 rectPos = new Vector2(rect.width * normalizedPos.x, rect.height * normalizedPos.y); + + // This is to combat the lack of precision formating on the UI controls. + rectPos.x = Mathf.Round(rectPos.x / kPivotFieldPrecision) * kPivotFieldPrecision; + rectPos.y = Mathf.Round(rectPos.y / kPivotFieldPrecision) * kPivotFieldPrecision; + + return rectPos; + } + + private static Vector2 ConvertFromRectToNormalizedSpace(Vector2 rectPos, Rect rect) + { + return new Vector2(rectPos.x / rect.width, rectPos.y / rect.height); + } + private static Vector2[] GetSnapPointsArray(Rect rect) { Vector2[] snapPoints = new Vector2[9]; @@ -375,7 +424,9 @@ protected void HandlePivotHandle() { // Pivot snapping only happen when ctrl is press. Same as scene view snapping move if (eventSystem.current.control) - SnapPivot(pivotHandlePosition, out pivot, out alignment); + SnapPivotToSnapPoints(pivotHandlePosition, out pivot, out alignment); + else if (m_PivotUnitMode == PivotUnitMode.Pixels) + SnapPivotToPixels(pivotHandlePosition, out pivot, out alignment); else { pivot = pivotHandlePosition; diff --git a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpritePolygonModeModule.cs b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpritePolygonModeModule.cs index a4a72de619..d6d5b010fa 100644 --- a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpritePolygonModeModule.cs +++ b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpritePolygonModeModule.cs @@ -56,6 +56,7 @@ private void DeterminePolygonSides() else // If for reasons we cannot determine the sides of the polygon, fall back to 0 (Square) polygonSides = 0; + ViewUpdateSideCountField(); } public int GetPolygonSideCount() @@ -92,5 +93,24 @@ public void GeneratePolygonOutline() } Repaint(); } + + public override bool ApplyRevert(bool apply) + { + var outlineProvider = spriteEditor.GetDataProvider(); + if (apply) + { + for (int i = 0; i < m_RectsCache.spriteRects.Count && i < m_Outline.Count; ++i) + outlineProvider.SetOutlines(m_RectsCache.spriteRects[i].spriteID, m_Outline[i]); + } + else + { + m_Outline.Clear(); + for (int i = 0; i < m_RectsCache.spriteRects.Count; ++i) + m_Outline.Add(outlineProvider.GetOutlines(m_RectsCache.spriteRects[i].spriteID)); + DeterminePolygonSides(); + ViewUpdateSideCountField(); + } + return base.ApplyRevert(apply); + } } } diff --git a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpritePolygonModeModuleView.cs b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpritePolygonModeModuleView.cs index b923d44c53..309b69c01a 100644 --- a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpritePolygonModeModuleView.cs +++ b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpritePolygonModeModuleView.cs @@ -87,6 +87,12 @@ private void DrawGizmos() DrawSpriteRectGizmos(); } + private void ViewUpdateSideCountField() + { + var sidesField = m_PolygonShapeView.Q>("labelIntegerField"); + sidesField.value = polygonSides; + } + private void SetupPolygonChangeShapeWindowElements(VisualElement moduleView) { var sidesField = moduleView.Q>("labelIntegerField"); diff --git a/Editor/Mono/AssemblyInfo/AssemblyInfo.cs b/Editor/Mono/AssemblyInfo/AssemblyInfo.cs index b5eba4de52..c7e87c7e5c 100644 --- a/Editor/Mono/AssemblyInfo/AssemblyInfo.cs +++ b/Editor/Mono/AssemblyInfo/AssemblyInfo.cs @@ -55,6 +55,7 @@ [assembly: InternalsVisibleTo("UnityEditor.AR")] [assembly: InternalsVisibleTo("UnityEditor.SpatialTracking")] [assembly: InternalsVisibleTo("UnityEditor.HoloLens")] +[assembly: InternalsVisibleTo("Unity.WindowsMRAutomation")] [assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridge.001")] [assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridge.002")] [assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridge.003")] diff --git a/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs b/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs index 27b6e32588..48cdb6f962 100644 --- a/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs +++ b/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs @@ -209,7 +209,6 @@ public void SetPlatformTextureSettings(string platform, int maxTextureSize, Text public extern int mipmapFadeDistanceStart { get; set; } // Mip level where texture is faded out completely. public extern int mipmapFadeDistanceEnd { get; set; } - public extern bool pushPullDilation { get; set; } // Should mip maps be generated with gamma correction? [Obsolete("generateMipsInLinearSpace Property deprecated. Mipmaps are always generated in linear space.")] diff --git a/Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs b/Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs index be7349582b..f3a63010e5 100644 --- a/Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs +++ b/Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs @@ -106,9 +106,6 @@ public sealed partial class TextureImporterSettings [SerializeField] int m_SingleChannelComponent; - [SerializeField] - int m_PushPullDilation; - // memory layout of these is in TextureSettings.h [SerializeField] [NativeName("m_TextureSettings.m_FilterMode")] @@ -259,12 +256,6 @@ public TextureImporterSingleChannelComponent singleChannelComponent set { m_SingleChannelComponent = (int)value; } } - public bool pushPullDilation - { - get { return m_PushPullDilation != 0; } - set { m_PushPullDilation = value ? 1 : 0; } - } - public bool readable { get {return m_IsReadable != 0; } diff --git a/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs b/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs index b3bee1911f..fb11bfa257 100644 --- a/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs +++ b/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs @@ -124,7 +124,7 @@ internal static bool UseIl2CppCodegenWithMonoBackend(BuildTargetGroup targetGrou internal static bool EnableIL2CPPDebugger(BuildTargetGroup targetGroup) { - if (!EditorUserBuildSettings.allowDebugging) + if (!EditorUserBuildSettings.allowDebugging || !EditorUserBuildSettings.development) return false; switch (PlayerSettings.GetApiCompatibilityLevel(targetGroup)) diff --git a/Editor/Mono/BuildPlayerSceneTreeView.cs b/Editor/Mono/BuildPlayerSceneTreeView.cs index f84f26c7fb..5d675cc6dc 100644 --- a/Editor/Mono/BuildPlayerSceneTreeView.cs +++ b/Editor/Mono/BuildPlayerSceneTreeView.cs @@ -36,13 +36,12 @@ public void UpdateName() } } - public BuildPlayerSceneTreeViewItem(int id, int depth, string path, bool state) : base(id, depth) + public BuildPlayerSceneTreeViewItem(int id, int depth, GUID g, bool state) : base(id, depth) { active = state; counter = kInvalidCounter; - guid = new GUID(AssetDatabase.AssetPathToGUID(path)); + guid = g; fullName = ""; - displayName = path; UpdateName(); } } @@ -72,7 +71,7 @@ protected override TreeViewItem BuildRoot() List scenes = new List(EditorBuildSettings.scenes); foreach (var sc in scenes) { - var item = new BuildPlayerSceneTreeViewItem(sc.guid.GetHashCode(), 0, sc.path, sc.enabled); + var item = new BuildPlayerSceneTreeViewItem(sc.guid.GetHashCode(), 0, sc.guid, sc.enabled); root.AddChild(item); } return root; diff --git a/Editor/Mono/EditorBuildSettings.bindings.cs b/Editor/Mono/EditorBuildSettings.bindings.cs index b0b580cfde..f8c11af2e1 100644 --- a/Editor/Mono/EditorBuildSettings.bindings.cs +++ b/Editor/Mono/EditorBuildSettings.bindings.cs @@ -76,7 +76,19 @@ public static EditorBuildSettingsScene[] scenes { get { - return GetEditorBuildSettingsScenes(); + var result = GetEditorBuildSettingsScenes(); + foreach (var scene in result) + { + if (scene.guid.Empty()) + { + scene.guid = new GUID(AssetDatabase.AssetPathToGUID(scene.path)); + } + else + { + scene.path = AssetDatabase.GUIDToAssetPath(scene.guid.ToString()); + } + } + return result; } set { diff --git a/Editor/Mono/GameView/GameView.cs b/Editor/Mono/GameView/GameView.cs index ac29cca869..427402cd51 100644 --- a/Editor/Mono/GameView/GameView.cs +++ b/Editor/Mono/GameView/GameView.cs @@ -513,7 +513,7 @@ void DoZoomSlider() var newZoom = Mathf.Pow(10f, logScale); SnapZoom(newZoom); } - var scaleContent = EditorGUIUtility.TempContent(string.Format("{0}x", (m_ZoomArea.scale.y).ToString("G2"))); + var scaleContent = EditorGUIUtility.TempContent(string.Format("{0}x", (m_ZoomArea.scale.y).ToString("G3"))); scaleContent.tooltip = Styles.zoomSliderContent.tooltip; GUILayout.Label(scaleContent, EditorStyles.miniLabel, GUILayout.Width(kScaleLabelWidth)); scaleContent.tooltip = string.Empty; diff --git a/Editor/Mono/Inspector/Avatar/AvatarMuscleEditor.cs b/Editor/Mono/Inspector/Avatar/AvatarMuscleEditor.cs index d65f91a1ec..497f132a46 100644 --- a/Editor/Mono/Inspector/Avatar/AvatarMuscleEditor.cs +++ b/Editor/Mono/Inspector/Avatar/AvatarMuscleEditor.cs @@ -68,123 +68,123 @@ public Styles() // This list containt the mecanim's musle id for each muscle group protected int[][] m_Muscles = { - new int[] { (int)DoF.BodyDoFStart + (int)BodyDoF.SpineFrontBack, - (int)DoF.BodyDoFStart + (int)BodyDoF.SpineLeftRight, - (int)DoF.BodyDoFStart + (int)BodyDoF.SpineRollLeftRight, - (int)DoF.BodyDoFStart + (int)BodyDoF.ChestFrontBack, - (int)DoF.BodyDoFStart + (int)BodyDoF.ChestLeftRight, - (int)DoF.BodyDoFStart + (int)BodyDoF.ChestRollLeftRight, - (int)DoF.BodyDoFStart + (int)BodyDoF.UpperChestFrontBack, - (int)DoF.BodyDoFStart + (int)BodyDoF.UpperChestLeftRight, - (int)DoF.BodyDoFStart + (int)BodyDoF.UpperChestRollLeftRight}, - - new int[] { (int)DoF.HeadDoFStart + (int)HeadDoF.NeckFrontBack, - (int)DoF.HeadDoFStart + (int)HeadDoF.NeckLeftRight, - (int)DoF.HeadDoFStart + (int)HeadDoF.NeckRollLeftRight, - (int)DoF.HeadDoFStart + (int)HeadDoF.HeadFrontBack, - (int)DoF.HeadDoFStart + (int)HeadDoF.HeadLeftRight, - (int)DoF.HeadDoFStart + (int)HeadDoF.HeadRollLeftRight, - (int)DoF.HeadDoFStart + (int)HeadDoF.LeftEyeDownUp, - (int)DoF.HeadDoFStart + (int)HeadDoF.LeftEyeInOut, - (int)DoF.HeadDoFStart + (int)HeadDoF.RightEyeDownUp, - (int)DoF.HeadDoFStart + (int)HeadDoF.RightEyeInOut, - (int)DoF.HeadDoFStart + (int)HeadDoF.JawDownUp, - (int)DoF.HeadDoFStart + (int)HeadDoF.JawLeftRight}, - - new int[] { (int)DoF.LeftArmDoFStart + (int)ArmDoF.ShoulderDownUp, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ShoulderFrontBack, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ArmDownUp, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ArmFrontBack, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ArmRollInOut, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ForeArmCloseOpen, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ForeArmRollInOut, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.HandDownUp, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.HandInOut}, + new int[] { (int)Dof.BodyDofStart + (int)BodyDof.SpineFrontBack, + (int)Dof.BodyDofStart + (int)BodyDof.SpineLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.SpineRollLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.ChestFrontBack, + (int)Dof.BodyDofStart + (int)BodyDof.ChestLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.ChestRollLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.UpperChestFrontBack, + (int)Dof.BodyDofStart + (int)BodyDof.UpperChestLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.UpperChestRollLeftRight}, + + new int[] { (int)Dof.HeadDofStart + (int)HeadDof.NeckFrontBack, + (int)Dof.HeadDofStart + (int)HeadDof.NeckLeftRight, + (int)Dof.HeadDofStart + (int)HeadDof.NeckRollLeftRight, + (int)Dof.HeadDofStart + (int)HeadDof.HeadFrontBack, + (int)Dof.HeadDofStart + (int)HeadDof.HeadLeftRight, + (int)Dof.HeadDofStart + (int)HeadDof.HeadRollLeftRight, + (int)Dof.HeadDofStart + (int)HeadDof.LeftEyeDownUp, + (int)Dof.HeadDofStart + (int)HeadDof.LeftEyeInOut, + (int)Dof.HeadDofStart + (int)HeadDof.RightEyeDownUp, + (int)Dof.HeadDofStart + (int)HeadDof.RightEyeInOut, + (int)Dof.HeadDofStart + (int)HeadDof.JawDownUp, + (int)Dof.HeadDofStart + (int)HeadDof.JawLeftRight}, + + new int[] { (int)Dof.LeftArmDofStart + (int)ArmDof.ShoulderDownUp, + (int)Dof.LeftArmDofStart + (int)ArmDof.ShoulderFrontBack, + (int)Dof.LeftArmDofStart + (int)ArmDof.ArmDownUp, + (int)Dof.LeftArmDofStart + (int)ArmDof.ArmFrontBack, + (int)Dof.LeftArmDofStart + (int)ArmDof.ArmRollInOut, + (int)Dof.LeftArmDofStart + (int)ArmDof.ForeArmCloseOpen, + (int)Dof.LeftArmDofStart + (int)ArmDof.ForeArmRollInOut, + (int)Dof.LeftArmDofStart + (int)ArmDof.HandDownUp, + (int)Dof.LeftArmDofStart + (int)ArmDof.HandInOut}, new int[] { - (int)DoF.LeftThumbDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftThumbDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.LeftThumbDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftThumbDoFStart + (int)FingerDoF.DistalCloseOpen, - - (int)DoF.LeftIndexDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftIndexDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.LeftIndexDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftIndexDoFStart + (int)FingerDoF.DistalCloseOpen, - - (int)DoF.LeftMiddleDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftMiddleDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.LeftMiddleDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftMiddleDoFStart + (int)FingerDoF.DistalCloseOpen, - - (int)DoF.LeftRingDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftRingDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.LeftRingDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftRingDoFStart + (int)FingerDoF.DistalCloseOpen, - - (int)DoF.LeftLittleDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftLittleDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.LeftLittleDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftLittleDoFStart + (int)FingerDoF.DistalCloseOpen + (int)Dof.LeftThumbDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftThumbDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.LeftThumbDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftThumbDofStart + (int)FingerDof.DistalCloseOpen, + + (int)Dof.LeftIndexDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftIndexDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.LeftIndexDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftIndexDofStart + (int)FingerDof.DistalCloseOpen, + + (int)Dof.LeftMiddleDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftMiddleDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.LeftMiddleDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftMiddleDofStart + (int)FingerDof.DistalCloseOpen, + + (int)Dof.LeftRingDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftRingDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.LeftRingDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftRingDofStart + (int)FingerDof.DistalCloseOpen, + + (int)Dof.LeftLittleDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftLittleDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.LeftLittleDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftLittleDofStart + (int)FingerDof.DistalCloseOpen }, - new int[] { (int)DoF.RightArmDoFStart + (int)ArmDoF.ShoulderDownUp, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ShoulderFrontBack, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ArmDownUp, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ArmFrontBack, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ArmRollInOut, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ForeArmCloseOpen, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ForeArmRollInOut, - (int)DoF.RightArmDoFStart + (int)ArmDoF.HandDownUp, - (int)DoF.RightArmDoFStart + (int)ArmDoF.HandInOut}, + new int[] { (int)Dof.RightArmDofStart + (int)ArmDof.ShoulderDownUp, + (int)Dof.RightArmDofStart + (int)ArmDof.ShoulderFrontBack, + (int)Dof.RightArmDofStart + (int)ArmDof.ArmDownUp, + (int)Dof.RightArmDofStart + (int)ArmDof.ArmFrontBack, + (int)Dof.RightArmDofStart + (int)ArmDof.ArmRollInOut, + (int)Dof.RightArmDofStart + (int)ArmDof.ForeArmCloseOpen, + (int)Dof.RightArmDofStart + (int)ArmDof.ForeArmRollInOut, + (int)Dof.RightArmDofStart + (int)ArmDof.HandDownUp, + (int)Dof.RightArmDofStart + (int)ArmDof.HandInOut}, new int[] { - (int)DoF.RightThumbDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightThumbDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightThumbDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightThumbDoFStart + (int)FingerDoF.DistalCloseOpen, - - (int)DoF.RightIndexDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightIndexDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightIndexDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightIndexDoFStart + (int)FingerDoF.DistalCloseOpen, - - (int)DoF.RightMiddleDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightMiddleDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightMiddleDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightMiddleDoFStart + (int)FingerDoF.DistalCloseOpen, - - (int)DoF.RightRingDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightRingDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightRingDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightRingDoFStart + (int)FingerDoF.DistalCloseOpen, - - (int)DoF.RightLittleDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightLittleDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightLittleDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightLittleDoFStart + (int)FingerDoF.DistalCloseOpen + (int)Dof.RightThumbDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightThumbDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightThumbDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightThumbDofStart + (int)FingerDof.DistalCloseOpen, + + (int)Dof.RightIndexDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightIndexDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightIndexDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightIndexDofStart + (int)FingerDof.DistalCloseOpen, + + (int)Dof.RightMiddleDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightMiddleDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightMiddleDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightMiddleDofStart + (int)FingerDof.DistalCloseOpen, + + (int)Dof.RightRingDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightRingDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightRingDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightRingDofStart + (int)FingerDof.DistalCloseOpen, + + (int)Dof.RightLittleDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightLittleDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightLittleDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightLittleDofStart + (int)FingerDof.DistalCloseOpen }, new int[] { - (int)DoF.LeftLegDoFStart + (int)LegDoF.UpperLegFrontBack, - (int)DoF.LeftLegDoFStart + (int)LegDoF.UpperLegInOut, - (int)DoF.LeftLegDoFStart + (int)LegDoF.UpperLegRollInOut, - (int)DoF.LeftLegDoFStart + (int)LegDoF.LegCloseOpen, - (int)DoF.LeftLegDoFStart + (int)LegDoF.LegRollInOut, - (int)DoF.LeftLegDoFStart + (int)LegDoF.FootCloseOpen, - (int)DoF.LeftLegDoFStart + (int)LegDoF.FootInOut, - (int)DoF.LeftLegDoFStart + (int)LegDoF.ToesUpDown, + (int)Dof.LeftLegDofStart + (int)LegDof.UpperLegFrontBack, + (int)Dof.LeftLegDofStart + (int)LegDof.UpperLegInOut, + (int)Dof.LeftLegDofStart + (int)LegDof.UpperLegRollInOut, + (int)Dof.LeftLegDofStart + (int)LegDof.LegCloseOpen, + (int)Dof.LeftLegDofStart + (int)LegDof.LegRollInOut, + (int)Dof.LeftLegDofStart + (int)LegDof.FootCloseOpen, + (int)Dof.LeftLegDofStart + (int)LegDof.FootInOut, + (int)Dof.LeftLegDofStart + (int)LegDof.ToesUpDown, }, new int[] { - (int)DoF.RightLegDoFStart + (int)LegDoF.UpperLegFrontBack, - (int)DoF.RightLegDoFStart + (int)LegDoF.UpperLegInOut, - (int)DoF.RightLegDoFStart + (int)LegDoF.UpperLegRollInOut, - (int)DoF.RightLegDoFStart + (int)LegDoF.LegCloseOpen, - (int)DoF.RightLegDoFStart + (int)LegDoF.LegRollInOut, - (int)DoF.RightLegDoFStart + (int)LegDoF.FootCloseOpen, - (int)DoF.RightLegDoFStart + (int)LegDoF.FootInOut, - (int)DoF.RightLegDoFStart + (int)LegDoF.ToesUpDown, + (int)Dof.RightLegDofStart + (int)LegDof.UpperLegFrontBack, + (int)Dof.RightLegDofStart + (int)LegDof.UpperLegInOut, + (int)Dof.RightLegDofStart + (int)LegDof.UpperLegRollInOut, + (int)Dof.RightLegDofStart + (int)LegDof.LegCloseOpen, + (int)Dof.RightLegDofStart + (int)LegDof.LegRollInOut, + (int)Dof.RightLegDofStart + (int)LegDof.FootCloseOpen, + (int)Dof.RightLegDofStart + (int)LegDof.FootInOut, + (int)Dof.RightLegDofStart + (int)LegDof.ToesUpDown, } }; @@ -192,129 +192,129 @@ public Styles() { // Body open close new int[] { - (int)DoF.BodyDoFStart + (int)BodyDoF.SpineFrontBack, - (int)DoF.BodyDoFStart + (int)BodyDoF.ChestFrontBack, - (int)DoF.BodyDoFStart + (int)BodyDoF.UpperChestFrontBack, - (int)DoF.HeadDoFStart + (int)HeadDoF.NeckFrontBack, - (int)DoF.HeadDoFStart + (int)HeadDoF.HeadFrontBack, - - (int)DoF.LeftLegDoFStart + (int)LegDoF.UpperLegFrontBack, - (int)DoF.LeftLegDoFStart + (int)LegDoF.LegCloseOpen, - (int)DoF.LeftLegDoFStart + (int)LegDoF.FootCloseOpen, - (int)DoF.RightLegDoFStart + (int)LegDoF.UpperLegFrontBack, - (int)DoF.RightLegDoFStart + (int)LegDoF.LegCloseOpen, - (int)DoF.RightLegDoFStart + (int)LegDoF.FootCloseOpen, - - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ShoulderDownUp, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ArmDownUp, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ForeArmCloseOpen, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.HandDownUp, - - (int)DoF.RightArmDoFStart + (int)ArmDoF.ShoulderDownUp, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ArmDownUp, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ForeArmCloseOpen, - (int)DoF.RightArmDoFStart + (int)ArmDoF.HandDownUp + (int)Dof.BodyDofStart + (int)BodyDof.SpineFrontBack, + (int)Dof.BodyDofStart + (int)BodyDof.ChestFrontBack, + (int)Dof.BodyDofStart + (int)BodyDof.UpperChestFrontBack, + (int)Dof.HeadDofStart + (int)HeadDof.NeckFrontBack, + (int)Dof.HeadDofStart + (int)HeadDof.HeadFrontBack, + + (int)Dof.LeftLegDofStart + (int)LegDof.UpperLegFrontBack, + (int)Dof.LeftLegDofStart + (int)LegDof.LegCloseOpen, + (int)Dof.LeftLegDofStart + (int)LegDof.FootCloseOpen, + (int)Dof.RightLegDofStart + (int)LegDof.UpperLegFrontBack, + (int)Dof.RightLegDofStart + (int)LegDof.LegCloseOpen, + (int)Dof.RightLegDofStart + (int)LegDof.FootCloseOpen, + + (int)Dof.LeftArmDofStart + (int)ArmDof.ShoulderDownUp, + (int)Dof.LeftArmDofStart + (int)ArmDof.ArmDownUp, + (int)Dof.LeftArmDofStart + (int)ArmDof.ForeArmCloseOpen, + (int)Dof.LeftArmDofStart + (int)ArmDof.HandDownUp, + + (int)Dof.RightArmDofStart + (int)ArmDof.ShoulderDownUp, + (int)Dof.RightArmDofStart + (int)ArmDof.ArmDownUp, + (int)Dof.RightArmDofStart + (int)ArmDof.ForeArmCloseOpen, + (int)Dof.RightArmDofStart + (int)ArmDof.HandDownUp }, // Body Left Right new int[] { - (int)DoF.BodyDoFStart + (int)BodyDoF.SpineLeftRight, - (int)DoF.BodyDoFStart + (int)BodyDoF.ChestLeftRight, - (int)DoF.BodyDoFStart + (int)BodyDoF.UpperChestLeftRight, - (int)DoF.HeadDoFStart + (int)HeadDoF.NeckLeftRight, - (int)DoF.HeadDoFStart + (int)HeadDoF.HeadLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.SpineLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.ChestLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.UpperChestLeftRight, + (int)Dof.HeadDofStart + (int)HeadDof.NeckLeftRight, + (int)Dof.HeadDofStart + (int)HeadDof.HeadLeftRight, }, // Roll Left Right new int[] { - (int)DoF.BodyDoFStart + (int)BodyDoF.SpineRollLeftRight, - (int)DoF.BodyDoFStart + (int)BodyDoF.ChestRollLeftRight, - (int)DoF.BodyDoFStart + (int)BodyDoF.UpperChestRollLeftRight, - (int)DoF.HeadDoFStart + (int)HeadDoF.NeckRollLeftRight, - (int)DoF.HeadDoFStart + (int)HeadDoF.HeadRollLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.SpineRollLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.ChestRollLeftRight, + (int)Dof.BodyDofStart + (int)BodyDof.UpperChestRollLeftRight, + (int)Dof.HeadDofStart + (int)HeadDof.NeckRollLeftRight, + (int)Dof.HeadDofStart + (int)HeadDof.HeadRollLeftRight, }, // In Out new int[] { - (int)DoF.LeftLegDoFStart + (int)LegDoF.UpperLegInOut, - (int)DoF.LeftLegDoFStart + (int)LegDoF.FootInOut, - (int)DoF.RightLegDoFStart + (int)LegDoF.UpperLegInOut, - (int)DoF.RightLegDoFStart + (int)LegDoF.FootInOut, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ShoulderFrontBack, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ArmFrontBack, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.HandInOut, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ShoulderFrontBack, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ArmFrontBack, - (int)DoF.RightArmDoFStart + (int)ArmDoF.HandInOut + (int)Dof.LeftLegDofStart + (int)LegDof.UpperLegInOut, + (int)Dof.LeftLegDofStart + (int)LegDof.FootInOut, + (int)Dof.RightLegDofStart + (int)LegDof.UpperLegInOut, + (int)Dof.RightLegDofStart + (int)LegDof.FootInOut, + (int)Dof.LeftArmDofStart + (int)ArmDof.ShoulderFrontBack, + (int)Dof.LeftArmDofStart + (int)ArmDof.ArmFrontBack, + (int)Dof.LeftArmDofStart + (int)ArmDof.HandInOut, + (int)Dof.RightArmDofStart + (int)ArmDof.ShoulderFrontBack, + (int)Dof.RightArmDofStart + (int)ArmDof.ArmFrontBack, + (int)Dof.RightArmDofStart + (int)ArmDof.HandInOut }, // Roll In Out new int[] { - (int)DoF.LeftLegDoFStart + (int)LegDoF.UpperLegRollInOut, - (int)DoF.LeftLegDoFStart + (int)LegDoF.LegRollInOut, - (int)DoF.RightLegDoFStart + (int)LegDoF.UpperLegRollInOut, - (int)DoF.RightLegDoFStart + (int)LegDoF.LegRollInOut, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ArmRollInOut, - (int)DoF.LeftArmDoFStart + (int)ArmDoF.ForeArmRollInOut, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ArmRollInOut, - (int)DoF.RightArmDoFStart + (int)ArmDoF.ForeArmRollInOut + (int)Dof.LeftLegDofStart + (int)LegDof.UpperLegRollInOut, + (int)Dof.LeftLegDofStart + (int)LegDof.LegRollInOut, + (int)Dof.RightLegDofStart + (int)LegDof.UpperLegRollInOut, + (int)Dof.RightLegDofStart + (int)LegDof.LegRollInOut, + (int)Dof.LeftArmDofStart + (int)ArmDof.ArmRollInOut, + (int)Dof.LeftArmDofStart + (int)ArmDof.ForeArmRollInOut, + (int)Dof.RightArmDofStart + (int)ArmDof.ArmRollInOut, + (int)Dof.RightArmDofStart + (int)ArmDof.ForeArmRollInOut }, // Finger open close new int[] { - (int)DoF.LeftThumbDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftThumbDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftThumbDoFStart + (int)FingerDoF.DistalCloseOpen, + (int)Dof.LeftThumbDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftThumbDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftThumbDofStart + (int)FingerDof.DistalCloseOpen, - (int)DoF.LeftIndexDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftIndexDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftIndexDoFStart + (int)FingerDoF.DistalCloseOpen, + (int)Dof.LeftIndexDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftIndexDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftIndexDofStart + (int)FingerDof.DistalCloseOpen, - (int)DoF.LeftMiddleDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftMiddleDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftMiddleDoFStart + (int)FingerDoF.DistalCloseOpen, + (int)Dof.LeftMiddleDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftMiddleDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftMiddleDofStart + (int)FingerDof.DistalCloseOpen, - (int)DoF.LeftRingDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftRingDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftRingDoFStart + (int)FingerDoF.DistalCloseOpen, + (int)Dof.LeftRingDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftRingDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftRingDofStart + (int)FingerDof.DistalCloseOpen, - (int)DoF.LeftLittleDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.LeftLittleDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.LeftLittleDoFStart + (int)FingerDoF.DistalCloseOpen, + (int)Dof.LeftLittleDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.LeftLittleDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.LeftLittleDofStart + (int)FingerDof.DistalCloseOpen, - (int)DoF.RightThumbDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightThumbDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightThumbDoFStart + (int)FingerDoF.DistalCloseOpen, + (int)Dof.RightThumbDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightThumbDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightThumbDofStart + (int)FingerDof.DistalCloseOpen, - (int)DoF.RightIndexDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightIndexDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightIndexDoFStart + (int)FingerDoF.DistalCloseOpen, + (int)Dof.RightIndexDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightIndexDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightIndexDofStart + (int)FingerDof.DistalCloseOpen, - (int)DoF.RightMiddleDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightMiddleDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightMiddleDoFStart + (int)FingerDoF.DistalCloseOpen, + (int)Dof.RightMiddleDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightMiddleDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightMiddleDofStart + (int)FingerDof.DistalCloseOpen, - (int)DoF.RightRingDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightRingDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightRingDoFStart + (int)FingerDoF.DistalCloseOpen, + (int)Dof.RightRingDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightRingDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightRingDofStart + (int)FingerDof.DistalCloseOpen, - (int)DoF.RightLittleDoFStart + (int)FingerDoF.ProximalDownUp, - (int)DoF.RightLittleDoFStart + (int)FingerDoF.IntermediateCloseOpen, - (int)DoF.RightLittleDoFStart + (int)FingerDoF.DistalCloseOpen + (int)Dof.RightLittleDofStart + (int)FingerDof.ProximalDownUp, + (int)Dof.RightLittleDofStart + (int)FingerDof.IntermediateCloseOpen, + (int)Dof.RightLittleDofStart + (int)FingerDof.DistalCloseOpen }, // Finger In Out new int[] { - (int)DoF.LeftThumbDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.LeftIndexDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.LeftMiddleDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.LeftRingDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.LeftLittleDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightThumbDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightIndexDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightMiddleDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightRingDoFStart + (int)FingerDoF.ProximalInOut, - (int)DoF.RightLittleDoFStart + (int)FingerDoF.ProximalInOut, + (int)Dof.LeftThumbDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.LeftIndexDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.LeftMiddleDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.LeftRingDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.LeftLittleDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightThumbDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightIndexDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightMiddleDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightRingDofStart + (int)FingerDof.ProximalInOut, + (int)Dof.RightLittleDofStart + (int)FingerDof.ProximalInOut, } }; diff --git a/Editor/Mono/Inspector/CameraEditor.cs b/Editor/Mono/Inspector/CameraEditor.cs index d24fc33dc4..8a787b2fcf 100644 --- a/Editor/Mono/Inspector/CameraEditor.cs +++ b/Editor/Mono/Inspector/CameraEditor.cs @@ -26,15 +26,14 @@ private static class Styles public static GUIContent clearFlags = EditorGUIUtility.TrTextContent("Clear Flags", "What to display in empty areas of this Camera's view.\n\nChoose Skybox to display a skybox in empty areas, defaulting to a background color if no skybox is found.\n\nChoose Solid Color to display a background color in empty areas.\n\nChoose Depth Only to display nothing in empty areas.\n\nChoose Don't Clear to display whatever was displayed in the previous frame in empty areas."); public static GUIContent background = EditorGUIUtility.TrTextContent("Background", "The Camera clears the screen to this color before rendering."); public static GUIContent projection = EditorGUIUtility.TrTextContent("Projection", "How the Camera renders perspective.\n\nChoose Perspective to render objects with perspective.\n\nChoose Orthographic to render objects uniformly, with no sense of perspective."); - public static GUIContent size = EditorGUIUtility.TrTextContent("Size"); - public static GUIContent fieldOfView = EditorGUIUtility.TrTextContent("Field of View", "The width of the Camera’s view angle, measured in degrees along the local Y axis."); + public static GUIContent size = EditorGUIUtility.TrTextContent("Size", "The vertical size of the camera view."); + public static GUIContent fieldOfView = EditorGUIUtility.TrTextContent("Field of View", "The height of the camera’s view angle, measured in degrees vertically, or along the local Y axis."); public static GUIContent viewportRect = EditorGUIUtility.TrTextContent("Viewport Rect", "Four values that indicate where on the screen this camera view will be drawn. Measured in Viewport Coordinates (values 0–1)."); - public static GUIContent cameraPreview = EditorGUIUtility.TrTextContent("Camera Preview"); - public static GUIContent sensorSize = EditorGUIUtility.TrTextContent("Sensor Size"); - public static GUIContent lensShift = EditorGUIUtility.TrTextContent("Lens Shift"); - public static GUIContent physicalCamera = EditorGUIUtility.TrTextContent("Physical Camera"); - public static GUIContent cameraType = EditorGUIUtility.TrTextContent("Camera Type"); - public static GUIContent focalLength = EditorGUIUtility.TrTextContent("Focal Length"); + public static GUIContent sensorSize = EditorGUIUtility.TrTextContent("Sensor Size", "The size of the camera sensor in millimeters."); + public static GUIContent lensShift = EditorGUIUtility.TrTextContent("Lens Shift", "Offset from the camera sensor. Use these properties to simulate a shift lens. Measured as a multiple of the sensor size."); + public static GUIContent physicalCamera = EditorGUIUtility.TrTextContent("Physical Camera", "Enables Physical camera mode. When checked, the field of view is calculated from properties for simulating physical attributes (focal length, sensor size, and lens shift)."); + public static GUIContent cameraType = EditorGUIUtility.TrTextContent("Sensor Type", "Common sensor sizes. Choose an item to set Sensor Size, or edit Sensor Size for your custom settings."); + public static GUIContent focalLength = EditorGUIUtility.TrTextContent("Focal Length", "The camera focal length in millimeters."); public static GUIStyle invisibleButton = "InvisibleButton"; } public sealed class Settings diff --git a/Editor/Mono/PerceptionRemoting/HolographicEmulation/HolographicEmulationWindow.cs b/Editor/Mono/PerceptionRemoting/HolographicEmulation/HolographicEmulationWindow.cs index 05bfac9ae0..762d56fa12 100644 --- a/Editor/Mono/PerceptionRemoting/HolographicEmulation/HolographicEmulationWindow.cs +++ b/Editor/Mono/PerceptionRemoting/HolographicEmulation/HolographicEmulationWindow.cs @@ -13,9 +13,9 @@ using UnityEngine.XR; using UnityEngine.XR.WSA; -namespace UnityEditorInternal.VR +namespace UnityEngine.XR.WSA { - public class HolographicEmulationWindow : EditorWindow + internal class HolographicEmulationWindow : EditorWindow { private bool m_InPlayMode = false; private bool m_OperatingSystemChecked = false; @@ -113,14 +113,14 @@ private void LoadCurrentRoom() return; string roomPath = EditorApplication.applicationContentsPath + "/UnityExtensions/Unity/VR/HolographicSimulation/Rooms/"; - HolographicEmulation.LoadRoom(roomPath + s_RoomStrings[m_RoomIndex].text + ".xef"); + HolographicAutomation.LoadRoom(roomPath + s_RoomStrings[m_RoomIndex].text + ".xef"); } private void InitializeSimulation() { Disconnect(); - HolographicEmulation.Initialize(); + HolographicAutomation.Initialize(); LoadCurrentRoom(); } @@ -135,7 +135,7 @@ private void OnPlayModeStateChanged(PlayModeStateChange state) if (m_InPlayMode && !wasPlaying) { - HolographicEmulation.SetEmulationMode(m_Mode); + HolographicAutomation.SetEmulationMode(m_Mode); switch (m_Mode) { case EmulationMode.Simulated: @@ -150,7 +150,7 @@ private void OnPlayModeStateChanged(PlayModeStateChange state) switch (m_Mode) { case EmulationMode.Simulated: - HolographicEmulation.Shutdown(); + HolographicAutomation.Shutdown(); break; case EmulationMode.RemoteDevice: @@ -161,21 +161,21 @@ private void OnPlayModeStateChanged(PlayModeStateChange state) private void Connect() { - PerceptionRemotingPlugin.SetVideoEncodingParameters(m_MaxBitrateKbps); - PerceptionRemotingPlugin.SetEnableVideo(m_EnableVideo); - PerceptionRemotingPlugin.SetEnableAudio(m_EnableAudio); - PerceptionRemotingPlugin.Connect(m_RemoteMachineAddress); + PerceptionRemoting.SetVideoEncodingParameters(m_MaxBitrateKbps); + PerceptionRemoting.SetEnableVideo(m_EnableVideo); + PerceptionRemoting.SetEnableAudio(m_EnableAudio); + PerceptionRemoting.Connect(m_RemoteMachineAddress); } private void Disconnect() { - if (PerceptionRemotingPlugin.GetConnectionState() != HolographicStreamerConnectionState.Disconnected) - PerceptionRemotingPlugin.Disconnect(); + if (PerceptionRemoting.GetConnectionState() != HolographicStreamerConnectionState.Disconnected) + PerceptionRemoting.Disconnect(); } private bool IsConnectedToRemoteDevice() { - return PerceptionRemotingPlugin.GetConnectionState() == HolographicStreamerConnectionState.Connected; + return PerceptionRemoting.GetConnectionState() == HolographicStreamerConnectionState.Connected; } private void HandleButtonPress() @@ -186,7 +186,7 @@ private void HandleButtonPress() return; } - HolographicStreamerConnectionState connectionState = PerceptionRemotingPlugin.GetConnectionState(); + HolographicStreamerConnectionState connectionState = PerceptionRemoting.GetConnectionState(); if (connectionState == HolographicStreamerConnectionState.Connecting || connectionState == HolographicStreamerConnectionState.Connected) { @@ -258,7 +258,7 @@ void ConnectionStateGUI() Texture2D iconTexture; GUIContent labelContent; GUIContent buttonContent; - HolographicStreamerConnectionState connectionState = PerceptionRemotingPlugin.GetConnectionState(); + HolographicStreamerConnectionState connectionState = PerceptionRemoting.GetConnectionState(); switch (connectionState) { case HolographicStreamerConnectionState.Disconnected: @@ -380,7 +380,7 @@ void OnGUI() EditorGUI.BeginChangeCheck(); m_Hand = (GestureHand)EditorGUILayout.Popup(s_HandText, (int)m_Hand, s_HandStrings); if (EditorGUI.EndChangeCheck()) - HolographicEmulation.SetGestureHand(m_Hand); + HolographicAutomation.SetGestureHand(m_Hand); break; } @@ -391,16 +391,16 @@ void Update() switch (m_Mode) { case EmulationMode.Simulated: - HolographicEmulation.SetGestureHand(m_Hand); + UnityEngine.XR.WSA.HolographicAutomation.SetGestureHand(m_Hand); break; case EmulationMode.RemoteDevice: - HolographicStreamerConnectionState connectionState = PerceptionRemotingPlugin.GetConnectionState(); + HolographicStreamerConnectionState connectionState = PerceptionRemoting.GetConnectionState(); if (connectionState != m_LastConnectionState) { Repaint(); } - var lastConnectionFailureReason = PerceptionRemotingPlugin.CheckForDisconnect(); + var lastConnectionFailureReason = PerceptionRemoting.CheckForDisconnect(); if (lastConnectionFailureReason == HolographicStreamerConnectionFailureReason.Unreachable || lastConnectionFailureReason == HolographicStreamerConnectionFailureReason.ConnectionLost) { diff --git a/Editor/Mono/SceneView/SceneView.cs b/Editor/Mono/SceneView/SceneView.cs index cec11c8283..9cc74db960 100644 --- a/Editor/Mono/SceneView/SceneView.cs +++ b/Editor/Mono/SceneView/SceneView.cs @@ -2092,6 +2092,14 @@ void SetupCamera() m_Camera.nearClipPlane = farClip * 0.000005f; m_Camera.farClipPlane = farClip; + // In 2D mode, camera position z should not go to positive value. + if (m_2DMode && m_Camera.transform.position.z >= 0) + { + var p = m_Camera.transform.position; + p.z = -(m_Camera.nearClipPlane + 0.01f); + m_Camera.transform.position = p; + } + m_Camera.renderingPath = GetSceneViewRenderingPath(); if (!CheckDrawModeForRenderingPath(m_CameraMode.drawMode)) m_CameraMode = GetBuiltinCameraMode(DrawCameraMode.Textured); diff --git a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs index 8d8a47a56d..a63ff7335d 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs @@ -1088,6 +1088,21 @@ public TargetAssemblyInfo[] GetTargetAssemblies() return targetAssemblyInfo; } + public TargetAssemblyInfo[] GetTargetAssembliesWithScripts(EditorScriptCompilationOptions options) + { + var scriptAssemblies = GetAllScriptAssemblies(EditorScriptCompilationOptions.BuildingForEditor | options); + var targetAssemblies = new TargetAssemblyInfo[scriptAssemblies.Length]; + + for (int i = 0; i < scriptAssemblies.Length; ++i) + { + var scriptAssembly = scriptAssemblies[i]; + targetAssemblies[i].Name = scriptAssembly.Filename; + targetAssemblies[i].Flags = scriptAssembly.Flags; + } + + return targetAssemblies; + } + public ScriptAssembly[] GetAllScriptAssembliesForLanguage(EditorScriptCompilationOptions additionalOptions) where T : SupportedLanguage { var assemblies = GetAllScriptAssemblies(EditorScriptCompilationOptions.BuildingForEditor).Where(a => a.Language.GetType() == typeof(T)).ToArray(); diff --git a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilationInterface.cs b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilationInterface.cs index 4375948a94..a9a18e9007 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilationInterface.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilationInterface.cs @@ -191,6 +191,13 @@ public static EditorCompilation.TargetAssemblyInfo[] GetAllCompiledAndResolvedCu return EmitExceptionAsError(() => Instance.GetAllCompiledAndResolvedCustomTargetAssemblies(), new EditorCompilation.TargetAssemblyInfo[0]); } + [RequiredByNativeCode] + public static EditorCompilation.TargetAssemblyInfo[] GetTargetAssembliesWithScripts() + { + var options = GetAdditionalEditorScriptCompilationOptions(); + return Instance.GetTargetAssembliesWithScripts(options); + } + [RequiredByNativeCode] public static bool HaveSetupErrors() { diff --git a/Modules/Physics2D/ScriptBindings/Physics2D.bindings.cs b/Modules/Physics2D/ScriptBindings/Physics2D.bindings.cs index 7edc2ebd80..f022c7f028 100644 --- a/Modules/Physics2D/ScriptBindings/Physics2D.bindings.cs +++ b/Modules/Physics2D/ScriptBindings/Physics2D.bindings.cs @@ -1933,30 +1933,111 @@ static internal ContactFilter2D CreateLegacyFilter(int layerMask, float minDepth } } + [UsedByNativeCode] + [StructLayout(LayoutKind.Sequential)] + internal unsafe partial struct CachedContactPoints2D + { + public ContactPoint2D this[int i] + { + get + { + // No need to limit the index here as it is limited by the contact count when accessed. + // Adding a constant here will just introduce something else that will need updating + // should the contact point cache change in the future. + fixed(ContactPoint2D * contact = &m_Contact0) + { + return *(contact + i); + } + } + } + + // It would've been nice to have some fixed array here but it's not possible. + // Using a fixed primitive type array isn't possible either as the size cannot be specified as an explicit constant. + ContactPoint2D m_Contact0; + ContactPoint2D m_Contact1; + ContactPoint2D m_Contact2; + ContactPoint2D m_Contact3; + ContactPoint2D m_Contact4; + ContactPoint2D m_Contact5; + ContactPoint2D m_Contact6; + ContactPoint2D m_Contact7; + ContactPoint2D m_Contact8; + ContactPoint2D m_Contact9; + + ContactPoint2D m_Contact10; + ContactPoint2D m_Contact11; + ContactPoint2D m_Contact12; + ContactPoint2D m_Contact13; + ContactPoint2D m_Contact14; + ContactPoint2D m_Contact15; + ContactPoint2D m_Contact16; + ContactPoint2D m_Contact17; + ContactPoint2D m_Contact18; + ContactPoint2D m_Contact19; + + ContactPoint2D m_Contact20; + ContactPoint2D m_Contact21; + ContactPoint2D m_Contact22; + ContactPoint2D m_Contact23; + ContactPoint2D m_Contact24; + ContactPoint2D m_Contact25; + ContactPoint2D m_Contact26; + ContactPoint2D m_Contact27; + ContactPoint2D m_Contact28; + ContactPoint2D m_Contact29; + + ContactPoint2D m_Contact30; + ContactPoint2D m_Contact31; + ContactPoint2D m_Contact32; + ContactPoint2D m_Contact33; + ContactPoint2D m_Contact34; + ContactPoint2D m_Contact35; + ContactPoint2D m_Contact36; + ContactPoint2D m_Contact37; + ContactPoint2D m_Contact38; + ContactPoint2D m_Contact39; + + ContactPoint2D m_Contact40; + ContactPoint2D m_Contact41; + ContactPoint2D m_Contact42; + ContactPoint2D m_Contact43; + ContactPoint2D m_Contact44; + ContactPoint2D m_Contact45; + ContactPoint2D m_Contact46; + ContactPoint2D m_Contact47; + ContactPoint2D m_Contact48; + ContactPoint2D m_Contact49; + + ContactPoint2D m_Contact50; + ContactPoint2D m_Contact51; + ContactPoint2D m_Contact52; + ContactPoint2D m_Contact53; + ContactPoint2D m_Contact54; + ContactPoint2D m_Contact55; + ContactPoint2D m_Contact56; + ContactPoint2D m_Contact57; + ContactPoint2D m_Contact58; + ContactPoint2D m_Contact59; + + ContactPoint2D m_Contact60; + ContactPoint2D m_Contact61; + ContactPoint2D m_Contact62; + ContactPoint2D m_Contact63; + } + // Describes a collision. - [RequiredByNativeCode(Optional = true, GenerateProxy = true)] + [UsedByNativeCode] [StructLayout(LayoutKind.Sequential)] - [NativeAsStruct] - [NativeClass("ScriptingCollision2D", "struct ScriptingCollision2D;")] public partial class Collision2D { - [NativeName("collider")] internal int m_Collider; - [NativeName("otherCollider")] internal int m_OtherCollider; - [NativeName("rigidbody")] internal int m_Rigidbody; - [NativeName("otherRigidbody")] internal int m_OtherRigidbody; - [NativeName("relativeVelocity")] internal Vector2 m_RelativeVelocity; - [NativeName("enabled")] internal int m_Enabled; - [NativeName("contactCount")] internal int m_ContactCount; - [NativeName("contacts")] - internal IntPtr m_Contacts; - [NativeName("legacyContactArray")] + internal CachedContactPoints2D m_CachedContactPoints; internal ContactPoint2D[] m_LegacyContactArray; // The first collider involved in the collision. @@ -1984,7 +2065,7 @@ public partial class Collision2D public bool enabled { get { return m_Enabled == 1; } } // The contact points. - public unsafe ContactPoint2D[] contacts + public ContactPoint2D[] contacts { get { @@ -1993,10 +2074,11 @@ public unsafe ContactPoint2D[] contacts m_LegacyContactArray = new ContactPoint2D[m_ContactCount]; if (m_ContactCount > 0) { - ContactPoint2D* contactPoint = (ContactPoint2D*)m_Contacts.ToPointer(); - for (var i = 0; i < m_ContactCount; ++i) { - m_LegacyContactArray[i] = *contactPoint++; + for (var i = 0; i < m_ContactCount; ++i) + { + m_LegacyContactArray[i] = m_CachedContactPoints[i]; + } } } } @@ -2009,16 +2091,16 @@ public unsafe ContactPoint2D[] contacts public int contactCount { get { return m_ContactCount; } } // Get contact at specific index. - public unsafe ContactPoint2D GetContact(int index) + public ContactPoint2D GetContact(int index) { if (index < 0 || index >= m_ContactCount) throw new ArgumentOutOfRangeException(String.Format("Cannot get contact at index {0}. There are {1} contact(s).", index, m_ContactCount)); - return *((ContactPoint2D*)m_Contacts.ToPointer() + index); + return m_CachedContactPoints[index]; } // Get contacts for this collision. - public unsafe int GetContacts(ContactPoint2D[] contacts) + public int GetContacts(ContactPoint2D[] contacts) { if (contacts == null) throw new ArgumentNullException("Cannot get contacts into a NULL array."); @@ -2037,25 +2119,13 @@ public unsafe int GetContacts(ContactPoint2D[] contacts) // Copy the cached contact points instead. if (m_ContactCount > 0) { - ContactPoint2D* contactPoint = (ContactPoint2D*)m_Contacts.ToPointer(); for (var i = 0; i < contactCount; ++i) { - contacts[i] = *contactPoint++; + contacts[i] = m_CachedContactPoints[i]; } } return contactCount; } - - ~Collision2D() - { - // Free any contacts. - if (m_ContactCount > 0) - FreeContacts(m_Contacts); - } - - [StaticAccessor("GetPhysicsManager2D()", StaticAccessorType.Arrow)] - [NativeMethod("FreeCachedContactPoints_Binding", IsThreadSafe = true)] - extern private static void FreeContacts(IntPtr contacts); }; // Describes a contact point where the collision occurs. diff --git a/Modules/ProfilerEditor/ProfilerWindow/ProfilerDetailedCallsView.cs b/Modules/ProfilerEditor/ProfilerWindow/ProfilerDetailedCallsView.cs index 617953e01d..dd715cd646 100644 --- a/Modules/ProfilerEditor/ProfilerWindow/ProfilerDetailedCallsView.cs +++ b/Modules/ProfilerEditor/ProfilerWindow/ProfilerDetailedCallsView.cs @@ -11,15 +11,157 @@ namespace UnityEditorInternal.Profiling { + internal class ProfilerCallersAndCalleeData + { + public float totalSelectedPropertyTime { get; private set; } + + public CallsData callersData + { + get + { + return m_CallersData; + } + } + public CallsData calleesData + { + get + { + return m_CalleesData; + } + } + + CallsData m_CallersData = new CallsData() {calls = new List(), totalSelectedPropertyTime = 0 }; + CallsData m_CalleesData = new CallsData() {calls = new List(), totalSelectedPropertyTime = 0 }; + + Dictionary m_Callers = new Dictionary(); + Dictionary m_Callees = new Dictionary(); + + List m_ChildrenIds = new List(256); + Stack m_Stack = new Stack(); + + internal struct CallsData + { + public List calls; + public float totalSelectedPropertyTime; + } + + internal class CallInformation + { + public int id; // FrameDataView item id + public string name; + public int callsCount; + public int gcAllocBytes; + public double totalCallTimeMs; + public double totalSelfTimeMs; + public double timePercent; // Cached value - calculated based on view type + } + + internal float UpdateData(FrameDataView frameDataView, int selectedMarkerId) + { + totalSelectedPropertyTime = 0; + + m_Callers.Clear(); + m_Callees.Clear(); + + m_ChildrenIds.Clear(); + m_Stack.Clear(); + m_Stack.Push(frameDataView.GetRootItemID()); + + while (m_Stack.Count > 0) + { + var current = m_Stack.Pop(); + + if (!frameDataView.HasItemChildren(current)) + continue; + + var markerId = frameDataView.GetItemMarkerID(current); + frameDataView.GetItemChildren(current, m_ChildrenIds); + foreach (var childId in m_ChildrenIds) + { + var childMarkerId = frameDataView.GetItemMarkerID(childId); + if (childMarkerId == selectedMarkerId) + { + var totalSelfTime = frameDataView.GetItemColumnDataAsSingle(childId, ProfilerColumn.TotalTime); + totalSelectedPropertyTime += totalSelfTime; + + if (current != 0) + { + // Add markerId to callers (except root) + CallInformation callInfo; + var totalTime = frameDataView.GetItemColumnDataAsSingle(current, ProfilerColumn.TotalTime); + var calls = (int)frameDataView.GetItemColumnDataAsSingle(current, ProfilerColumn.Calls); + var gcAlloc = (int)frameDataView.GetItemColumnDataAsSingle(current, ProfilerColumn.GCMemory); + if (!m_Callers.TryGetValue(markerId, out callInfo)) + { + m_Callers.Add(markerId, new CallInformation() + { + id = current, + name = frameDataView.GetItemFunctionName(current), + callsCount = calls, + gcAllocBytes = gcAlloc, + totalCallTimeMs = totalTime, + totalSelfTimeMs = totalSelfTime + }); + } + else + { + callInfo.callsCount += calls; + callInfo.gcAllocBytes += gcAlloc; + callInfo.totalCallTimeMs += totalTime; + callInfo.totalSelfTimeMs += totalSelfTime; + } + } + } + + if (markerId == selectedMarkerId) + { + // Add childMarkerId to callees + CallInformation callInfo; + var totalTime = frameDataView.GetItemColumnDataAsSingle(childId, ProfilerColumn.TotalTime); + var calls = (int)frameDataView.GetItemColumnDataAsSingle(childId, ProfilerColumn.Calls); + var gcAlloc = (int)frameDataView.GetItemColumnDataAsSingle(childId, ProfilerColumn.GCMemory); + if (!m_Callees.TryGetValue(childMarkerId, out callInfo)) + { + m_Callees.Add(childMarkerId, new CallInformation() + { + id = childId, + name = frameDataView.GetItemFunctionName(childId), + callsCount = calls, + gcAllocBytes = gcAlloc, + totalCallTimeMs = totalTime, + totalSelfTimeMs = 0 + }); + } + else + { + callInfo.callsCount += calls; + callInfo.gcAllocBytes += gcAlloc; + callInfo.totalCallTimeMs += totalTime; + } + } + + m_Stack.Push(childId); + } + } + UpdateCallsData(ref m_CallersData, m_Callers, totalSelectedPropertyTime); + UpdateCallsData(ref m_CalleesData, m_Callees, totalSelectedPropertyTime); + return totalSelectedPropertyTime; + } + + private void UpdateCallsData(ref CallsData callsData, Dictionary data, float totalSelectedPropertyTime) + { + callsData.calls.Clear(); + callsData.calls.AddRange(data.Values); + callsData.totalSelectedPropertyTime = totalSelectedPropertyTime; + } + } + [Serializable] internal class ProfilerDetailedCallsView : ProfilerDetailedView { [NonSerialized] bool m_Initialized = false; - [NonSerialized] - float m_TotalSelectedPropertyTime; - [NonSerialized] GUIContent m_TotalSelectedPropertyTimeLabel = EditorGUIUtility.TrTextContent("", "Total time of all calls of the selected function in the frame."); @@ -35,22 +177,8 @@ internal class ProfilerDetailedCallsView : ProfilerDetailedView public delegate void FrameItemCallback(int id); public event FrameItemCallback frameItemEvent; - struct CallsData - { - public List calls; - public float totalSelectedPropertyTime; - } - - class CallInformation - { - public int id; // FrameDataView item id - public string name; - public int callsCount; - public int gcAllocBytes; - public double totalCallTimeMs; - public double totalSelfTimeMs; - public double timePercent; // Cached value - calculated based on view type - } + [NonSerialized] + ProfilerCallersAndCalleeData callersAndCalleeData = null; class CallsTreeView : TreeView { @@ -71,7 +199,7 @@ public enum Column Count } - internal CallsData m_CallsData; + internal ProfilerCallersAndCalleeData.CallsData m_CallsData; Type m_Type; public event FrameItemCallback frameItemEvent; @@ -89,7 +217,7 @@ public CallsTreeView(Type type, TreeViewState treeViewState, MultiColumnHeader m Reload(); } - public void SetCallsData(CallsData callsData) + public void SetCallsData(ProfilerCallersAndCalleeData.CallsData callsData) { m_CallsData = callsData; @@ -190,7 +318,7 @@ void OnSortingChanged(MultiColumnHeader header) if (m_CallsData.calls != null) { var orderMultiplier = header.IsSortedAscending(header.sortedColumnIndex) ? 1 : -1; - Comparison comparison; + Comparison comparison; switch ((Column)header.sortedColumnIndex) { case Column.Name: @@ -361,7 +489,7 @@ public void SetType(CallsTreeView.Type type) m_Type = type; } - public void SetCallsData(CallsData callsData) + public void SetCallsData(ProfilerCallersAndCalleeData.CallsData callsData) { InitIfNeeded(); @@ -398,6 +526,8 @@ void InitIfNeeded() m_CallersTreeView.SetType(CallsTreeView.Type.Callers); m_CallersTreeView.frameItemEvent += frameItemEvent; + callersAndCalleeData = new ProfilerCallersAndCalleeData(); + m_Initialized = true; } @@ -439,106 +569,20 @@ void UpdateIfNeeded(FrameDataView frameDataView, int selectedId) m_FrameDataView = frameDataView; m_SelectedID = selectedId; - m_TotalSelectedPropertyTime = 0; - - var selectedMarkerId = m_FrameDataView.GetItemMarkerID(m_SelectedID); - - var callers = new Dictionary(); - var callees = new Dictionary(); - - var childrenIds = new List(256); - var stack = new Stack(); - stack.Push(m_FrameDataView.GetRootItemID()); - - while (stack.Count > 0) - { - var current = stack.Pop(); - - if (m_FrameDataView.HasItemChildren(current)) - continue; - - var markerId = m_FrameDataView.GetItemMarkerID(current); - m_FrameDataView.GetItemChildren(current, childrenIds); - foreach (var childId in childrenIds) - { - var childMarkerId = m_FrameDataView.GetItemMarkerID(childId); - if (childMarkerId == selectedMarkerId) - { - var totalSelfTime = m_FrameDataView.GetItemColumnDataAsSingle(childId, ProfilerColumn.TotalTime); - m_TotalSelectedPropertyTime += totalSelfTime; - - if (current != 0) - { - // Add markerId to callers (except root) - CallInformation callInfo; - var totalTime = m_FrameDataView.GetItemColumnDataAsSingle(current, ProfilerColumn.TotalTime); - var calls = (int)m_FrameDataView.GetItemColumnDataAsSingle(current, ProfilerColumn.Calls); - var gcAlloc = (int)m_FrameDataView.GetItemColumnDataAsSingle(current, ProfilerColumn.GCMemory); - if (!callers.TryGetValue(markerId, out callInfo)) - { - callers.Add(markerId, new CallInformation() - { - id = current, - name = m_FrameDataView.GetItemFunctionName(current), - callsCount = calls, - gcAllocBytes = gcAlloc, - totalCallTimeMs = totalTime, - totalSelfTimeMs = totalSelfTime - }); - } - else - { - callInfo.callsCount += calls; - callInfo.gcAllocBytes += gcAlloc; - callInfo.totalCallTimeMs += totalTime; - callInfo.totalSelfTimeMs += totalSelfTime; - } - } - } - - if (markerId == selectedMarkerId) - { - // Add childMarkerId to callees - CallInformation callInfo; - var totalTime = m_FrameDataView.GetItemColumnDataAsSingle(childId, ProfilerColumn.TotalTime); - var calls = (int)m_FrameDataView.GetItemColumnDataAsSingle(childId, ProfilerColumn.Calls); - var gcAlloc = (int)m_FrameDataView.GetItemColumnDataAsSingle(childId, ProfilerColumn.GCMemory); - if (!callees.TryGetValue(childMarkerId, out callInfo)) - { - callees.Add(childMarkerId, new CallInformation() - { - id = childId, - name = m_FrameDataView.GetItemFunctionName(childId), - callsCount = calls, - gcAllocBytes = gcAlloc, - totalCallTimeMs = totalTime, - totalSelfTimeMs = 0 - }); - } - else - { - callInfo.callsCount += calls; - callInfo.gcAllocBytes += gcAlloc; - callInfo.totalCallTimeMs += totalTime; - } - } - - stack.Push(childId); - } - } + callersAndCalleeData.UpdateData(m_FrameDataView, m_FrameDataView.GetItemMarkerID(m_SelectedID)); - m_CallersTreeView.SetCallsData(new CallsData() { calls = callers.Values.ToList(), totalSelectedPropertyTime = m_TotalSelectedPropertyTime }); - m_CalleesTreeView.SetCallsData(new CallsData() { calls = callees.Values.ToList(), totalSelectedPropertyTime = m_TotalSelectedPropertyTime }); + m_CallersTreeView.SetCallsData(callersAndCalleeData.callersData); + m_CalleesTreeView.SetCallsData(callersAndCalleeData.calleesData); - m_TotalSelectedPropertyTimeLabel.text = m_FrameDataView.GetItemFunctionName(selectedId) + string.Format(" - Total time: {0:f2} ms", m_TotalSelectedPropertyTime); + m_TotalSelectedPropertyTimeLabel.text = m_FrameDataView.GetItemFunctionName(selectedId) + string.Format(" - Total time: {0:f2} ms", callersAndCalleeData.totalSelectedPropertyTime); } public void Clear() { if (m_CallersTreeView != null) - m_CallersTreeView.SetCallsData(new CallsData() { calls = null, totalSelectedPropertyTime = 0 }); + m_CallersTreeView.SetCallsData(new ProfilerCallersAndCalleeData.CallsData() { calls = null, totalSelectedPropertyTime = 0 }); if (m_CalleesTreeView != null) - m_CalleesTreeView.SetCallsData(new CallsData() { calls = null, totalSelectedPropertyTime = 0 }); + m_CalleesTreeView.SetCallsData(new ProfilerCallersAndCalleeData.CallsData() { calls = null, totalSelectedPropertyTime = 0 }); } } } diff --git a/Modules/ProfilerEditor/ProfilerWindow/ProfilerWindow.cs b/Modules/ProfilerEditor/ProfilerWindow/ProfilerWindow.cs index 49bcffb98b..02057d1244 100644 --- a/Modules/ProfilerEditor/ProfilerWindow/ProfilerWindow.cs +++ b/Modules/ProfilerEditor/ProfilerWindow/ProfilerWindow.cs @@ -109,7 +109,7 @@ static Styles() private Vector2 m_PaneScroll_AudioClips = Vector2.zero; [SerializeField] - string m_ActiveNativePlatformSupportModule; + string m_ActiveNativePlatformSupportModule = null; static List m_ProfilerWindows = new List(); @@ -480,6 +480,13 @@ void OnChartSelected(Chart sender) void CheckForPlatformModuleChange() { + if (m_ActiveNativePlatformSupportModule == null) + { + m_ActiveNativePlatformSupportModule = EditorUtility.GetActiveNativePlatformSupportModuleName(); + return; + } + + if (m_ActiveNativePlatformSupportModule != EditorUtility.GetActiveNativePlatformSupportModuleName()) { ProfilerDriver.ResetHistory(); @@ -1304,7 +1311,8 @@ private void DrawMainToolbar() if (wasProfilingEditor != ProfilerDriver.profileEditor) { - m_CPUFrameDataHierarchyView.treeView.Clear(); + // Clear the hierarchy view to force a rebuilding of the tree + m_CPUFrameDataHierarchyView.Clear(); } diff --git a/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs b/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs index 27ff8ef503..b57ef721db 100644 --- a/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs +++ b/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs @@ -24,6 +24,11 @@ internal enum SendEventOptions kAppendBuildTarget = 1 << 1 } + internal static bool SendEventScriptableBuildPipelineInfo(object parameters) + { + return EditorAnalytics.SendEvent("scriptableBuildPipeline", parameters); + } + internal static bool SendEventServiceInfo(object parameters) { return EditorAnalytics.SendEvent("serviceInfo", parameters); diff --git a/Projects/CSharp/UnityEditor.csproj b/Projects/CSharp/UnityEditor.csproj index 5a38178862..d62ca45426 100644 --- a/Projects/CSharp/UnityEditor.csproj +++ b/Projects/CSharp/UnityEditor.csproj @@ -19,7 +19,7 @@ full false ..\..\artifacts\Bee.CSharpSupport\UnityEditor\Debug\ - COMBINED_ASSEMBLIES;DEBUG;DEBUGGER_LISTENS_FIXED_PORT;ENABLE_ALTERNATIVE_LISTEN_PORT;ENABLE_AR;ENABLE_AUDIO;ENABLE_AUDIO_MANAGER_BASED_SCHEDULING;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_CLOUD_HUB;ENABLE_CLOUD_LICENSE;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_COLLAB_TESTING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_DUCK_TYPING;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_GRID;ENABLE_HOLOLENS_MODULE_API;ENABLE_LOCALIZATION;ENABLE_LZMA;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MICROPHONE;ENABLE_MONO;ENABLE_MONO_BDWGC;ENABLE_MOVIES;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NETWORK;ENABLE_PACKMAN;ENABLE_PHYSICS;ENABLE_SPATIALTRACKING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TEXTURE_STREAMING;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_UNITYWEBREQUEST;ENABLE_UNITYWEBREQUEST;ENABLE_UNLOCKED_DIAGNOSTIC_SWITCHES;ENABLE_VERSION_CONTROL_INTEGRATION;ENABLE_VIDEO;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WEBSOCKET_CLIENT;ENABLE_WWW;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_PUBNUB;PLATFORM_SUPPORTS_MONO;PLAYERCONNECTION_LISTENS_FIXED_PORT;RENDER_SOFTWARE_CURSOR;TRACE;UNITY_ANDROID_API;UNITY_ASSEMBLIES_API;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_API;UNITY_IPHONE_API;UNITY_METRO_API;UNITY_N3DS_API;UNITY_PS4_API;UNITY_PS4_API;UNITY_PSVITA_API;UNITY_STANDALONE_LINUX_API;UNITY_STANDALONE_OSX_API;UNITY_STANDALONE_WIN_API;UNITY_SWITCH_API;UNITY_TVOS_API;UNITY_WEBGL_API;UNITY_XBOXONE_API + COMBINED_ASSEMBLIES;DEBUG;DEBUGGER_LISTENS_FIXED_PORT;ENABLE_ALTERNATIVE_LISTEN_PORT;ENABLE_AR;ENABLE_AUDIO;ENABLE_AUDIO_MANAGER_BASED_SCHEDULING;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_CLOUD_HUB;ENABLE_CLOUD_LICENSE;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_COLLAB_TESTING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_DUCK_TYPING;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_GRID;ENABLE_HOLOLENS_MODULE_API;ENABLE_LOCALIZATION;ENABLE_LZMA;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MICROPHONE;ENABLE_MONO;ENABLE_MONO_BDWGC;ENABLE_MOVIES;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NETWORK;ENABLE_PACKMAN;ENABLE_PHYSICS;ENABLE_SPATIALTRACKING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TEXTURE_STREAMING;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_UNITYWEBREQUEST;ENABLE_UNITYWEBREQUEST;ENABLE_UNLOCKED_DIAGNOSTIC_SWITCHES;ENABLE_VERSION_CONTROL_INTEGRATION;ENABLE_VIDEO;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WEBSOCKET_CLIENT;ENABLE_WWW;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_PUBNUB;PLATFORM_SUPPORTS_MONO;PLAYERCONNECTION_LISTENS_FIXED_PORT;RENDER_SOFTWARE_CURSOR;TRACE;UNITY_ANDROID_API;UNITY_ASSEMBLIES_API;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_API;UNITY_IPHONE_API;UNITY_METRO_API;UNITY_N3DS_API;UNITY_PS4_API;UNITY_PS4_API;UNITY_PSVITA_API;UNITY_STANDALONE_LINUX_API;UNITY_STANDALONE_OSX_API;UNITY_STANDALONE_WIN_API;UNITY_SWITCH_API;UNITY_TVOS_API;UNITY_WEBGL_API;UNITY_XBOXONE_API prompt 4 true @@ -31,7 +31,7 @@ pdbonly true ..\..\artifacts\Bee.CSharpSupport\UnityEditor\Release\ - COMBINED_ASSEMBLIES;DEBUGGER_LISTENS_FIXED_PORT;ENABLE_ALTERNATIVE_LISTEN_PORT;ENABLE_AR;ENABLE_AUDIO;ENABLE_AUDIO_MANAGER_BASED_SCHEDULING;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_CLOUD_HUB;ENABLE_CLOUD_LICENSE;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_COLLAB_TESTING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_DUCK_TYPING;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_GRID;ENABLE_HOLOLENS_MODULE_API;ENABLE_LOCALIZATION;ENABLE_LZMA;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MICROPHONE;ENABLE_MONO;ENABLE_MONO_BDWGC;ENABLE_MOVIES;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NETWORK;ENABLE_PACKMAN;ENABLE_PHYSICS;ENABLE_SPATIALTRACKING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TEXTURE_STREAMING;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_UNITYWEBREQUEST;ENABLE_UNITYWEBREQUEST;ENABLE_UNLOCKED_DIAGNOSTIC_SWITCHES;ENABLE_VERSION_CONTROL_INTEGRATION;ENABLE_VIDEO;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WEBSOCKET_CLIENT;ENABLE_WWW;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_PUBNUB;PLATFORM_SUPPORTS_MONO;PLAYERCONNECTION_LISTENS_FIXED_PORT;RENDER_SOFTWARE_CURSOR;TRACE;UNITY_ANDROID_API;UNITY_ASSEMBLIES_API;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_API;UNITY_IPHONE_API;UNITY_METRO_API;UNITY_N3DS_API;UNITY_PS4_API;UNITY_PS4_API;UNITY_PSVITA_API;UNITY_STANDALONE_LINUX_API;UNITY_STANDALONE_OSX_API;UNITY_STANDALONE_WIN_API;UNITY_SWITCH_API;UNITY_TVOS_API;UNITY_WEBGL_API;UNITY_XBOXONE_API + COMBINED_ASSEMBLIES;DEBUGGER_LISTENS_FIXED_PORT;ENABLE_ALTERNATIVE_LISTEN_PORT;ENABLE_AR;ENABLE_AUDIO;ENABLE_AUDIO_MANAGER_BASED_SCHEDULING;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_CLOUD_HUB;ENABLE_CLOUD_LICENSE;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_COLLAB_TESTING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_DUCK_TYPING;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_GRID;ENABLE_HOLOLENS_MODULE_API;ENABLE_LOCALIZATION;ENABLE_LZMA;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MICROPHONE;ENABLE_MONO;ENABLE_MONO_BDWGC;ENABLE_MOVIES;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NETWORK;ENABLE_PACKMAN;ENABLE_PHYSICS;ENABLE_SPATIALTRACKING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TEXTURE_STREAMING;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_UNITYWEBREQUEST;ENABLE_UNITYWEBREQUEST;ENABLE_UNLOCKED_DIAGNOSTIC_SWITCHES;ENABLE_VERSION_CONTROL_INTEGRATION;ENABLE_VIDEO;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WEBSOCKET_CLIENT;ENABLE_WWW;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_PUBNUB;PLATFORM_SUPPORTS_MONO;PLAYERCONNECTION_LISTENS_FIXED_PORT;RENDER_SOFTWARE_CURSOR;TRACE;UNITY_ANDROID_API;UNITY_ASSEMBLIES_API;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_API;UNITY_IPHONE_API;UNITY_METRO_API;UNITY_N3DS_API;UNITY_PS4_API;UNITY_PS4_API;UNITY_PSVITA_API;UNITY_STANDALONE_LINUX_API;UNITY_STANDALONE_OSX_API;UNITY_STANDALONE_WIN_API;UNITY_SWITCH_API;UNITY_TVOS_API;UNITY_WEBGL_API;UNITY_XBOXONE_API prompt 4 true diff --git a/Projects/CSharp/UnityEngine.csproj b/Projects/CSharp/UnityEngine.csproj index 34b34ea76e..58df6ddcf1 100644 --- a/Projects/CSharp/UnityEngine.csproj +++ b/Projects/CSharp/UnityEngine.csproj @@ -19,7 +19,7 @@ full false ..\..\artifacts\Bee.CSharpSupport\UnityEngine\Debug\ - COMBINED_ASSEMBLIES;DEBUG;DEBUGGER_LISTENS_FIXED_PORT;ENABLE_ALTERNATIVE_LISTEN_PORT;ENABLE_AR;ENABLE_AUDIO;ENABLE_AUDIO_MANAGER_BASED_SCHEDULING;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_CLOUD_HUB;ENABLE_CLOUD_LICENSE;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_COLLAB_TESTING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_DUCK_TYPING;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_GRID;ENABLE_HOLOLENS_MODULE_API;ENABLE_LOCALIZATION;ENABLE_LZMA;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MICROPHONE;ENABLE_MONO;ENABLE_MONO_BDWGC;ENABLE_MOVIES;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NETWORK;ENABLE_PACKMAN;ENABLE_PHYSICS;ENABLE_SPATIALTRACKING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TEXTURE_STREAMING;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_UNITYWEBREQUEST;ENABLE_UNITYWEBREQUEST;ENABLE_UNLOCKED_DIAGNOSTIC_SWITCHES;ENABLE_VERSION_CONTROL_INTEGRATION;ENABLE_VIDEO;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WEBSOCKET_CLIENT;ENABLE_WWW;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_PUBNUB;PLATFORM_SUPPORTS_MONO;PLAYERCONNECTION_LISTENS_FIXED_PORT;RENDER_SOFTWARE_CURSOR;TRACE;UNITY_ANDROID_API;UNITY_ASSEMBLIES_API;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_API;UNITY_IPHONE_API;UNITY_METRO_API;UNITY_N3DS_API;UNITY_PS4_API;UNITY_PS4_API;UNITY_PSVITA_API;UNITY_STANDALONE_LINUX_API;UNITY_STANDALONE_OSX_API;UNITY_STANDALONE_WIN_API;UNITY_SWITCH_API;UNITY_TVOS_API;UNITY_WEBGL_API;UNITY_XBOXONE_API + COMBINED_ASSEMBLIES;DEBUG;DEBUGGER_LISTENS_FIXED_PORT;ENABLE_ALTERNATIVE_LISTEN_PORT;ENABLE_AR;ENABLE_AUDIO;ENABLE_AUDIO_MANAGER_BASED_SCHEDULING;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_CLOUD_HUB;ENABLE_CLOUD_LICENSE;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_COLLAB_TESTING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_DUCK_TYPING;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_GRID;ENABLE_HOLOLENS_MODULE_API;ENABLE_LOCALIZATION;ENABLE_LZMA;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MICROPHONE;ENABLE_MONO;ENABLE_MONO_BDWGC;ENABLE_MOVIES;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NETWORK;ENABLE_PACKMAN;ENABLE_PHYSICS;ENABLE_SPATIALTRACKING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TEXTURE_STREAMING;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_UNITYWEBREQUEST;ENABLE_UNITYWEBREQUEST;ENABLE_UNLOCKED_DIAGNOSTIC_SWITCHES;ENABLE_VERSION_CONTROL_INTEGRATION;ENABLE_VIDEO;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WEBSOCKET_CLIENT;ENABLE_WWW;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_PUBNUB;PLATFORM_SUPPORTS_MONO;PLAYERCONNECTION_LISTENS_FIXED_PORT;RENDER_SOFTWARE_CURSOR;TRACE;UNITY_ANDROID_API;UNITY_ASSEMBLIES_API;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_API;UNITY_IPHONE_API;UNITY_METRO_API;UNITY_N3DS_API;UNITY_PS4_API;UNITY_PS4_API;UNITY_PSVITA_API;UNITY_STANDALONE_LINUX_API;UNITY_STANDALONE_OSX_API;UNITY_STANDALONE_WIN_API;UNITY_SWITCH_API;UNITY_TVOS_API;UNITY_WEBGL_API;UNITY_XBOXONE_API prompt 4 true @@ -31,7 +31,7 @@ pdbonly true ..\..\artifacts\Bee.CSharpSupport\UnityEngine\Release\ - COMBINED_ASSEMBLIES;DEBUGGER_LISTENS_FIXED_PORT;ENABLE_ALTERNATIVE_LISTEN_PORT;ENABLE_AR;ENABLE_AUDIO;ENABLE_AUDIO_MANAGER_BASED_SCHEDULING;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_CLOUD_HUB;ENABLE_CLOUD_LICENSE;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_COLLAB_TESTING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_DUCK_TYPING;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_GRID;ENABLE_HOLOLENS_MODULE_API;ENABLE_LOCALIZATION;ENABLE_LZMA;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MICROPHONE;ENABLE_MONO;ENABLE_MONO_BDWGC;ENABLE_MOVIES;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NETWORK;ENABLE_PACKMAN;ENABLE_PHYSICS;ENABLE_SPATIALTRACKING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TEXTURE_STREAMING;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_UNITYWEBREQUEST;ENABLE_UNITYWEBREQUEST;ENABLE_UNLOCKED_DIAGNOSTIC_SWITCHES;ENABLE_VERSION_CONTROL_INTEGRATION;ENABLE_VIDEO;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WEBSOCKET_CLIENT;ENABLE_WWW;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_PUBNUB;PLATFORM_SUPPORTS_MONO;PLAYERCONNECTION_LISTENS_FIXED_PORT;RENDER_SOFTWARE_CURSOR;TRACE;UNITY_ANDROID_API;UNITY_ASSEMBLIES_API;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_API;UNITY_IPHONE_API;UNITY_METRO_API;UNITY_N3DS_API;UNITY_PS4_API;UNITY_PS4_API;UNITY_PSVITA_API;UNITY_STANDALONE_LINUX_API;UNITY_STANDALONE_OSX_API;UNITY_STANDALONE_WIN_API;UNITY_SWITCH_API;UNITY_TVOS_API;UNITY_WEBGL_API;UNITY_XBOXONE_API + COMBINED_ASSEMBLIES;DEBUGGER_LISTENS_FIXED_PORT;ENABLE_ALTERNATIVE_LISTEN_PORT;ENABLE_AR;ENABLE_AUDIO;ENABLE_AUDIO_MANAGER_BASED_SCHEDULING;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_CLOUD_HUB;ENABLE_CLOUD_LICENSE;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_COLLAB_TESTING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_DUCK_TYPING;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_GRID;ENABLE_HOLOLENS_MODULE_API;ENABLE_LOCALIZATION;ENABLE_LZMA;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MICROPHONE;ENABLE_MONO;ENABLE_MONO_BDWGC;ENABLE_MOVIES;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NETWORK;ENABLE_PACKMAN;ENABLE_PHYSICS;ENABLE_SPATIALTRACKING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TEXTURE_STREAMING;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_UNITYWEBREQUEST;ENABLE_UNITYWEBREQUEST;ENABLE_UNLOCKED_DIAGNOSTIC_SWITCHES;ENABLE_VERSION_CONTROL_INTEGRATION;ENABLE_VIDEO;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WEBSOCKET_CLIENT;ENABLE_WWW;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_PUBNUB;PLATFORM_SUPPORTS_MONO;PLAYERCONNECTION_LISTENS_FIXED_PORT;RENDER_SOFTWARE_CURSOR;TRACE;UNITY_ANDROID_API;UNITY_ASSEMBLIES_API;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_API;UNITY_IPHONE_API;UNITY_METRO_API;UNITY_N3DS_API;UNITY_PS4_API;UNITY_PS4_API;UNITY_PSVITA_API;UNITY_STANDALONE_LINUX_API;UNITY_STANDALONE_OSX_API;UNITY_STANDALONE_WIN_API;UNITY_SWITCH_API;UNITY_TVOS_API;UNITY_WEBGL_API;UNITY_XBOXONE_API prompt 4 true @@ -2108,8 +2108,14 @@ Runtime\VR\HoloLens\ScriptBindings\GestureRecognizer.bindings.cs - - Runtime\VR\HoloLens\ScriptBindings\HolographicEmulation.cs + + Runtime\VR\HoloLens\ScriptBindings\HolographicAutomation.bindings.cs + + + Runtime\VR\HoloLens\ScriptBindings\HolographicAutomationUtils.cs + + + Runtime\VR\HoloLens\ScriptBindings\HolographicEmulation.bindings.cs Runtime\VR\HoloLens\ScriptBindings\HolographicSettings.bindings.cs @@ -2210,9 +2216,6 @@ artifacts\generated\bindings_old\common\UNET\UNETworkingBindings.gen.cs - - artifacts\generated\bindings_old\common\VR\HolographicEmulationBindings.gen.cs - artifacts\generated\bindings_old\common\VR\VRBindings.gen.cs diff --git a/README.md b/README.md index 5cbfd41b62..518cd40496 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b2 C# reference source code +## Unity 2018.2.0b3 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Animation/Managed/IAnimationJobPlayable.cs b/Runtime/Animation/Managed/IAnimationJobPlayable.cs index 1506f2b81f..9d13756e7b 100644 --- a/Runtime/Animation/Managed/IAnimationJobPlayable.cs +++ b/Runtime/Animation/Managed/IAnimationJobPlayable.cs @@ -12,7 +12,7 @@ namespace UnityEngine.Experimental.Animations public interface IAnimationJobPlayable : IPlayable { T GetJobData() where T : struct, IAnimationJob; - void SetJobData(T value) where T : struct, IAnimationJob; + void SetJobData(T jobData) where T : struct, IAnimationJob; } } diff --git a/Runtime/Animation/ScriptBindings/AnimationHumanStream.bindings.cs b/Runtime/Animation/ScriptBindings/AnimationHumanStream.bindings.cs index 879db5313a..35ea341430 100644 --- a/Runtime/Animation/ScriptBindings/AnimationHumanStream.bindings.cs +++ b/Runtime/Animation/ScriptBindings/AnimationHumanStream.bindings.cs @@ -18,14 +18,14 @@ public struct AnimationHumanStream { private System.IntPtr stream; - public bool IsValid() + public bool isValid { - return stream != System.IntPtr.Zero; + get { return stream != System.IntPtr.Zero; } } private void ThrowIfInvalid() { - if (!IsValid()) + if (!isValid) throw new InvalidOperationException("The AnimationHumanStream is invalid."); } @@ -35,17 +35,29 @@ private void ThrowIfInvalid() public float rightFootHeight { get { ThrowIfInvalid(); return GetFootHeight(false); } } - public Vector3 GetBodyLocalPosition() { ThrowIfInvalid(); return InternalGetBodyLocalPosition(); } - public void SetBodyLocalPosition(Vector3 value) { ThrowIfInvalid(); InternalSetBodyLocalPosition(value); } + public Vector3 bodyLocalPosition + { + get { ThrowIfInvalid(); return InternalGetBodyLocalPosition(); } + set { ThrowIfInvalid(); InternalSetBodyLocalPosition(value); } + } - public Quaternion GetBodyLocalRotation() { ThrowIfInvalid(); return InternalGetBodyLocalRotation(); } - public void SetBodyLocalRotation(Quaternion value) { ThrowIfInvalid(); InternalSetBodyLocalRotation(value); } + public Quaternion bodyLocalRotation + { + get { ThrowIfInvalid(); return InternalGetBodyLocalRotation(); } + set { ThrowIfInvalid(); InternalSetBodyLocalRotation(value); } + } - public Vector3 GetBodyPosition() { ThrowIfInvalid(); return InternalGetBodyPosition(); } - public void SetBodyPosition(Vector3 value) { ThrowIfInvalid(); InternalSetBodyPosition(value); } + public Vector3 bodyPosition + { + get { ThrowIfInvalid(); return InternalGetBodyPosition(); } + set { ThrowIfInvalid(); InternalSetBodyPosition(value); } + } - public Quaternion GetBodyRotation() { ThrowIfInvalid(); return InternalGetBodyRotation(); } - public void SetBodyRotation(Quaternion value) { ThrowIfInvalid(); InternalSetBodyRotation(value); } + public Quaternion bodyRotation + { + get { ThrowIfInvalid(); return InternalGetBodyRotation(); } + set { ThrowIfInvalid(); InternalSetBodyRotation(value); } + } public float GetMuscle(MuscleHandle muscle) { ThrowIfInvalid(); return InternalGetMuscle(muscle); } public void SetMuscle(MuscleHandle muscle, float value) { ThrowIfInvalid(); InternalSetMuscle(muscle, value); } @@ -54,7 +66,7 @@ private void ThrowIfInvalid() public Vector3 rightFootVelocity { get { ThrowIfInvalid(); return GetRightFootVelocity(); } } // IK goals - public void SetStancePose() { ThrowIfInvalid(); InternalSetStancePose(); } + public void ResetToStancePose() { ThrowIfInvalid(); InternalResetToStancePose(); } public Vector3 GetGoalPositionFromPose(AvatarIKGoal index) { ThrowIfInvalid(); return InternalGetGoalPositionFromPose(index); } public Quaternion GetGoalRotationFromPose(AvatarIKGoal index) { ThrowIfInvalid(); return InternalGetGoalRotationFromPose(index); } @@ -84,7 +96,7 @@ private void ThrowIfInvalid() public void SetLookAtBodyWeight(float weight) { ThrowIfInvalid(); InternalSetLookAtBodyWeight(weight); } public void SetLookAtHeadWeight(float weight) { ThrowIfInvalid(); InternalSetLookAtHeadWeight(weight); } public void SetLookAtEyesWeight(float weight) { ThrowIfInvalid(); InternalSetLookAtEyesWeight(weight); } - public void IKSolve() { ThrowIfInvalid(); InternalIKSolve(); } + public void SolveIK() { ThrowIfInvalid(); InternalSolveIK(); } [NativeMethod(IsThreadSafe = true)] private extern float GetHumanScale(); @@ -92,8 +104,8 @@ private void ThrowIfInvalid() [NativeMethod(IsThreadSafe = true)] private extern float GetFootHeight(bool left); - [NativeMethod(Name = "SetStancePose", IsThreadSafe = true)] - private extern void InternalSetStancePose(); + [NativeMethod(Name = "ResetToStancePose", IsThreadSafe = true)] + private extern void InternalResetToStancePose(); [NativeMethod(Name = "AnimationHumanStreamBindings::GetGoalPositionFromPose", IsFreeFunction = true, IsThreadSafe = true, HasExplicitThis = true)] private extern Vector3 InternalGetGoalPositionFromPose(AvatarIKGoal index); @@ -199,7 +211,7 @@ private void ThrowIfInvalid() [NativeMethod(Name = "SetLookAtEyesWeight", IsThreadSafe = true)] private extern void InternalSetLookAtEyesWeight(float weight); - [NativeMethod(Name = "IKSolve", IsThreadSafe = true)] - private extern void InternalIKSolve(); + [NativeMethod(Name = "SolveIK", IsThreadSafe = true)] + private extern void InternalSolveIK(); } } diff --git a/Runtime/Animation/ScriptBindings/AnimationScriptPlayable.bindings.cs b/Runtime/Animation/ScriptBindings/AnimationScriptPlayable.bindings.cs index 6b5d9299c2..7ad47a9717 100644 --- a/Runtime/Animation/ScriptBindings/AnimationScriptPlayable.bindings.cs +++ b/Runtime/Animation/ScriptBindings/AnimationScriptPlayable.bindings.cs @@ -23,16 +23,16 @@ public struct AnimationScriptPlayable : IAnimationJobPlayable, IEquatable(PlayableGraph graph, T job, int inputCount = 0) + public static AnimationScriptPlayable Create(PlayableGraph graph, T jobData, int inputCount = 0) where T : struct, IAnimationJob { - var handle = CreateHandle(graph, job, inputCount); + var handle = CreateHandle(graph, inputCount); var playable = new AnimationScriptPlayable(handle); - playable.SetJobData(job); + playable.SetJobData(jobData); return playable; } - private static PlayableHandle CreateHandle(PlayableGraph graph, T job, int inputCount) + private static PlayableHandle CreateHandle(PlayableGraph graph, int inputCount) where T : struct, IAnimationJob { IntPtr jobReflectionData = ProcessAnimationJobStruct.GetJobReflectionData(); @@ -79,12 +79,12 @@ public unsafe T GetJobData() return data; } - public unsafe void SetJobData(T value) + public unsafe void SetJobData(T jobData) where T : struct, IAnimationJob { CheckJobTypeValidity(); - UnsafeUtility.CopyStructureToPtr(ref value, (void*)GetHandle().GetAdditionalPayload()); + UnsafeUtility.CopyStructureToPtr(ref jobData, (void*)GetHandle().GetAdditionalPayload()); } public static implicit operator Playable(AnimationScriptPlayable playable) diff --git a/Runtime/Animation/ScriptBindings/AnimationStream.bindings.cs b/Runtime/Animation/ScriptBindings/AnimationStream.bindings.cs index debd73b2b6..96f5b6c60b 100644 --- a/Runtime/Animation/ScriptBindings/AnimationStream.bindings.cs +++ b/Runtime/Animation/ScriptBindings/AnimationStream.bindings.cs @@ -44,21 +44,24 @@ internal UInt32 animatorBindingsVersion get { return m_AnimatorBindingsVersion; } } - public bool IsValid() + public bool isValid { - return m_AnimatorBindingsVersion >= (UInt32)AnimatorBindingsVersion.kValidMinVersion && - constant != System.IntPtr.Zero && - input != System.IntPtr.Zero && - output != System.IntPtr.Zero && - workspace != System.IntPtr.Zero && - streamHandles != System.IntPtr.Zero && - transformSceneHandles != System.IntPtr.Zero && - propertySceneHandles != System.IntPtr.Zero; + get + { + return m_AnimatorBindingsVersion >= (UInt32)AnimatorBindingsVersion.kValidMinVersion && + constant != System.IntPtr.Zero && + input != System.IntPtr.Zero && + output != System.IntPtr.Zero && + workspace != System.IntPtr.Zero && + streamHandles != System.IntPtr.Zero && + transformSceneHandles != System.IntPtr.Zero && + propertySceneHandles != System.IntPtr.Zero; + } } internal void CheckIsValid() { - if (!IsValid()) + if (!isValid) throw new InvalidOperationException("The AnimationStream is invalid."); } @@ -94,21 +97,18 @@ public bool isHumanStream get { CheckIsValid(); return GetIsHumanStream(); } } - public AnimationHumanStream humanStream + public AnimationHumanStream AsHuman() { - get - { - CheckIsValid(); - if (!GetIsHumanStream()) - throw new InvalidOperationException("Cannot create an AnimationHumanStream for a generic rig."); + CheckIsValid(); + if (!GetIsHumanStream()) + throw new InvalidOperationException("Cannot create an AnimationHumanStream for a generic rig."); - return GetHumanStream(); - } + return GetHumanStream(); } - public int inputCount + public int inputStreamCount { - get { CheckIsValid(); return GetInputCount(); } + get { CheckIsValid(); return GetInputStreamCount(); } } public AnimationStream GetInputStream(int index) @@ -146,7 +146,7 @@ public AnimationStream GetInputStream(int index) private extern Quaternion GetRootMotionRotation(); [NativeMethod(IsThreadSafe = true)] - private extern int GetInputCount(); + private extern int GetInputStreamCount(); [NativeMethod(Name = "GetInputStream", IsThreadSafe = true)] private extern AnimationStream InternalGetInputStream(int index); diff --git a/Runtime/Animation/ScriptBindings/AnimationStreamHandles.bindings.cs b/Runtime/Animation/ScriptBindings/AnimationStreamHandles.bindings.cs index 89a6eb0be2..186359acc1 100644 --- a/Runtime/Animation/ScriptBindings/AnimationStreamHandles.bindings.cs +++ b/Runtime/Animation/ScriptBindings/AnimationStreamHandles.bindings.cs @@ -27,18 +27,23 @@ internal enum BindType [StructLayout(LayoutKind.Sequential)] public struct TransformStreamHandle { - private UInt32 animatorBindingsVersion; + private UInt32 m_AnimatorBindingsVersion; private int handleIndex; private int skeletonIndex; public bool IsValid(AnimationStream stream) { - return stream.IsValid() && IsCreatedByNative(); + return IsValidInternal(ref stream); + } + + private bool IsValidInternal(ref AnimationStream stream) + { + return stream.isValid && createdByNative; } - private bool IsCreatedByNative() + private bool createdByNative { - return animatorBindingsVersion != (UInt32)AnimatorBindingsVersion.kInvalidNotNative; + get { return animatorBindingsVersion != (UInt32)AnimatorBindingsVersion.kInvalidNotNative; } } private bool IsSameVersionAsStream(ref AnimationStream stream) @@ -46,20 +51,21 @@ private bool IsSameVersionAsStream(ref AnimationStream stream) return animatorBindingsVersion == stream.animatorBindingsVersion; } - private bool HasHandleIndex() + private bool hasHandleIndex { - return handleIndex != AnimationStream.InvalidIndex; + get { return handleIndex != AnimationStream.InvalidIndex; } } - private bool HasSkeletonIndex() + private bool hasSkeletonIndex { - return skeletonIndex != AnimationStream.InvalidIndex; + get { return skeletonIndex != AnimationStream.InvalidIndex; } } // internal for EditorTests - internal UInt32 GetAnimatorBindingsVersion() + internal UInt32 animatorBindingsVersion { - return animatorBindingsVersion; + private set { m_AnimatorBindingsVersion = value; } + get { return m_AnimatorBindingsVersion; } } public void Resolve(AnimationStream stream) @@ -74,10 +80,10 @@ public bool IsResolved(AnimationStream stream) private bool IsResolvedInternal(ref AnimationStream stream) { - return IsCreatedByNative() && + return IsValidInternal(ref stream) && IsSameVersionAsStream(ref stream) && - HasHandleIndex() && - HasSkeletonIndex(); + hasHandleIndex && + hasSkeletonIndex; } private void CheckIsValidAndResolve(ref AnimationStream stream) @@ -89,15 +95,15 @@ private void CheckIsValidAndResolve(ref AnimationStream stream) return; // Handle create directly by user are never valid - if (!IsCreatedByNative()) + if (!createdByNative) throw new InvalidOperationException("The TransformStreamHandle is invalid. Please use proper function to create the handle."); - if (!IsSameVersionAsStream(ref stream) || (HasHandleIndex() && !HasSkeletonIndex())) + if (!IsSameVersionAsStream(ref stream) || (hasHandleIndex && !hasSkeletonIndex)) { ResolveInternal(ref stream); } - if (HasHandleIndex() && !HasSkeletonIndex()) + if (hasHandleIndex && !hasSkeletonIndex) throw new InvalidOperationException("The TransformStreamHandle cannot be resolved."); } @@ -154,19 +160,24 @@ private void CheckIsValidAndResolve(ref AnimationStream stream) [StructLayout(LayoutKind.Sequential)] public struct PropertyStreamHandle { - private UInt32 animatorBindingsVersion; + private UInt32 m_AnimatorBindingsVersion; private int handleIndex; private int valueArrayIndex; private int bindType; public bool IsValid(AnimationStream stream) { - return stream.IsValid() && IsCreatedByNative(); + return IsValidInternal(ref stream); + } + + private bool IsValidInternal(ref AnimationStream stream) + { + return stream.isValid && createdByNative; } - private bool IsCreatedByNative() + private bool createdByNative { - return animatorBindingsVersion != (UInt32)AnimatorBindingsVersion.kInvalidNotNative; + get { return animatorBindingsVersion != (UInt32)AnimatorBindingsVersion.kInvalidNotNative; } } private bool IsSameVersionAsStream(ref AnimationStream stream) @@ -174,25 +185,26 @@ private bool IsSameVersionAsStream(ref AnimationStream stream) return animatorBindingsVersion == stream.animatorBindingsVersion; } - private bool HasHandleIndex() + private bool hasHandleIndex { - return handleIndex != AnimationStream.InvalidIndex; + get { return handleIndex != AnimationStream.InvalidIndex; } } - private bool HasValueArrayIndex() + private bool hasValueArrayIndex { - return valueArrayIndex != AnimationStream.InvalidIndex; + get { return valueArrayIndex != AnimationStream.InvalidIndex; } } - private bool HasBindType() + private bool hasBindType { - return bindType != (int)BindType.Unbound; + get { return bindType != (int)BindType.Unbound; } } // internal for EditorTests - internal UInt32 GetAnimatorBindingsVersion() + internal UInt32 animatorBindingsVersion { - return animatorBindingsVersion; + private set { m_AnimatorBindingsVersion = value; } + get { return m_AnimatorBindingsVersion; } } public void Resolve(AnimationStream stream) @@ -207,11 +219,11 @@ public bool IsResolved(AnimationStream stream) private bool IsResolvedInternal(ref AnimationStream stream) { - return IsCreatedByNative() && + return IsValidInternal(ref stream) && IsSameVersionAsStream(ref stream) && - HasBindType() && - HasHandleIndex() && - HasValueArrayIndex(); + hasBindType && + hasHandleIndex && + hasValueArrayIndex; } private void CheckIsValidAndResolve(ref AnimationStream stream) @@ -223,15 +235,15 @@ private void CheckIsValidAndResolve(ref AnimationStream stream) return; // Handle create directly by user are never valid - if (!IsCreatedByNative() || !HasBindType()) + if (!createdByNative || !hasBindType) throw new InvalidOperationException("The PropertyStreamHandle is invalid. Please use proper function to create the handle."); - if (!IsSameVersionAsStream(ref stream) || (HasHandleIndex() && !HasValueArrayIndex())) + if (!IsSameVersionAsStream(ref stream) || (hasHandleIndex && !hasValueArrayIndex)) { ResolveInternal(ref stream); } - if (HasHandleIndex() && !HasValueArrayIndex()) + if (hasHandleIndex && !hasValueArrayIndex) throw new InvalidOperationException("The PropertyStreamHandle cannot be resolved."); } @@ -315,20 +327,20 @@ public struct TransformSceneHandle public bool IsValid(AnimationStream stream) { - return stream.IsValid() && - IsCreatedByNative() && + return stream.isValid && + createdByNative && HasValidTransform(ref stream) && - HasTransformSceneHandleDefinitionIndex(); + hasTransformSceneHandleDefinitionIndex; } - private bool IsCreatedByNative() + private bool createdByNative { - return valid != 0; + get { return valid != 0; } } - private bool HasTransformSceneHandleDefinitionIndex() + private bool hasTransformSceneHandleDefinitionIndex { - return transformSceneHandleDefinitionIndex != AnimationStream.InvalidIndex; + get { return transformSceneHandleDefinitionIndex != AnimationStream.InvalidIndex; } } private void CheckIsValid(ref AnimationStream stream) @@ -337,17 +349,17 @@ private void CheckIsValid(ref AnimationStream stream) stream.CheckIsValid(); var hasValidTransform = HasValidTransform(ref stream); - if (IsCreatedByNative() && hasValidTransform && HasTransformSceneHandleDefinitionIndex()) + if (createdByNative && hasValidTransform && hasTransformSceneHandleDefinitionIndex) return; // Handle create directly by user are never valid - if (!IsCreatedByNative()) + if (!createdByNative) throw new InvalidOperationException("The TransformSceneHandle is invalid. Please use proper function to create the handle."); if (!hasValidTransform) throw new NullReferenceException("The transform is invalid."); - if (!HasTransformSceneHandleDefinitionIndex()) + if (!hasTransformSceneHandleDefinitionIndex) throw new InvalidOperationException("The TransformSceneHandle cannot be resolved."); } @@ -459,20 +471,20 @@ public bool IsValid(AnimationStream stream) private bool IsValidInternal(ref AnimationStream stream) { - return stream.IsValid() && - IsCreatedByNative() && + return stream.isValid && + createdByNative && HasValidTransform(ref stream) && - HasHandleIndex(); + hasHandleIndex; } - private bool IsCreatedByNative() + private bool createdByNative { - return valid != 0; + get { return valid != 0; } } - private bool HasHandleIndex() + private bool hasHandleIndex { - return handleIndex != AnimationStream.InvalidIndex; + get { return handleIndex != AnimationStream.InvalidIndex; } } public void Resolve(AnimationStream stream) @@ -492,17 +504,17 @@ private void CheckIsValid(ref AnimationStream stream) stream.CheckIsValid(); var hasValidTransform = HasValidTransform(ref stream); - if (IsCreatedByNative() && hasValidTransform && HasHandleIndex()) + if (createdByNative && hasValidTransform && hasHandleIndex) return; // Handle create directly by user are never valid - if (!IsCreatedByNative()) + if (!createdByNative) throw new InvalidOperationException("The PropertySceneHandle is invalid. Please use proper function to create the handle."); if (!hasValidTransform) throw new NullReferenceException("The transform is invalid."); - if (!HasHandleIndex()) + if (!hasHandleIndex) throw new InvalidOperationException("The PropertySceneHandle cannot be resolved."); } diff --git a/Runtime/Animation/ScriptBindings/Animator.bindings.cs b/Runtime/Animation/ScriptBindings/Animator.bindings.cs index 218a492316..55199f2296 100644 --- a/Runtime/Animation/ScriptBindings/Animator.bindings.cs +++ b/Runtime/Animation/ScriptBindings/Animator.bindings.cs @@ -966,7 +966,13 @@ extern internal Transform avatarRoot get; } - public Transform GetBoneTransform(HumanBodyBones humanBoneId) {return GetBoneTransformInternal(HumanTrait.GetBoneIndexFromMono((int)humanBoneId)); } + public Transform GetBoneTransform(HumanBodyBones humanBoneId) + { + if (humanBoneId < 0 || humanBoneId >= HumanBodyBones.LastBone) + throw new IndexOutOfRangeException("humanBoneId must be between 0 and " + HumanBodyBones.LastBone); + + return GetBoneTransformInternal(HumanTrait.GetBoneIndexFromMono((int)humanBoneId)); + } [NativeMethod("GetBoneTransform")] extern internal Transform GetBoneTransformInternal(int humanBoneId); diff --git a/Runtime/Animation/ScriptBindings/Avatar.bindings.cs b/Runtime/Animation/ScriptBindings/Avatar.bindings.cs index 72a1bc064f..90af726da2 100644 --- a/Runtime/Animation/ScriptBindings/Avatar.bindings.cs +++ b/Runtime/Animation/ScriptBindings/Avatar.bindings.cs @@ -11,7 +11,7 @@ namespace UnityEngine { - public enum BodyDoF + public enum BodyDof { SpineFrontBack = 0, SpineLeftRight, @@ -22,10 +22,10 @@ public enum BodyDoF UpperChestFrontBack, UpperChestLeftRight, UpperChestRollLeftRight, - LastBodyDoF + LastBodyDof } - public enum HeadDoF + public enum HeadDof { NeckFrontBack = 0, NeckLeftRight, @@ -39,10 +39,10 @@ public enum HeadDoF RightEyeInOut, JawDownUp, JawLeftRight, - LastHeadDoF + LastHeadDof } - public enum LegDoF + public enum LegDof { UpperLegFrontBack = 0, UpperLegInOut, @@ -52,10 +52,10 @@ public enum LegDoF FootCloseOpen, FootInOut, ToesUpDown, - LastLegDoF + LastLegDof } - public enum ArmDoF + public enum ArmDof { ShoulderDownUp = 0, ShoulderFrontBack, @@ -66,19 +66,19 @@ public enum ArmDoF ForeArmRollInOut, HandDownUp, HandInOut, - LastArmDoF + LastArmDof } - public enum FingerDoF + public enum FingerDof { ProximalDownUp = 0, ProximalInOut, IntermediateCloseOpen, DistalCloseOpen, - LastFingerDoF + LastFingerDof } - public enum HumanPartDoF + public enum HumanPartDof { Body = 0, Head, @@ -96,32 +96,32 @@ public enum HumanPartDoF RightMiddle, RightRing, RightLittle, - LastHumanPartDoF + LastHumanPartDof } - internal enum DoF + internal enum Dof { - BodyDoFStart = 0, - HeadDoFStart = (int)BodyDoFStart + (int)BodyDoF.LastBodyDoF, - LeftLegDoFStart = (int)HeadDoFStart + (int)HeadDoF.LastHeadDoF, - RightLegDoFStart = (int)LeftLegDoFStart + (int)LegDoF.LastLegDoF, - LeftArmDoFStart = (int)RightLegDoFStart + (int)LegDoF.LastLegDoF, - RightArmDoFStart = (int)LeftArmDoFStart + (int)ArmDoF.LastArmDoF, - - LeftThumbDoFStart = (int)RightArmDoFStart + (int)ArmDoF.LastArmDoF, - LeftIndexDoFStart = (int)LeftThumbDoFStart + (int)FingerDoF.LastFingerDoF, - LeftMiddleDoFStart = (int)LeftIndexDoFStart + (int)FingerDoF.LastFingerDoF, - - LeftRingDoFStart = (int)LeftMiddleDoFStart + (int)FingerDoF.LastFingerDoF, - LeftLittleDoFStart = (int)LeftRingDoFStart + (int)FingerDoF.LastFingerDoF, - - RightThumbDoFStart = (int)LeftLittleDoFStart + (int)FingerDoF.LastFingerDoF, - RightIndexDoFStart = (int)RightThumbDoFStart + (int)FingerDoF.LastFingerDoF, - RightMiddleDoFStart = (int)RightIndexDoFStart + (int)FingerDoF.LastFingerDoF, - RightRingDoFStart = (int)RightMiddleDoFStart + (int)FingerDoF.LastFingerDoF, - RightLittleDoFStart = (int)RightRingDoFStart + (int)FingerDoF.LastFingerDoF, - - LastDoF = (int)RightLittleDoFStart + (int)FingerDoF.LastFingerDoF + BodyDofStart = 0, + HeadDofStart = (int)BodyDofStart + (int)BodyDof.LastBodyDof, + LeftLegDofStart = (int)HeadDofStart + (int)HeadDof.LastHeadDof, + RightLegDofStart = (int)LeftLegDofStart + (int)LegDof.LastLegDof, + LeftArmDofStart = (int)RightLegDofStart + (int)LegDof.LastLegDof, + RightArmDofStart = (int)LeftArmDofStart + (int)ArmDof.LastArmDof, + + LeftThumbDofStart = (int)RightArmDofStart + (int)ArmDof.LastArmDof, + LeftIndexDofStart = (int)LeftThumbDofStart + (int)FingerDof.LastFingerDof, + LeftMiddleDofStart = (int)LeftIndexDofStart + (int)FingerDof.LastFingerDof, + + LeftRingDofStart = (int)LeftMiddleDofStart + (int)FingerDof.LastFingerDof, + LeftLittleDofStart = (int)LeftRingDofStart + (int)FingerDof.LastFingerDof, + + RightThumbDofStart = (int)LeftLittleDofStart + (int)FingerDof.LastFingerDof, + RightIndexDofStart = (int)RightThumbDofStart + (int)FingerDof.LastFingerDof, + RightMiddleDofStart = (int)RightIndexDofStart + (int)FingerDof.LastFingerDof, + RightRingDofStart = (int)RightMiddleDofStart + (int)FingerDof.LastFingerDof, + RightLittleDofStart = (int)RightRingDofStart + (int)FingerDof.LastFingerDof, + + LastDof = (int)RightLittleDofStart + (int)FingerDof.LastFingerDof } // Human Body Bones diff --git a/Runtime/Animation/ScriptBindings/HumanTrait.bindings.cs b/Runtime/Animation/ScriptBindings/HumanTrait.bindings.cs index 2f1ede9b28..407dac0aa0 100644 --- a/Runtime/Animation/ScriptBindings/HumanTrait.bindings.cs +++ b/Runtime/Animation/ScriptBindings/HumanTrait.bindings.cs @@ -26,6 +26,7 @@ extern public static int MuscleCount // Muscle's name extern public static string[] MuscleName { + [NativeMethod("GetMuscleNames")] get; } @@ -38,7 +39,7 @@ extern public static int BoneCount // Bone's name extern public static string[] BoneName { - [NativeMethod("MonoBoneName")] + [NativeMethod("MonoBoneNames")] get; } diff --git a/Runtime/Animation/ScriptBindings/MuscleHandle.bindings.cs b/Runtime/Animation/ScriptBindings/MuscleHandle.bindings.cs index 07a6bf25f4..e375731e6b 100644 --- a/Runtime/Animation/ScriptBindings/MuscleHandle.bindings.cs +++ b/Runtime/Animation/ScriptBindings/MuscleHandle.bindings.cs @@ -18,7 +18,7 @@ namespace UnityEngine.Experimental.Animations [StructLayout(LayoutKind.Sequential)] public struct MuscleHandle { - public HumanPartDoF humanPartDoF + public HumanPartDof humanPartDof { get; private set; @@ -29,60 +29,43 @@ public int dof private set; } - public MuscleHandle(BodyDoF bodyDoF) + public MuscleHandle(BodyDof bodyDof) { - humanPartDoF = HumanPartDoF.Body; - dof = (int)bodyDoF; + humanPartDof = HumanPartDof.Body; + dof = (int)bodyDof; } - public MuscleHandle(HeadDoF headDoF) + public MuscleHandle(HeadDof headDof) { - humanPartDoF = HumanPartDoF.Head; - dof = (int)headDoF; + humanPartDof = HumanPartDof.Head; + dof = (int)headDof; } - public MuscleHandle(HumanPartDoF partDoF, BodyDoF bodyDoF) + public MuscleHandle(HumanPartDof partDof, LegDof legDof) { - if (partDoF != HumanPartDoF.Body) - throw new InvalidOperationException("Invalid HumanPartDoF for body, please use HumanPartDoF.Body"); - humanPartDoF = HumanPartDoF.Body; - dof = (int)bodyDoF; - } - - public MuscleHandle(HumanPartDoF partDoF, HeadDoF headDoF) - { - if (partDoF != HumanPartDoF.Head) - throw new InvalidOperationException("Invalid HumanPartDoF for head, please use HumanPartDoF.Head"); - - humanPartDoF = HumanPartDoF.Head; - dof = (int)headDoF; - } - - public MuscleHandle(HumanPartDoF partDoF, LegDoF legDoF) - { - if (partDoF != HumanPartDoF.LeftLeg && partDoF != HumanPartDoF.RightLeg) - throw new InvalidOperationException("Invalid HumanPartDoF for a leg, please use either HumanPartDoF.LeftLeg or HumanPartDoF.RightLeg."); + if (partDof != HumanPartDof.LeftLeg && partDof != HumanPartDof.RightLeg) + throw new InvalidOperationException("Invalid HumanPartDof for a leg, please use either HumanPartDof.LeftLeg or HumanPartDof.RightLeg."); - humanPartDoF = partDoF; - dof = (int)legDoF; + humanPartDof = partDof; + dof = (int)legDof; } - public MuscleHandle(HumanPartDoF partDoF, ArmDoF armDoF) + public MuscleHandle(HumanPartDof partDof, ArmDof armDof) { - if (partDoF != HumanPartDoF.LeftArm && partDoF != HumanPartDoF.RightArm) - throw new InvalidOperationException("Invalid HumanPartDoF for an arm, please use either HumanPartDoF.LeftArm or HumanPartDoF.RightArm."); + if (partDof != HumanPartDof.LeftArm && partDof != HumanPartDof.RightArm) + throw new InvalidOperationException("Invalid HumanPartDof for an arm, please use either HumanPartDof.LeftArm or HumanPartDof.RightArm."); - humanPartDoF = partDoF; - dof = (int)armDoF; + humanPartDof = partDof; + dof = (int)armDof; } - public MuscleHandle(HumanPartDoF partDoF, FingerDoF fingerDoF) + public MuscleHandle(HumanPartDof partDof, FingerDof fingerDof) { - if (partDoF < HumanPartDoF.LeftThumb || partDoF > HumanPartDoF.RightLittle) - throw new InvalidOperationException("Invalid HumanPartDoF for a finger."); + if (partDof < HumanPartDof.LeftThumb || partDof > HumanPartDof.RightLittle) + throw new InvalidOperationException("Invalid HumanPartDof for a finger."); - humanPartDoF = partDoF; - dof = (int)fingerDoF; + humanPartDof = partDof; + dof = (int)fingerDof; } public string name @@ -90,16 +73,16 @@ public string name get { return GetName(); } } - public static int muscleHandlesCount + public static int muscleHandleCount { - get { return GetMuscleHandlesCount(); } + get { return GetMuscleHandleCount(); } } public extern static void GetMuscleHandles([NotNull][Out] MuscleHandle[] muscleHandles); private extern string GetName(); - private extern static int GetMuscleHandlesCount(); + private extern static int GetMuscleHandleCount(); } } diff --git a/Runtime/Export/AssemblyInfo.cs b/Runtime/Export/AssemblyInfo.cs index f294855b0a..0f44d8337a 100644 --- a/Runtime/Export/AssemblyInfo.cs +++ b/Runtime/Export/AssemblyInfo.cs @@ -2,6 +2,7 @@ // Copyright (c) Unity Technologies. For terms of use, see // https://unity3d.com/legal/licenses/Unity_Reference_Only_License +using System.Reflection; using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("UnityEngine.Advertisements")] @@ -51,6 +52,7 @@ [assembly: InternalsVisibleTo("Unity.RuntimeTests.AllIn1Runner")] [assembly: InternalsVisibleTo("UnityEngine.SpatialTracking")] [assembly: InternalsVisibleTo("GoogleAR.UnityNative")] +[assembly: InternalsVisibleTo("Unity.WindowsMRAutomation")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.001")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.002")] diff --git a/Runtime/Export/PlayerLoop.bindings.cs b/Runtime/Export/PlayerLoop.bindings.cs index 098736c68c..eaa17793a5 100644 --- a/Runtime/Export/PlayerLoop.bindings.cs +++ b/Runtime/Export/PlayerLoop.bindings.cs @@ -122,8 +122,6 @@ public struct DirectorFixedUpdatePostPhysics {} [RequiredByNativeCode] public struct ScriptRunDelayedFixedFrameRate {} [RequiredByNativeCode] - public struct ScriptRunDelayedTasks {} - [RequiredByNativeCode] public struct NewInputFixedUpdate {} } [RequiredByNativeCode] @@ -157,6 +155,8 @@ public struct ScriptRunBehaviourUpdate {} public struct DirectorUpdate {} [RequiredByNativeCode] public struct ScriptRunDelayedDynamicFrameRate {} + [RequiredByNativeCode] + public struct ScriptRunDelayedTasks {} } [RequiredByNativeCode] public struct PreLateUpdate diff --git a/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs b/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs index e1f0208dce..68d97077ce 100644 --- a/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs +++ b/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs @@ -10,7 +10,7 @@ namespace UnityEngine.XR.WSA { public partial class HolographicRemoting { - public static HolographicStreamerConnectionState ConnectionState + public HolographicStreamerConnectionState ConnectionState { get { diff --git a/Runtime/VR/HoloLens/ScriptBindings/HolographicAutomation.bindings.cs b/Runtime/VR/HoloLens/ScriptBindings/HolographicAutomation.bindings.cs new file mode 100644 index 0000000000..d26363f98a --- /dev/null +++ b/Runtime/VR/HoloLens/ScriptBindings/HolographicAutomation.bindings.cs @@ -0,0 +1,80 @@ +// Unity C# reference source +// Copyright (c) Unity Technologies. For terms of use, see +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License + +using UnityEngine.Bindings; +using UnityEngine; +using UnityEngine.XR.WSA; + +namespace UnityEngine.XR.WSA +{ + [NativeHeader("Runtime/VR/HoloLens/HolographicEmulation/HolographicEmulationManager.h")] + internal enum GestureHand + { + Left, + Right + }; + + [NativeHeader("Runtime/VR/HoloLens/HolographicEmulation/HolographicEmulationManager.h")] + internal enum SimulatedGesture + { + FingerPressed, + FingerReleased + } + + [NativeHeader("Runtime/VR/HoloLens/HolographicEmulation/HolographicEmulationManager.h")] + [StaticAccessor("HolographicEmulation::HolographicEmulationManager::Get()", StaticAccessorType.Dot)] + [NativeConditional("ENABLE_HOLOLENS_MODULE")] + internal partial class HolographicAutomation + { + internal static extern void Initialize(); + + internal static extern void Shutdown(); + + internal static extern void LoadRoom(string id); + + internal static extern void SetEmulationMode(EmulationMode mode); + + internal static extern void SetGestureHand(GestureHand hand); + + [NativeName("ResetEmulationState")] + internal static extern void Reset(); + + internal static extern void PerformGesture(GestureHand hand, SimulatedGesture gesture); + + [NativeConditional("ENABLE_HOLOLENS_MODULE", StubReturnStatement = "Vector3f::zero")] + internal static extern Vector3 GetBodyPosition(); + + internal static extern void SetBodyPosition(Vector3 position); + + internal static extern float GetBodyRotation(); + + internal static extern void SetBodyRotation(float degrees); + + internal static extern float GetBodyHeight(); + + internal static extern void SetBodyHeight(float degrees); + + [NativeConditional("ENABLE_HOLOLENS_MODULE", StubReturnStatement = "Vector3f::zero")] + internal static extern Vector3 GetHeadRotation(); + + internal static extern void SetHeadRotation(Vector3 degrees); + + internal static extern float GetHeadDiameter(); + + internal static extern void SetHeadDiameter(float degrees); + + [NativeConditional("ENABLE_HOLOLENS_MODULE", StubReturnStatement = "Vector3f::zero")] + internal static extern Vector3 GetHandPosition(GestureHand hand); + + internal static extern void SetHandPosition(GestureHand hand, Vector3 position); + + internal static extern bool GetHandActivated(GestureHand hand); + + internal static extern void SetHandActivated(GestureHand hand, bool activated); + + internal static extern bool GetHandVisible(GestureHand hand); + + internal static extern void EnsureHandVisible(GestureHand hand); + } +} diff --git a/Runtime/VR/HoloLens/ScriptBindings/HolographicEmulation.cs b/Runtime/VR/HoloLens/ScriptBindings/HolographicAutomationUtils.cs similarity index 70% rename from Runtime/VR/HoloLens/ScriptBindings/HolographicEmulation.cs rename to Runtime/VR/HoloLens/ScriptBindings/HolographicAutomationUtils.cs index 5c20e580bf..e101489fd8 100644 --- a/Runtime/VR/HoloLens/ScriptBindings/HolographicEmulation.cs +++ b/Runtime/VR/HoloLens/ScriptBindings/HolographicAutomationUtils.cs @@ -2,125 +2,93 @@ // Copyright (c) Unity Technologies. For terms of use, see // https://unity3d.com/legal/licenses/Unity_Reference_Only_License +using System.Diagnostics; using UnityEngine; +using UnityEngine.Bindings; namespace UnityEngine.XR.WSA { internal class SimulatedBody { // Require use of HolographicEmulation.simulatedBody to get instance - internal SimulatedBody() {} + public SimulatedBody() {} public Vector3 position { - get - { - return Vector3.zero; - } - set - { - } + get { return HolographicAutomation.GetBodyPosition(); } + set { HolographicAutomation.SetBodyPosition(value); } } public float rotation { - get - { - return 0; - } - set - { - } + get { return HolographicAutomation.GetBodyRotation(); } + set { HolographicAutomation.SetBodyRotation(value); } } public float height { - get - { - return 0; - } - set - { - } + get { return HolographicAutomation.GetBodyHeight(); } + set { HolographicAutomation.SetBodyHeight(value); } } } internal class SimulatedHead { // Require use of HolographicEmulation.simulatedHead to get instance - internal SimulatedHead() {} + public SimulatedHead() {} public float diameter { - get - { - return 0; - } - set - { - } + get { return HolographicAutomation.GetHeadDiameter(); } + set { HolographicAutomation.SetHeadDiameter(value); } } public Vector3 eulerAngles { - get - { - return Vector3.zero; - } - set - { - } + get { return HolographicAutomation.GetHeadRotation(); } + set { HolographicAutomation.SetHeadRotation(value); } } } internal class SimulatedHand { + public GestureHand m_Hand; // Require use of HolographicEmulation.simulatedLeftHand or HolographicEmulation.simulatedRightHand to get instance internal SimulatedHand(GestureHand hand) { + m_Hand = hand; } public Vector3 position { - get - { - return Vector3.zero; - } - set - { - } + get { return HolographicAutomation.GetHandPosition(m_Hand); } + set { HolographicAutomation.SetHandPosition(m_Hand, value); } } public bool activated { - get - { - return false; - } - set - { - } + get { return HolographicAutomation.GetHandActivated(m_Hand); } + set { HolographicAutomation.SetHandActivated(m_Hand, value); } } public bool visible { - get - { - return false; - } + get { return HolographicAutomation.GetHandVisible(m_Hand); } } public void EnsureVisible() { + HolographicAutomation.EnsureHandVisible(m_Hand); } public void PerformGesture(SimulatedGesture gesture) { + HolographicAutomation.PerformGesture(m_Hand, gesture); } } - internal sealed partial class HolographicEmulation + internal partial class HolographicAutomation { static SimulatedBody s_Body = new SimulatedBody(); static SimulatedHead s_Head = new SimulatedHead(); diff --git a/Runtime/VR/HoloLens/ScriptBindings/HolographicEmulation.bindings.cs b/Runtime/VR/HoloLens/ScriptBindings/HolographicEmulation.bindings.cs new file mode 100644 index 0000000000..dc861b2137 --- /dev/null +++ b/Runtime/VR/HoloLens/ScriptBindings/HolographicEmulation.bindings.cs @@ -0,0 +1,65 @@ +// Unity C# reference source +// Copyright (c) Unity Technologies. For terms of use, see +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License + +using UnityEngine.Bindings; + +namespace UnityEngine.XR.WSA +{ + [NativeHeader("Runtime/VR/HoloLens/PerceptionRemoting.h")] + public enum HolographicStreamerConnectionState + { + Disconnected, + Connecting, + Connected + } + + [NativeHeader("Runtime/VR/HoloLens/PerceptionRemoting.h")] + public enum HolographicStreamerConnectionFailureReason + { + None, + Unknown, + Unreachable, + HandshakeFailed, + ProtocolVersionMismatch, + ConnectionLost + } + + [NativeHeader("Runtime/VR/HoloLens/PerceptionRemoting.h")] + internal enum EmulationMode + { + None, + RemoteDevice, + Simulated + }; + + [NativeHeader("Runtime/VR/HoloLens/HolographicEmulation/HolographicEmulationManager.h")] + [StaticAccessor("HolographicEmulation::HolographicEmulationManager::Get()", StaticAccessorType.Dot)] + internal partial class HolographicEmulationHelper + { + [NativeName("GetEmulationMode")] + [NativeConditional("ENABLE_HOLOLENS_MODULE", StubReturnStatement = "HolographicEmulation::EmulationMode_None")] + internal static extern EmulationMode GetEmulationMode(); + } + + [NativeHeader("Runtime/VR/HoloLens/PerceptionRemoting.h")] + [NativeConditional("ENABLE_HOLOLENS_MODULE")] + internal partial class PerceptionRemoting + { + internal static extern void Connect(string clientName); + + internal static extern void Disconnect(); + + [NativeConditional("ENABLE_HOLOLENS_MODULE", StubReturnStatement = "HolographicEmulation::None")] + internal static extern HolographicStreamerConnectionFailureReason CheckForDisconnect(); + + [NativeConditional("ENABLE_HOLOLENS_MODULE", StubReturnStatement = "HolographicEmulation::Disconnected")] + internal static extern HolographicStreamerConnectionState GetConnectionState(); + + internal static extern void SetEnableAudio(bool enable); + + internal static extern void SetEnableVideo(bool enable); + + internal static extern void SetVideoEncodingParameters(int maxBitRate); + } +} diff --git a/artifacts/generated/bindings_old/common/VR/HolographicEmulationBindings.gen.cs b/artifacts/generated/bindings_old/common/VR/HolographicEmulationBindings.gen.cs deleted file mode 100644 index b6cfdc3b4f..0000000000 --- a/artifacts/generated/bindings_old/common/VR/HolographicEmulationBindings.gen.cs +++ /dev/null @@ -1,124 +0,0 @@ -// Unity C# reference source -// Copyright (c) Unity Technologies. For terms of use, see -// https://unity3d.com/legal/licenses/Unity_Reference_Only_License - -using scm=System.ComponentModel; -using uei=UnityEngine.Internal; -using RequiredByNativeCodeAttribute=UnityEngine.Scripting.RequiredByNativeCodeAttribute; -using UsedByNativeCodeAttribute=UnityEngine.Scripting.UsedByNativeCodeAttribute; - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Collections; -using UnityEngine; - -namespace UnityEngine.XR.WSA -{ -public enum HolographicStreamerConnectionState -{ - Disconnected, - Connecting, - Connected -} - -public enum HolographicStreamerConnectionFailureReason -{ - None, - Unknown, - Unreachable, - HandshakeFailed, - ProtocolVersionMismatch, - ConnectionLost -} - - -internal enum EmulationMode -{ - None, - RemoteDevice, - Simulated - }; - internal enum GestureHand - { - Left, - Right - }; - internal enum SimulatedGesture - { - FingerPressed, - FingerReleased - } - - - internal sealed partial class HolographicEmulation - { - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void Initialize () ; - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void Shutdown () ; - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void LoadRoom (string id) ; - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void SetEmulationMode (EmulationMode mode) ; - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static EmulationMode GetEmulationMode () ; - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void SetGestureHand (GestureHand hand) ; - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void Reset () ; - - } - - internal sealed partial class PerceptionRemotingPlugin - { - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void Connect (string clientName) ; - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void Disconnect () ; - - internal static HolographicStreamerConnectionFailureReason CheckForDisconnect() - { - return HolographicStreamerConnectionFailureReason.None; - } - - - internal static HolographicStreamerConnectionState GetConnectionState() - { - return HolographicStreamerConnectionState.Disconnected; - } - - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void SetEnableAudio (bool enable) ; - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void SetEnableVideo (bool enable) ; - - [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration - [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] - extern internal static void SetVideoEncodingParameters (Int32 maxBitRate) ; - - } - - - } - From 5967ef9f2e3a947eee4525b9a46c67a1d1f12735 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Fri, 11 May 2018 19:14:37 +0000 Subject: [PATCH 03/13] Unity 2018.2.0b4 C# reference source code --- .../AssetImportContext.bindings.cs | 2 +- Editor/Mono/GI/Lightmapping.bindings.cs | 21 ++-- Editor/Mono/GUI/WindowLayout.cs | 8 +- Editor/Mono/GameView/GameView.cs | 2 +- .../LookDevView/CameraControllerStandard.cs | 9 +- Editor/Mono/LookDevView/LookDevView.cs | 2 + .../ParticleSystemEditor.cs | 6 +- .../LightingWindowLightmapPreviewTab.cs | 7 +- Editor/Mono/SceneView/CameraFlyModeContext.cs | 7 +- Editor/Mono/SceneView/SceneView.cs | 2 + Editor/Mono/SceneView/SceneViewMotion.cs | 11 +- .../Mono/Scripting/Compilers/BooCompiler.cs | 22 +++- .../ScriptCompilation/EditorCompilation.cs | 113 ++++++++++++++---- .../Mono/GoogleVR/VRCustomOptionsGoogleVR.cs | 10 +- .../VR/Mono/Oculus/VRCustomOptionsOculus.cs | 7 +- Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs | 2 +- Editor/Src/VR/Mono/VRCustomOptions.cs | 4 +- .../VRCustomOptionsWindowsHolographic.cs | 2 +- .../lib/mono/2.0/Boo.Lang.Compiler.dll | Bin 934912 -> 934912 bytes .../lib/mono/2.0/Boo.Lang.Parser.dll | Bin 414208 -> 414208 bytes .../lib/mono/2.0/Boo.Lang.dll | Bin 126976 -> 126976 bytes .../lib/mono/2.0/Mono.Posix.dll | Bin 184320 -> 184320 bytes .../lib/mono/2.0/Mono.Security.dll | Bin 294912 -> 294912 bytes .../lib/mono/2.0/System.Core.dll | Bin 297984 -> 297984 bytes .../lib/mono/2.0/System.Xml.Linq.dll | Bin 106496 -> 106496 bytes .../lib/mono/2.0/System.Xml.dll | Bin 1270272 -> 1270272 bytes .../monodistribution/lib/mono/2.0/System.dll | Bin 1679360 -> 1679360 bytes .../lib/mono/2.0/UnityScript.dll | Bin 177664 -> 177664 bytes Modules/Input/Private/Input.cs | 3 +- Modules/Input/Private/InputModule.bindings.cs | 21 +--- .../ShortcutManagerEditor/ContextManager.cs | 91 ++++++++++++++ Modules/ShortcutManagerEditor/Directory.cs | 31 ++++- Modules/ShortcutManagerEditor/IDirectory.cs | 1 + .../IShortcutPriorityContext.cs | 2 +- .../ReserveModifiersAttribute.cs | 19 +++ .../ShortcutController.cs | 44 +++++-- .../ShortcutManagerEditor/ShortcutEntry.cs | 4 +- Modules/ShortcutManagerEditor/Trigger.cs | 61 +++------- .../Managed/Grid/GridPaintPaletteWindow.cs | 6 +- Modules/UIElements/IMGUIContainer.cs | 3 - Modules/UIElements/UIElementsUtility.cs | 3 - .../UnityWebRequest/Public/WebRequestUtils.cs | 25 +++- Projects/CSharp/UnityEditor.csproj | 6 + README.md | 2 +- Runtime/Export/ShaderKeyword.bindings.cs | 21 ++-- Runtime/Export/ShaderKeywordSet.cs | 18 +++ 46 files changed, 432 insertions(+), 166 deletions(-) create mode 100644 Modules/ShortcutManagerEditor/ContextManager.cs create mode 100644 Modules/ShortcutManagerEditor/ReserveModifiersAttribute.cs diff --git a/Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs b/Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs index 5ab046bff7..c30f1d5497 100644 --- a/Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs +++ b/Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs @@ -52,7 +52,7 @@ public void AddObjectToAsset(string identifier, Object obj) // Create a dependency against the contents of the source asset at the provided path // * if the asset at the path changes, it will trigger an import // * if the asset at the path moves, it will trigger an import - internal void DependsOnSourceAsset(string path) + public void DependsOnSourceAsset(string path) { if (string.IsNullOrEmpty(path)) { diff --git a/Editor/Mono/GI/Lightmapping.bindings.cs b/Editor/Mono/GI/Lightmapping.bindings.cs index c4a6424d60..67e8fc4854 100644 --- a/Editor/Mono/GI/Lightmapping.bindings.cs +++ b/Editor/Mono/GI/Lightmapping.bindings.cs @@ -54,6 +54,13 @@ internal struct MemLabels public float[] sizes; } + internal struct GeoMemLabels + { + public string[] labels; + public float[] sizes; + public UInt64[] triCounts; + } + [NativeHeader("Editor/Src/GI/EditorHelpers.h")] internal struct LightingStats { @@ -218,18 +225,9 @@ public enum GIWorkflowMode [StaticAccessor("PVRMemoryLabelTracker::Get()", StaticAccessorType.Arrow)] internal static extern void ResetExplicitlyShownMemLabels(); - internal static void GetGeometryMemory(out string[] labels, out float[] sizes, out UInt64[] triCounts) - { - labels = new string[0]; - sizes = new float[0]; - triCounts = new UInt64[0]; - - GetGeometryMemoryInternal(labels, sizes, triCounts); - } - [StaticAccessor("PVROpenRLMemoryTracker::Get()", StaticAccessorType.Arrow)] [NativeName("GetGeometryMemory")] - internal static extern void GetGeometryMemoryInternal([Out] string[] labels, [Out] float[] sizes, [Out] UInt64[] triCounts); + internal static extern GeoMemLabels GetGeometryMemory(); [StaticAccessor("ProgressiveRuntimeManager::Get()", StaticAccessorType.Arrow)] internal static extern float ComputeTotalMemoryUsageInMB(); @@ -362,7 +360,8 @@ public static void BakeMultipleScenes(string[] paths) OnBakeFinish = () => { EditorSceneManager.SaveOpenScenes(); - EditorSceneManager.RestoreSceneManagerSetup(sceneSetup); + if (sceneSetup.Length > 0) + EditorSceneManager.RestoreSceneManagerSetup(sceneSetup); Lightmapping.completed -= OnBakeFinish; }; diff --git a/Editor/Mono/GUI/WindowLayout.cs b/Editor/Mono/GUI/WindowLayout.cs index 65b32e0227..e7a4c39495 100644 --- a/Editor/Mono/GUI/WindowLayout.cs +++ b/Editor/Mono/GUI/WindowLayout.cs @@ -340,17 +340,17 @@ internal static void MaximizeGestureHandler() MaximizeKeyHandler(args); } - [Shortcut("Window/Maximize View", null, "# ")] + [Shortcut("Window/Maximize View", typeof(EditorWindow), "# ")] [FormerlyPrefKeyAs("Window/Maximize View", "# ")] internal static void MaximizeKeyHandler(ShortcutArguments args) { if (args.context == null || args.context is PreviewWindow) return; - if (IsMaximized(args.context)) - Unmaximize(args.context); + if (IsMaximized(args.context as EditorWindow)) + Unmaximize(args.context as EditorWindow); else - Maximize(args.context); + Maximize(args.context as EditorWindow); } public static void AddSplitViewAndChildrenRecurse(View splitview, ArrayList list) diff --git a/Editor/Mono/GameView/GameView.cs b/Editor/Mono/GameView/GameView.cs index 427402cd51..86a42f5025 100644 --- a/Editor/Mono/GameView/GameView.cs +++ b/Editor/Mono/GameView/GameView.cs @@ -812,7 +812,7 @@ private void OnGUI() } else if (type != EventType.Layout && type != EventType.Used) { - if (!EditorApplication.isPlaying || EditorApplication.isPaused) + if (Event.current.isKey && (!EditorApplication.isPlaying || EditorApplication.isPaused)) return; bool mousePosInGameViewRect = viewInWindow.Contains(Event.current.mousePosition); diff --git a/Editor/Mono/LookDevView/CameraControllerStandard.cs b/Editor/Mono/LookDevView/CameraControllerStandard.cs index 2353a94e22..f0ed1eadf4 100644 --- a/Editor/Mono/LookDevView/CameraControllerStandard.cs +++ b/Editor/Mono/LookDevView/CameraControllerStandard.cs @@ -5,6 +5,7 @@ using System; using UnityEngine; using System.Collections.Generic; +using UnityEditor.ShortcutManagement; using UnityEditorInternal; namespace UnityEditor @@ -190,7 +191,6 @@ public override void Update(CameraState cameraState, Camera cam, EditorWindow wi window.Focus(); } - m_CameraFlyModeContext.active = m_CurrentViewTool == ViewTool.FPS; var id = GUIUtility.GetControlID(FocusType.Passive); using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(m_CameraFlyModeContext, id)) { @@ -217,9 +217,14 @@ public override void Update(CameraState cameraState, Camera cam, EditorWindow wi } } + public void ActivateFlyModeContext() + { + ShortcutIntegration.instance.contextManager.SetPriorityContext(m_CameraFlyModeContext); + } + public void DeactivateFlyModeContext() { - m_CameraFlyModeContext.active = false; + ShortcutIntegration.instance.contextManager.ClearPriorityContext(); } } } diff --git a/Editor/Mono/LookDevView/LookDevView.cs b/Editor/Mono/LookDevView/LookDevView.cs index 1f00d47a21..5119791451 100644 --- a/Editor/Mono/LookDevView/LookDevView.cs +++ b/Editor/Mono/LookDevView/LookDevView.cs @@ -279,6 +279,8 @@ private void Initialize() { m_LookDevEnvWindow = new LookDevEnvironmentWindow(this); } + + m_CameraController.ActivateFlyModeContext(); } void InitializePreviewUtilities() diff --git a/Editor/Mono/ParticleSystemEditor/ParticleSystemEditor.cs b/Editor/Mono/ParticleSystemEditor/ParticleSystemEditor.cs index 191cf36269..7a23866812 100644 --- a/Editor/Mono/ParticleSystemEditor/ParticleSystemEditor.cs +++ b/Editor/Mono/ParticleSystemEditor/ParticleSystemEditor.cs @@ -20,7 +20,7 @@ internal class ParticleSystemInspector : Editor, ParticleEffectUIOwner GUIContent hideWindowText = EditorGUIUtility.TrTextContent("Hide Editor"); static GUIContent m_PlayBackTitle; - public class ShortcutContext : IShortcutPriorityContext + public class ShortcutContext : IShortcutToolContext { public bool active { get; set; } } @@ -64,7 +64,7 @@ public void OnEnable() SceneView.onSceneGUIDelegate += OnSceneViewGUI; Undo.undoRedoPerformed += UndoRedoPerformed; - ShortcutController.priorityContext = m_ShortcutContext; + ShortcutIntegration.instance.contextManager.RegisterToolContext(m_ShortcutContext); } public void OnDisable() @@ -77,7 +77,7 @@ public void OnDisable() if (m_ParticleEffectUI != null) m_ParticleEffectUI.Clear(); - m_ShortcutContext.active = false; + ShortcutIntegration.instance.contextManager.DeregisterToolContext(m_ShortcutContext); } private void HierarchyOrProjectWindowWasChanged() diff --git a/Editor/Mono/SceneModeWindows/LightingWindowLightmapPreviewTab.cs b/Editor/Mono/SceneModeWindows/LightingWindowLightmapPreviewTab.cs index 8cf9d84e76..d02366faee 100644 --- a/Editor/Mono/SceneModeWindows/LightingWindowLightmapPreviewTab.cs +++ b/Editor/Mono/SceneModeWindows/LightingWindowLightmapPreviewTab.cs @@ -429,11 +429,8 @@ void MemoryCentricView(LightmapData[] lightmaps, bool showDirLightmap, bool show } { - string[] objectNames; - float[] sizes; - System.UInt64[] triCounts; - Lightmapping.GetGeometryMemory(out objectNames, out sizes, out triCounts); - ShowObjectNamesSizesAndCounts("Geometry data", kEditorPrefsGeometryData, objectNames, sizes, triCounts, Precision.Hundredths); + GeoMemLabels labels = Lightmapping.GetGeometryMemory(); + ShowObjectNamesSizesAndCounts("Geometry data", kEditorPrefsGeometryData, labels.labels, labels.sizes, labels.triCounts, Precision.Hundredths); } { diff --git a/Editor/Mono/SceneView/CameraFlyModeContext.cs b/Editor/Mono/SceneView/CameraFlyModeContext.cs index 64373836fb..cc1b93075c 100644 --- a/Editor/Mono/SceneView/CameraFlyModeContext.cs +++ b/Editor/Mono/SceneView/CameraFlyModeContext.cs @@ -9,7 +9,8 @@ namespace UnityEditor { - class CameraFlyModeContext : IShortcutPriorityContext + [ReserveModifiers(ShortcutModifiers.Shift)] + class CameraFlyModeContext : IShortcutToolContext { public struct InputSamplingScope : IDisposable { @@ -35,8 +36,6 @@ public InputSamplingScope(CameraFlyModeContext context, int controlID, bool orth if (!context.active) m_ArrowKeysActive = DoArrowKeys(controlID, orthographic); - else - ShortcutController.priorityContext = context; if (currentlyMoving && Mathf.Approximately(m_Context.m_PreviousVector.sqrMagnitude, 0f)) s_Timer.Begin(); @@ -94,7 +93,7 @@ bool DoArrowKeys(int id, bool orthographic) } } - public bool active { get; set; } + public bool active => Tools.viewTool == ViewTool.FPS; Vector3 m_PreviousVector; diff --git a/Editor/Mono/SceneView/SceneView.cs b/Editor/Mono/SceneView/SceneView.cs index 9cc74db960..0d8ed6bbbd 100644 --- a/Editor/Mono/SceneView/SceneView.cs +++ b/Editor/Mono/SceneView/SceneView.cs @@ -532,6 +532,8 @@ override public void OnEnable() if (m_CameraMode.drawMode == DrawCameraMode.UserDefined && !s_UserDefinedModes.Contains(m_CameraMode)) AddCameraMode(m_CameraMode.name, m_CameraMode.section); + SceneViewMotion.ActivateFlyModeContext(); + base.OnEnable(); } diff --git a/Editor/Mono/SceneView/SceneViewMotion.cs b/Editor/Mono/SceneView/SceneViewMotion.cs index 930ee6e024..d441b4e234 100644 --- a/Editor/Mono/SceneView/SceneViewMotion.cs +++ b/Editor/Mono/SceneView/SceneViewMotion.cs @@ -3,12 +3,13 @@ // https://unity3d.com/legal/licenses/Unity_Reference_Only_License using UnityEditor.AnimatedValues; +using UnityEditor.ShortcutManagement; using UnityEngine; using UnityEngine.Profiling; namespace UnityEditor { - internal class SceneViewMotion + internal static class SceneViewMotion { static Vector3 s_Motion; static float s_FlySpeed = 0; @@ -43,7 +44,6 @@ public static void DoViewTool(SceneView view) view.FixNegativeSize(); } - s_CameraFlyModeContext.active = Tools.viewTool == ViewTool.FPS; using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(s_CameraFlyModeContext, id, view.orthographic)) { if (inputSamplingScope.currentlyMoving) @@ -382,9 +382,14 @@ public static void ResetMotion() s_Motion = Vector3.zero; } + public static void ActivateFlyModeContext() + { + ShortcutIntegration.instance.contextManager.SetPriorityContext(s_CameraFlyModeContext); + } + public static void DeactivateFlyModeContext() { - s_CameraFlyModeContext.active = false; + ShortcutIntegration.instance.contextManager.ClearPriorityContext(); } } diff --git a/Editor/Mono/Scripting/Compilers/BooCompiler.cs b/Editor/Mono/Scripting/Compilers/BooCompiler.cs index 2db899a741..0fc857b46d 100644 --- a/Editor/Mono/Scripting/Compilers/BooCompiler.cs +++ b/Editor/Mono/Scripting/Compilers/BooCompiler.cs @@ -11,6 +11,8 @@ namespace UnityEditor.Scripting.Compilers { class BooCompiler : MonoScriptCompilerBase { + const string k_UnityScriptProfileDirectory = "unityscript"; + public BooCompiler(MonoIsland island, bool runUpdater) : base(island, runUpdater) { } @@ -32,13 +34,29 @@ override protected Program StartCompiler() foreach (string source in _island._files) arguments.Add(PrepareFileName(source)); - string compilerPath = Path.Combine(GetMonoProfileLibDirectory(), "booc.exe"); - return StartCompiler(_island._target, compilerPath, arguments); + string compilerPath = Path.Combine(GetBooCompilerDirectory(), "booc.exe"); + return StartCompiler(_island._target, compilerPath, arguments, GetBooProfileDirectory()); } protected override CompilerOutputParserBase CreateOutputParser() { return new BooCompilerOutputParser(); } + + string GetBooCompilerDirectory() + { + if (PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy) + return GetMonoProfileLibDirectory(); + + return Path.Combine(MonoInstallationFinder.GetProfilesDirectory(MonoInstallationFinder.MonoBleedingEdgeInstallation), k_UnityScriptProfileDirectory); + } + + string GetBooProfileDirectory() + { + if (PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy) + return BuildPipeline.CompatibilityProfileToClassLibFolder(_island._api_compatibility_level); + + return k_UnityScriptProfileDirectory; + } } } diff --git a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs index a63ff7335d..0ff8a66593 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; +using System.Text.RegularExpressions; using UnityEditor.Modules; using UnityEditor.Compilation; using UnityEditor.Scripting.Compilers; @@ -65,6 +66,82 @@ public enum CompilationSetupErrorFlags loadError = (1 << 0) } + abstract class UnitySpecificCompilerMessageProcessor + { + public abstract bool IsInterestedInMessage(CompilerMessage m); + public abstract void PostprocessMessage(ref CompilerMessage m); + } + + class UnsafeErrorProcessor : UnitySpecificCompilerMessageProcessor + { + string unityUnsafeMessage; + + public UnsafeErrorProcessor(ScriptAssembly assembly, EditorCompilation editorCompilation) + { + var assemblyName = AssetPath.GetAssemblyNameWithoutExtension(assembly.Filename); + + try + { + var customScriptAssembly = editorCompilation.FindCustomScriptAssemblyFromAssemblyName(assemblyName); + unityUnsafeMessage = string.Format("Enable \"Allow 'unsafe' code\" in the inspector for '{0}' to fix this error.", customScriptAssembly.FilePath); + } + catch + { + unityUnsafeMessage = "Enable \"Allow 'unsafe' code\" in Player Settings to fix this error."; + } + } + + public override bool IsInterestedInMessage(CompilerMessage m) + { + return m.type == CompilerMessageType.Error && m.message.Contains("CS0227"); + } + + public override void PostprocessMessage(ref CompilerMessage m) + { + m.message += ". " + unityUnsafeMessage; + } + } + + class ModuleReferenceErrorProcessor : UnitySpecificCompilerMessageProcessor + { + Regex messageRegex; + + public ModuleReferenceErrorProcessor() + { + messageRegex = new Regex("`UnityEngine.(\\w*)Module,"); + } + + public override bool IsInterestedInMessage(CompilerMessage m) + { + return m.type == CompilerMessageType.Error && (m.message.Contains("CS1069") || m.message.Contains("CS1070")); + } + + private static string GetNiceDisplayNameForModule(string name) + { + for (int i = 1; i < name.Length; i++) + if (char.IsLower(name[i - 1]) && !char.IsLower(name[i])) + { + name = name.Insert(i, " "); + i++; + } + return name; + } + + public override void PostprocessMessage(ref CompilerMessage message) + { + var match = messageRegex.Match(message.message); + if (match.Success) + { + var index = message.message.IndexOf("Consider adding a reference to assembly"); + if (index != -1) + message.message = message.message.Substring(0, index); + var moduleName = GetNiceDisplayNameForModule(match.Groups[1].Value); + + message.message += string.Format("Enable the built in package '{0}' in the Package Manager window to fix this error.", moduleName); + } + } + } + bool areAllScriptsDirty; string projectDirectory = string.Empty; string assemblySuffix = string.Empty; @@ -817,38 +894,26 @@ internal bool CompileScriptAssemblies(ScriptAssembly[] scriptAssemblies, ScriptA void AddUnitySpecificErrorMessages(ScriptAssembly assembly, List messages) { - // error CS0227: Unsafe code requires the `unsafe' command line option to be specified - if (!messages.Any(m => m.type == CompilerMessageType.Error && m.message.Contains("CS0227"))) - return; - - var assemblyName = AssetPath.GetAssemblyNameWithoutExtension(assembly.Filename); - - string unityUnsafeMessage; - - try - { - var customScriptAssembly = FindCustomScriptAssemblyFromAssemblyName(assemblyName); - unityUnsafeMessage = string.Format("Enable \"Allow 'unsafe' code\" in the inspector for '{0}' to fix this error.", customScriptAssembly.FilePath); - } - catch + var processors = new List() { - unityUnsafeMessage = "Enable \"Allow 'unsafe' code\" in Player Settings to fix this error."; - } + new UnsafeErrorProcessor(assembly, this), + new ModuleReferenceErrorProcessor() + }; + + if (!messages.Any(m => processors.Any(p => p.IsInterestedInMessage(m)))) + return; List newMessages = new List(); foreach (var message in messages) { - if (message.type == CompilerMessageType.Error && message.message.Contains("CS0227")) - { - var newMessage = new CompilerMessage(message); - newMessage.message += ". " + unityUnsafeMessage; - newMessages.Add(newMessage); - } - else + var newMessage = new CompilerMessage(message); + foreach (var processor in processors) { - newMessages.Add(message); + if (processor.IsInterestedInMessage(message)) + processor.PostprocessMessage(ref newMessage); } + newMessages.Add(newMessage); } messages.Clear(); diff --git a/Editor/Src/VR/Mono/GoogleVR/VRCustomOptionsGoogleVR.cs b/Editor/Src/VR/Mono/GoogleVR/VRCustomOptionsGoogleVR.cs index 37d8e993cf..9f52de4a7e 100644 --- a/Editor/Src/VR/Mono/GoogleVR/VRCustomOptionsGoogleVR.cs +++ b/Editor/Src/VR/Mono/GoogleVR/VRCustomOptionsGoogleVR.cs @@ -28,7 +28,7 @@ public override void Initialize(SerializedObject settings, string propertyName) m_DepthFormat = FindPropertyAssert("depthFormat"); } - public override Rect Draw(Rect rect) + public override Rect Draw(BuildTargetGroup target, Rect rect) { rect.y += EditorGUIUtility.standardVerticalSpacing; rect.height = EditorGUIUtility.singleLineHeight; @@ -69,9 +69,9 @@ public override void Initialize(SerializedObject settings, string propertyName) m_EnableTransitionView = FindPropertyAssert("enableTransitionView"); } - public override Rect Draw(Rect rect) + public override Rect Draw(BuildTargetGroup target, Rect rect) { - rect = base.Draw(rect); + rect = base.Draw(target, rect); rect.height = EditorGUIUtility.singleLineHeight; GUIContent label = EditorGUI.BeginProperty(rect, s_EnableTransitionViewLabel, m_EnableTransitionView); @@ -202,9 +202,9 @@ private void SetHeadTrackingValue(int headTrackingValue) } } - public override Rect Draw(Rect rect) + public override Rect Draw(BuildTargetGroup target, Rect rect) { - rect = base.Draw(rect); + rect = base.Draw(target, rect); rect = DrawTextureUI(rect, s_ForegroundIconLabel, m_DaydreamIcon); rect = DrawTextureUI(rect, s_BackgroundIconLabel, m_DaydreamIconBackground); diff --git a/Editor/Src/VR/Mono/Oculus/VRCustomOptionsOculus.cs b/Editor/Src/VR/Mono/Oculus/VRCustomOptionsOculus.cs index 5a949a85d7..162bf65800 100644 --- a/Editor/Src/VR/Mono/Oculus/VRCustomOptionsOculus.cs +++ b/Editor/Src/VR/Mono/Oculus/VRCustomOptionsOculus.cs @@ -29,10 +29,12 @@ public override void Initialize(SerializedObject settings, string propertyName) m_DashSupport = FindPropertyAssert("dashSupport"); } - public override Rect Draw(Rect rect) + public override Rect Draw(BuildTargetGroup target, Rect rect) { rect.y += EditorGUIUtility.standardVerticalSpacing; + EditorGUI.BeginDisabled(target == BuildTargetGroup.Android); + rect.height = EditorGUIUtility.singleLineHeight; GUIContent label = EditorGUI.BeginProperty(rect, s_SharedDepthBufferLabel, m_SharedDepthBuffer); EditorGUI.BeginChangeCheck(); @@ -53,6 +55,9 @@ public override Rect Draw(Rect rect) m_DashSupport.boolValue = boolValue; } EditorGUI.EndProperty(); + + EditorGUI.EndDisabled(); + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; return rect; diff --git a/Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs b/Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs index f9636a1665..3c24531eed 100644 --- a/Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs +++ b/Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs @@ -447,7 +447,7 @@ private void DrawVRDeviceElement(BuildTargetGroup target, Rect rect, int index, if (customOptions != null && customOptions.IsExpanded) { - customOptions.Draw(rect); + customOptions.Draw(target, rect); } } diff --git a/Editor/Src/VR/Mono/VRCustomOptions.cs b/Editor/Src/VR/Mono/VRCustomOptions.cs index 1410549b7b..4f2987cfd7 100644 --- a/Editor/Src/VR/Mono/VRCustomOptions.cs +++ b/Editor/Src/VR/Mono/VRCustomOptions.cs @@ -64,13 +64,13 @@ public virtual void Initialize(SerializedObject settings, string propertyName) } } - abstract public Rect Draw(Rect rect); + abstract public Rect Draw(BuildTargetGroup target, Rect rect); abstract public float GetHeight(); } internal class VRCustomOptionsNone : VRCustomOptions { - public override Rect Draw(Rect rect) { return rect; } + public override Rect Draw(BuildTargetGroup target, Rect rect) { return rect; } public override float GetHeight() { return 0.0f; } } } diff --git a/Editor/Src/VR/Mono/WindowsHolographic/VRCustomOptionsWindowsHolographic.cs b/Editor/Src/VR/Mono/WindowsHolographic/VRCustomOptionsWindowsHolographic.cs index e5859c2977..23cacc5175 100644 --- a/Editor/Src/VR/Mono/WindowsHolographic/VRCustomOptionsWindowsHolographic.cs +++ b/Editor/Src/VR/Mono/WindowsHolographic/VRCustomOptionsWindowsHolographic.cs @@ -31,7 +31,7 @@ public override void Initialize(SerializedObject settings, string propertyName) m_DepthBufferSharingEnabled = FindPropertyAssert("depthBufferSharingEnabled"); } - public override Rect Draw(Rect rect) + public override Rect Draw(BuildTargetGroup target, Rect rect) { rect.y += EditorGUIUtility.standardVerticalSpacing; rect.height = EditorGUIUtility.singleLineHeight; diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.Compiler.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.Compiler.dll index efdeb816785cac190d18d75a65e03b99192abd75..cf322709d7a8ef578f2f420e10ca364cc9b3a058 100644 GIT binary patch delta 216 zcmV;}04M)|h&h0WIgp40*MRJSi-n5;g^L1(ivxv=1ci$Qg^LD-iwA{^2!)FYg^LP> ziwlK|426pgwTljoIe)FW<~hvaXib$Uno{x2V)KZ*vgOEb-*oTW_Nd0eO>-BCjIAhw zA*+90?$PCju-AFv6zz%~Z$=%p)(;>~91I5ds%i_X`T%*^~onR?J;zu{So6cI3RHKYfk5~&{Smq Su7Vi1K|l^>0k;l34)O ziwlK|426pgwTljoIe%b(X59GLFif`t0K|uVBuH?V8`xyvT6xf1XpuJ^TskKV`?a+b z`(1lE;jS>H&spzn2oxo7UnbDdj{jS~e96F|SsO-}yXmHS6_~bI1orc0M#QNOwZ=VR zaMvP$IQf~wfoT&2D Selvr&K|l^>0k;l34)O;;yCaFCP0jWFU+o2Iw`a u@e9v;f4nho1;XDP(E9?5l{wp0k;lJ2J!{ITUk8- diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.dll index 429aa37a6d8d0a69250bbeca0b39dea84e25c8fc..1b728d30ee073eb26fcc1bf8db3a99c8dad623bd 100644 GIT binary patch delta 177 zcmV;i08ama;0J)<2at#Z(tzxNi?xdZ1?7Ks18{)g*(N}^7F~(HC9AWu?F2xQRjbt5 ztLzx5fQ6{@TUuZ@3b+jn8^vDZKQviO| zMLvP2a8?)+QuGFq;w~VFamD^7$G(GFxWzE#ZYPd>wpqD_{pt@z6i_4N+F|-aZX2FG z-_PC2FV|}3ma|8SS4ipioRqC>2@SFR41n~a?S$ggPR{rj1ys37|C|4)ySr;@y&XIR3z_@(4X z*B1>oM8}SnA$^)m*?^P9@tbs^`oM0ZskT7cuElr>=kt$eZtv6a`66!6(fqX_YS7Zw zev=Uz&`7)x^#;~e^m5>ji!Y2pCt!7xae-IT($1Da>=ln(is3}SBymZT!-b_q4^mGf hZV`*R9{jR6A^i5ZYOSLHmHQOyE+w+_kz@&!)dTOR-b delta 179 zcmV;k08IaYpbLPY3y_EdsmZ&6i-n5;wTl9I$bX!Bz7zuXzCx70S8wC@(j5xv`^%7g z^3xOZfUgC(Q*`$wPd|Sx(it(J43DDunls>@MtAf!YB?@G(STv!N)Gw+IOw#=6S>8L@kQuNWW+cTN4|hxooUBaU7P3OsVU^1dbn zQYx#h4Sj4H06{qbc66!24D&`94@f{>F=!5q<==w+?y)@&!(aTWA0P delta 195 zcmV;!06hPIfD(X!5|D@kuF1QBi-n5;wTl9aZUF&@7jFWG7jFZ%7jFcy34i7CnB;8@ z$VHx3mg3C;>|-b_0g%Zf9!B8Y+Gdy{^|dNFoXoapeLM&zPEs$vDV6&C3;)AfqO{Rlx9s&pBnO?r-+0`@Sc zKaJRs73GNNK|_c#b}7p0G}sUGk?UM6ezjQZL$zdxTHF7UgBj3u`#Dx1NS_%lKv{?~{L&47U-A1Qr3e4u%Bs1u}739smFU diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.Linq.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.Linq.dll index c5d43faf35f3c81500f34e51cc567bc415aeee58..2ba343f968f65d77e73bc2bd929a287641f85ed5 100644 GIT binary patch delta 179 zcmV;k08IaYzy^T829SsY-G1zWi?xdZ>6Cw&H1(E>Mvg|jKF7Q?H^m*M@xa4Z6Cv~qSo*hVq;Cc448?NAll{$=pzV&7jj+J zoXm0gJvyGbi`sm-lxShS59Z$JN$ZiQ*7QC?%TEfs{G#ySzT81*>>FG;?Pb5H3gXfl zOnMmWI;?z#9p-LU?&gkNW0zok7T6SM=X+mjHVt2JosC%wl!FAN6(VztMTKGETK0qa8S>rvaP+0+BEZw+@&A@(1qSRGR<* diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.dll index daf68ba4ceb97c2ea3fd469f5b084fcb0f8a33ce..192e55160dd71dd27993a56abff638657cd54972 100644 GIT binary patch delta 230 zcmV ziwlK|426pgg^Lb_iw}j15QU2og^LokixU}If7-D3NHxRCLWhoozk~|Bq=)YUrUB~j zE9KwJu3Ti{gSkA+)OM5V2TNW;i1}vJp)4#TvZ?jCqc}c~s+qdjENpl>Xnz&cY<)E= zDywn0c!(@qQhBbtZ?SXX@~e4CzLmmMI3!XV7r2`}Mqc9>(*UiCL=wK4I$s5?YYd1m g5p;&*VsDbWf0V-Qj#Eaje3+LJU=!N64qOxR1@Jd%y8r+H delta 230 zcmV ziwlK|426pgg^Lb_iw}j15QU2og^LokixU}Ie@o^Ug<6=7O`!boBmnU9Uk*$z8R}?R zbh5^z6eWq|^A=RLa0P%9fvA3ncDg2bR6I{%+7ZhfH0IOAEhF g5z=-!?G?cAt)?B|A4Z{vAbFP&U=!N64qOxR1vp%7^8f$< diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/System.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/System.dll index 8d6192777e23b352b3401bc7f5f31c17261aca9d..d43c8780c423211cdd37c38752eab457db720e98 100644 GIT binary patch delta 246 zcmV ziwlK|426pgg^Lb_iw}j15QU2og^Ln}ixY*56orcwg^L!2ix-897`2NT*_eM{p>{5n z%==559AQu+HIiBV{57Zzbi*<3q+!%9zdbY0TK)O|bsQ4LsVWl^3B%|JEV#7$kklzo z8ym_E(&wct+90E20I5v^spwVuD7KABf{TSZu60B3Aexyb9SRREor}MN!MQ4g>4W=` wRRb;X(69Kb2_1fZau(KonSl|NivOgLVG80C?p=j`SLAv;ks%tl4w@PA1*Ujzs{jB1 delta 246 zcmV ziwlK|426pgg^Lb_iw}j15QU2og^Ln}ixY*56orcwg^L!2ix-897`2NT*_eOh%Y6g= z>mW{mn!2$YRlXaLpyUZx9%4xg)$wkbsB$)*fVo!ClKw1$5T!vm;=)?umsV4SCu|kiaks%tl4w@PA1vOc2M*si- diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/UnityScript.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/UnityScript.dll index 7633e4400117f710b49881744dc65a774147d276..afee693d43a99d0490818e24fdcd3c849ea0e561 100644 GIT binary patch delta 259 zcmZp8!`1MHYeEO}i-tFi-CMgEwXK<$IJfVxX1v8Hq|d~_QmqLjn5y-_q`~$jwv3PL zm^hiHchoS>Va%VdTFV&5Sg^gOmT{UqN1i-0gI|;|<94aJj0KFmIr$-K%nW7u{y?&M z`}BE?h893E1_nl;7y|MA+;$%#3| zD#peZ3@Tt1#>SRF6>woQu<&;CT&7#LEJ6)iIJS$fX1c~E;K0Hr)M&%0z{Duj=m2DG m|GklECZj-fa;$)<*%GHEvL8>kgqlp9+{hHWopB4(e?|ZrolHXj delta 259 zcmZp8!`1MHYeENe>Y3e*-CMgEwXK;rnYQn+X1v8HWWdD0QmqLjn5y-_r2h6Lwv3PL zn3y=HchoS>VJw)gTFV&5n7_TImT{UqhcF{EgI`ph{C26ij0KFmnfW1V%nW7u{y?%} z`}BE?h893E1_nl;7y|L8|yv9Se% zib_s?a$*jMV+m0KWSPN)x0~lO-Lhrj5Ng=6U34|mH8ueo7B-Y ljZ8Bc1&Vb}<}<#3<21)z^oIQ9fSr>YnPRsyZejY*2mrQ}O!NQ% diff --git a/Modules/Input/Private/Input.cs b/Modules/Input/Private/Input.cs index d002d2bed4..4568696ce0 100644 --- a/Modules/Input/Private/Input.cs +++ b/Modules/Input/Private/Input.cs @@ -50,7 +50,8 @@ public enum NativeInputUpdateType Dynamic = 1 << 0, Fixed = 1 << 1, BeforeRender = 1 << 2, - Editor = 1 << 3 + Editor = 1 << 3, + IgnoreFocus = 1 << 31, } diff --git a/Modules/Input/Private/InputModule.bindings.cs b/Modules/Input/Private/InputModule.bindings.cs index 1d4ac41fab..31b8187696 100644 --- a/Modules/Input/Private/InputModule.bindings.cs +++ b/Modules/Input/Private/InputModule.bindings.cs @@ -15,9 +15,7 @@ namespace UnityEngineInternal.Input [NativeConditional("ENABLE_NEW_INPUT_SYSTEM")] public partial class NativeInputSystem { - public static extern double zeroEventTime { get; } - - public static extern bool hasDeviceDiscoveredCallback { set; } + internal static extern bool hasDeviceDiscoveredCallback { set; } [FreeFunction("AllocateInputDeviceId")] public static extern int AllocateDeviceId(); @@ -34,21 +32,10 @@ public static unsafe void QueueInputEvent(ref TInputEvent inputEven public static extern long IOCTL(int deviceId, int code, IntPtr data, int sizeInBytes); - public static void SetPollingFrequency(float hertz) - { - if (hertz < 1.0f) - throw new ArgumentException("Polling frequency cannot be less than 1Hz"); - SetPollingFrequencyInternal(hertz); - } + public static extern void SetPollingFrequency(float hertz); - private static extern void SetPollingFrequencyInternal(float hertz); - - // The following APIs are not for normal use of the system as they do things - // that are normally done either by platform-specific backends or by the player - // loop. However, they can be used, for example, to drive the system from - // managed code during tests. public static extern void Update(NativeInputUpdateType updateType); - public static extern int ReportNewInputDevice(string descriptor); - public static extern void ReportInputDeviceRemoved(int id); + + public static extern void SetUpdateMask(NativeInputUpdateType mask); } } diff --git a/Modules/ShortcutManagerEditor/ContextManager.cs b/Modules/ShortcutManagerEditor/ContextManager.cs new file mode 100644 index 0000000000..9de42377a8 --- /dev/null +++ b/Modules/ShortcutManagerEditor/ContextManager.cs @@ -0,0 +1,91 @@ +// Unity C# reference source +// Copyright (c) Unity Technologies. For terms of use, see +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace UnityEditor.ShortcutManagement +{ + interface IContextManager + { + bool HasAnyActiveContextOfType(Type type); + object GetContextInstanceOfType(Type type); + IShortcutToolContext priorityContext { get; } + } + + internal class ContextManager : IContextManager + { + internal class GlobalContext{} + public static readonly GlobalContext globalContext = new GlobalContext(); + public static readonly Type globalContextType = typeof(GlobalContext); + + EditorWindow m_FocusedWindow; + + IShortcutToolContext m_PriorityContext; + public IShortcutToolContext priorityContext => m_PriorityContext; + + List m_ToolContexts = new List(); + + public int activeContextCount => 1 + (m_FocusedWindow != null ? 1 : 0) + (m_PriorityContext != null && m_PriorityContext.active ? 1 : 0) + m_ToolContexts.Count(c => c.active); + + public void SetFocusedWindow(EditorWindow window) + { + m_FocusedWindow = window; + } + + public void SetPriorityContext(IShortcutToolContext context) + { + m_PriorityContext = context; + } + + public void ClearPriorityContext() + { + m_PriorityContext = null; + } + + public void RegisterToolContext(IShortcutToolContext context) + { + if (context == null) + return; + if (!m_ToolContexts.Contains(context)) + m_ToolContexts.Add(context); + } + + public void DeregisterToolContext(IShortcutToolContext context) + { + if (context == null) + return; + if (m_ToolContexts.Contains(context)) + m_ToolContexts.Remove(context); + } + + public object GetContextInstanceOfType(Type type) + { + if (type == globalContextType) + return globalContext; + if (type.IsInstanceOfType(m_FocusedWindow)) + return m_FocusedWindow; + if (m_PriorityContext != null && m_PriorityContext.active && type.IsInstanceOfType(m_PriorityContext)) + return m_PriorityContext; + for (int i = 0; i < m_ToolContexts.Count; i++) + { + if (m_ToolContexts[i].active && m_ToolContexts[i].GetType() == type) + return m_ToolContexts[i]; + } + return m_ToolContexts.FirstOrDefault(c => c.active && type.IsInstanceOfType(c)); + } + + public bool HasAnyActiveContextOfType(Type type) + { + if (type.IsInstanceOfType(globalContext)) + return true; + if (type.IsInstanceOfType(m_FocusedWindow)) + return true; + if (priorityContext != null && priorityContext.active && type.IsInstanceOfType(priorityContext)) + return true; + return m_ToolContexts.Any(c => c.active && type.IsInstanceOfType(c)); + } + } +} diff --git a/Modules/ShortcutManagerEditor/Directory.cs b/Modules/ShortcutManagerEditor/Directory.cs index 022aa8fed1..98a997768b 100644 --- a/Modules/ShortcutManagerEditor/Directory.cs +++ b/Modules/ShortcutManagerEditor/Directory.cs @@ -38,9 +38,38 @@ public void FindShortcutEntries(List combinationSequence, Type[] } } + public void FindShortcutEntries(List combinationSequence, IContextManager contextManager, List outputShortcuts) + { + outputShortcuts.Clear(); + + Assert.IsNotNull(combinationSequence); + Assert.IsTrue(combinationSequence.Count > 0, "Sequence can not be empty"); + + foreach (var shortcutEntry in m_ShortcutEntries) + { + if (shortcutEntry.StartsWith(combinationSequence)) + { + if (contextManager != null && !contextManager.HasAnyActiveContextOfType(shortcutEntry.context)) + continue; + outputShortcuts.Add(shortcutEntry); + } + } + } + public void FindShortcutEntries(List combinationSequence, List outputShortcuts) { - FindShortcutEntries(combinationSequence, null, outputShortcuts); + outputShortcuts.Clear(); + + Assert.IsNotNull(combinationSequence); + Assert.IsTrue(combinationSequence.Count > 0, "Sequence can not be empty"); + + foreach (var shortcutEntry in m_ShortcutEntries) + { + if (shortcutEntry.StartsWith(combinationSequence)) + { + outputShortcuts.Add(shortcutEntry); + } + } } public ShortcutEntry FindShortcutEntry(Identifier identifier) diff --git a/Modules/ShortcutManagerEditor/IDirectory.cs b/Modules/ShortcutManagerEditor/IDirectory.cs index ba40634063..d0e4c9e52f 100644 --- a/Modules/ShortcutManagerEditor/IDirectory.cs +++ b/Modules/ShortcutManagerEditor/IDirectory.cs @@ -10,6 +10,7 @@ namespace UnityEditor.ShortcutManagement interface IDirectory { void FindShortcutEntries(List combinationSequence, Type[] context, List outputShortcuts); + void FindShortcutEntries(List combinationSequence, IContextManager contextManager, List outputShortcuts); void FindShortcutEntries(List combinationSequence, List outputShortcuts); ShortcutEntry FindShortcutEntry(Identifier identifier); ShortcutEntry FindShortcutEntry(string identifier); diff --git a/Modules/ShortcutManagerEditor/IShortcutPriorityContext.cs b/Modules/ShortcutManagerEditor/IShortcutPriorityContext.cs index 66461bc31f..bbb2183223 100644 --- a/Modules/ShortcutManagerEditor/IShortcutPriorityContext.cs +++ b/Modules/ShortcutManagerEditor/IShortcutPriorityContext.cs @@ -4,7 +4,7 @@ namespace UnityEditor.ShortcutManagement { - internal interface IShortcutPriorityContext + internal interface IShortcutToolContext { bool active { get; } } diff --git a/Modules/ShortcutManagerEditor/ReserveModifiersAttribute.cs b/Modules/ShortcutManagerEditor/ReserveModifiersAttribute.cs new file mode 100644 index 0000000000..6e392fbb82 --- /dev/null +++ b/Modules/ShortcutManagerEditor/ReserveModifiersAttribute.cs @@ -0,0 +1,19 @@ +// Unity C# reference source +// Copyright (c) Unity Technologies. For terms of use, see +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License + +using System; + +namespace UnityEditor.ShortcutManagement +{ + [AttributeUsage(AttributeTargets.Class)] + class ReserveModifiersAttribute : Attribute + { + public ShortcutModifiers modifier { get; } + + public ReserveModifiersAttribute(ShortcutModifiers modifier) + { + this.modifier = modifier; + } + } +} diff --git a/Modules/ShortcutManagerEditor/ShortcutController.cs b/Modules/ShortcutManagerEditor/ShortcutController.cs index 66d822ffcc..a26a45b47f 100644 --- a/Modules/ShortcutManagerEditor/ShortcutController.cs +++ b/Modules/ShortcutManagerEditor/ShortcutController.cs @@ -3,6 +3,7 @@ // https://unity3d.com/legal/licenses/Unity_Reference_Only_License using UnityEngine; +using UnityObject = UnityEngine.Object; namespace UnityEditor.ShortcutManagement { @@ -20,7 +21,8 @@ static ShortcutIntegration() static void EventHandler() { - instance.HandleKeyEventForContext(Event.current, EditorWindow.focusedWindow); + instance.contextManager.SetFocusedWindow(EditorWindow.focusedWindow); + instance.HandleKeyEvent(Event.current); } } @@ -31,11 +33,7 @@ class ShortcutController public IShortcutProfileManager profileManager { get; } public IDirectory directory { get; private set; } - public static IShortcutPriorityContext priorityContext - { - get { return ShortcutIntegration.instance.m_Trigger.priorityContext; } - set { ShortcutIntegration.instance.m_Trigger.priorityContext = value; } - } + public ContextManager contextManager = new ContextManager(); public ShortcutController(IDiscovery discovery) { @@ -50,9 +48,39 @@ internal void Initialize(IShortcutProfileManager sender) m_Trigger = new Trigger(directory, new ConflictResolver()); } - internal void HandleKeyEventForContext(Event evt, object context) + internal void HandleKeyEvent(Event evt) + { + if (contextManager.priorityContext != null && contextManager.priorityContext.active) + { + // For now the ReserveModifiersAttribute only works with priority context. + // Making it working with any contex will require changing how Directory works + var contextType = contextManager.priorityContext.GetType(); + var attributes = contextType.GetCustomAttributes(typeof(ReserveModifiersAttribute), true); + + foreach (var attribue in attributes) + { + var modifier = (attribue as ReserveModifiersAttribute).modifier; + if ((modifier & ShortcutModifiers.Shift) == ShortcutModifiers.Shift) + { + evt.shift = false; + } + if ((modifier & ShortcutModifiers.Alt) == ShortcutModifiers.Alt) + { + evt.alt = false; + } + if ((modifier & ShortcutModifiers.ControlOrCommand) == ShortcutModifiers.ControlOrCommand) + { + evt.control = evt.command = false; + } + } + } + + HandleInTrigger(evt, contextManager); + } + + internal virtual void HandleInTrigger(Event evt, IContextManager contextManager) { - m_Trigger.HandleKeyEventForContext(evt, context); + m_Trigger.HandleKeyEvent(evt, contextManager); } } } diff --git a/Modules/ShortcutManagerEditor/ShortcutEntry.cs b/Modules/ShortcutManagerEditor/ShortcutEntry.cs index 37189722bb..10d76d42c0 100644 --- a/Modules/ShortcutManagerEditor/ShortcutEntry.cs +++ b/Modules/ShortcutManagerEditor/ShortcutEntry.cs @@ -20,7 +20,7 @@ enum ShortcutState struct ShortcutArguments { - public EditorWindow context; + public object context; public ShortcutState state; } @@ -75,7 +75,7 @@ internal ShortcutEntry(Identifier id, List defaultCombination, A { m_Identifier = id; m_DefaultCombinations = new List(defaultCombination); - m_Context = context; + m_Context = context ?? ContextManager.globalContextType; m_Action = action; m_Type = type; this.prefKeyMigratedValue = prefKeyMigratedValue; diff --git a/Modules/ShortcutManagerEditor/Trigger.cs b/Modules/ShortcutManagerEditor/Trigger.cs index 58899294bc..0db7cd7e9a 100644 --- a/Modules/ShortcutManagerEditor/Trigger.cs +++ b/Modules/ShortcutManagerEditor/Trigger.cs @@ -2,11 +2,9 @@ // Copyright (c) Unity Technologies. For terms of use, see // https://unity3d.com/legal/licenses/Unity_Reference_Only_License -using System; using System.Collections.Generic; using System.Linq; using UnityEngine; -using UnityObject = UnityEngine.Object; namespace UnityEditor.ShortcutManagement { @@ -19,39 +17,6 @@ class Trigger List m_Entries = new List(); Dictionary m_ActiveClutches = new Dictionary(); HashSet m_KeysDown = new HashSet(); - static Type[] s_Context = { null, null }; - - public IShortcutPriorityContext priorityContext - { - get - { - while (m_PriorityContexts.Count > 0) - { - var ctx = m_PriorityContexts.Peek(); - if ( - ctx == null - || !ctx.active - || typeof(UnityObject).IsAssignableFrom(ctx.GetType()) && (UnityObject)ctx == null - ) - { - // remove an inactive priority context in case e.g., user forgot to clear it when done - // this pattern was chosen to make it more explicit to priority context implementer how to indicate completion - m_PriorityContexts.Pop(); - } - else - { - return ctx; - } - } - return null; - } - set - { - if (!m_PriorityContexts.Contains(value)) - m_PriorityContexts.Push(value); - } - } - readonly Stack m_PriorityContexts = new Stack(); public Trigger(IDirectory directory, IConflictResolver conflictResolver) { @@ -59,7 +24,7 @@ public Trigger(IDirectory directory, IConflictResolver conflictResolver) m_ConflictResolver = conflictResolver; } - public void HandleKeyEventForContext(Event evt, object context) + public void HandleKeyEvent(Event evt, IContextManager contextManager) { if (evt == null || !evt.isKey || evt.keyCode == KeyCode.None) return; @@ -73,12 +38,11 @@ public void HandleKeyEventForContext(Event evt, object context) m_ActiveClutches.Remove(evt.keyCode); var args = new ShortcutArguments { - context = context as EditorWindow, + context = contextManager.GetContextInstanceOfType(shortcutEntry.context), state = ShortcutState.End, }; shortcutEntry.action(args); } - return; } @@ -92,10 +56,21 @@ public void HandleKeyEventForContext(Event evt, object context) var keyCodeCombination = new KeyCombination(evt); m_KeyCombinationSequence.Add(keyCodeCombination); - s_Context[1] = priorityContext?.GetType() ?? context?.GetType(); - m_Directory.FindShortcutEntries(m_KeyCombinationSequence, s_Context, m_Entries); - if (priorityContext != null && m_Entries.Count(entry => entry.context == null) < m_Entries.Count) - m_Entries.RemoveAll(entry => entry.context == null); + // Ignore event if sequence is empty + if (m_KeyCombinationSequence.Count == 0) + return; + + m_Directory.FindShortcutEntries(m_KeyCombinationSequence, contextManager, m_Entries); + + if (m_Entries.Count > 1 && contextManager.priorityContext != null) + { + var entry = m_Entries.FirstOrDefault(a => a.context == contextManager.priorityContext.GetType()); + if (entry != null) + { + m_Entries.Clear(); + m_Entries.Add(entry); + } + } switch (m_Entries.Count) { @@ -111,7 +86,7 @@ public void HandleKeyEventForContext(Event evt, object context) break; var args = new ShortcutArguments(); - args.context = context as EditorWindow; + args.context = contextManager.GetContextInstanceOfType(shortcutEntry.context); switch (shortcutEntry.type) { case ShortcutType.Action: diff --git a/Modules/TilemapEditor/Editor/Managed/Grid/GridPaintPaletteWindow.cs b/Modules/TilemapEditor/Editor/Managed/Grid/GridPaintPaletteWindow.cs index 84ac635fdd..7c45787a18 100644 --- a/Modules/TilemapEditor/Editor/Managed/Grid/GridPaintPaletteWindow.cs +++ b/Modules/TilemapEditor/Editor/Managed/Grid/GridPaintPaletteWindow.cs @@ -138,7 +138,7 @@ static void ToggleEditMode(EditMode.SceneViewEditMode mode) EditMode.QuitEditMode(); } - class ShortcutContext : IShortcutPriorityContext + class ShortcutContext : IShortcutToolContext { public bool active { get; set; } } @@ -626,7 +626,7 @@ public void OnEnable() Tools.onToolChanged += ToolChanged; - ShortcutController.priorityContext = m_ShortcutContext; + ShortcutIntegration.instance.contextManager.RegisterToolContext(m_ShortcutContext); } private void PrefabInstanceUpdated(GameObject updatedPrefab) @@ -687,7 +687,7 @@ public void OnDisable() GridPaintingState.UnregisterPainterInterest(this); PrefabUtility.prefabInstanceUpdated -= PrefabInstanceUpdated; - m_ShortcutContext.active = false; + ShortcutIntegration.instance.contextManager.DeregisterToolContext(m_ShortcutContext); } private void OnScenePaintTargetChanged(GameObject scenePaintTarget) diff --git a/Modules/UIElements/IMGUIContainer.cs b/Modules/UIElements/IMGUIContainer.cs index 855b153c2b..8dbafa23f7 100644 --- a/Modules/UIElements/IMGUIContainer.cs +++ b/Modules/UIElements/IMGUIContainer.cs @@ -61,7 +61,6 @@ private GUILayoutUtility.LayoutCache cache } public ContextType contextType { get; set; } - internal int GUIDepth { get; private set; } bool lostFocus = false; bool receivedFocus = false; @@ -200,8 +199,6 @@ private void DoOnGUI(Event evt, bool isComputingLayout = false) // We intentionally don't send the NewKeuboardFocus command here since it creates an issue with the AutomatedWindow // newKeyboardFocusControlID = GUIUtility.keyboardControl; } - - GUIDepth = GUIUtility.guiDepth; EventType originalEventType = Event.current.type; bool isExitGUIException = false; diff --git a/Modules/UIElements/UIElementsUtility.cs b/Modules/UIElements/UIElementsUtility.cs index 513e63a0c6..dcc7d0d95b 100644 --- a/Modules/UIElements/UIElementsUtility.cs +++ b/Modules/UIElements/UIElementsUtility.cs @@ -51,9 +51,6 @@ private static void TakeCapture() { var topmostContainer = s_ContainerStack.Peek(); - if (topmostContainer.GUIDepth != GUIUtility.guiDepth) - return; - if (MouseCaptureController.IsMouseCaptureTaken() && !topmostContainer.HasMouseCapture()) { Debug.Log("Should not grab hot control with an active capture"); diff --git a/Modules/UnityWebRequest/Public/WebRequestUtils.cs b/Modules/UnityWebRequest/Public/WebRequestUtils.cs index 66218a09d6..fd8d754bdd 100644 --- a/Modules/UnityWebRequest/Public/WebRequestUtils.cs +++ b/Modules/UnityWebRequest/Public/WebRequestUtils.cs @@ -556,11 +556,7 @@ internal static string MakeUriString(Uri targetUri, string targetUrl, bool prepe return targetUri.OriginalString; string path = targetUri.AbsolutePath; if (path.Contains("%")) - { - var urlBytes = Encoding.UTF8.GetBytes(path); - var decodedBytes = UnityEngine.WWWTranscoder.URLDecode(urlBytes); - path = Encoding.UTF8.GetString(decodedBytes); - } + path = URLDecode(path); if (path.Length > 0 && path[0] != '/') path = '/' + path; return "file://" + path; @@ -580,12 +576,29 @@ internal static string MakeUriString(Uri targetUri, string targetUrl, bool prepe { StringBuilder sb = new StringBuilder(scheme, targetUrl.Length); sb.Append(':'); - sb.Append(targetUri.PathAndQuery); // for these spec URIs path also has the part of URI to right of colon + // for these spec URIs path also has the part of URI to right of colon + // jar:file URIs should be treated like file URIs (unescaped and stripped of query&fragment) + if (scheme == "jar") + { + string path = targetUri.AbsolutePath; + if (path.Contains("%")) + path = URLDecode(path); + sb.Append(path); + return sb.ToString(); + } + sb.Append(targetUri.PathAndQuery); sb.Append(targetUri.Fragment); return sb.ToString(); } return targetUri.AbsoluteUri; } + + static string URLDecode(string encoded) + { + var urlBytes = Encoding.UTF8.GetBytes(encoded); + var decodedBytes = UnityEngine.WWWTranscoder.URLDecode(urlBytes); + return Encoding.UTF8.GetString(decodedBytes); + } } } diff --git a/Projects/CSharp/UnityEditor.csproj b/Projects/CSharp/UnityEditor.csproj index d62ca45426..f1dc7a8a05 100644 --- a/Projects/CSharp/UnityEditor.csproj +++ b/Projects/CSharp/UnityEditor.csproj @@ -4166,6 +4166,9 @@ Modules\ShortcutManagerEditor\ConflictResolver.cs + + Modules\ShortcutManagerEditor\ContextManager.cs + Modules\ShortcutManagerEditor\Directory.cs @@ -4187,6 +4190,9 @@ Modules\ShortcutManagerEditor\IShortcutPriorityContext.cs + + Modules\ShortcutManagerEditor\ReserveModifiersAttribute.cs + Modules\ShortcutManagerEditor\ShortcutAttribute.cs diff --git a/README.md b/README.md index 518cd40496..be806d8ed2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b3 C# reference source code +## Unity 2018.2.0b4 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Export/ShaderKeyword.bindings.cs b/Runtime/Export/ShaderKeyword.bindings.cs index 757dade5e7..cd47e76058 100644 --- a/Runtime/Export/ShaderKeyword.bindings.cs +++ b/Runtime/Export/ShaderKeyword.bindings.cs @@ -16,30 +16,37 @@ public class ShaderKeyword [NativeMethod("keywords::Find", true)] extern internal static int GetShaderKeywordIndex(string keywordName); - private const int k_MaxShaderKeywords = 256; // Keep in sync with kMaxShaderKeywords in ShaderKeywordSet.h + [NativeMethod("keywords::GetKeywordName", true)] + extern internal static string GetShaderKeywordName(int keywordIndex); + + internal const int k_MaxShaderKeywords = 256; // Keep in sync with kMaxShaderKeywords in ShaderKeywordSet.h private const int k_InvalidKeyword = -1; // Keep in sync with keywords::kInvalidKeyword in ShaderKeywords.h + internal ShaderKeyword(int keywordIndex) + { + m_KeywordIndex = keywordIndex; + } + public ShaderKeyword(string keywordName) { - m_Keyword = keywordName; + m_KeywordIndex = GetShaderKeywordIndex(keywordName); } public bool IsValid() { - var index = GetShaderKeywordIndex(m_Keyword); - return index >= 0 && index < k_MaxShaderKeywords && index != k_InvalidKeyword; + return m_KeywordIndex >= 0 && m_KeywordIndex < k_MaxShaderKeywords && m_KeywordIndex != k_InvalidKeyword; } public string GetName() { - return m_Keyword; + return GetShaderKeywordName(m_KeywordIndex); } internal int GetIndex() { - return GetShaderKeywordIndex(m_Keyword); + return m_KeywordIndex; } - internal string m_Keyword; + internal int m_KeywordIndex; } } diff --git a/Runtime/Export/ShaderKeywordSet.cs b/Runtime/Export/ShaderKeywordSet.cs index ce2f5fc9be..7682738f27 100644 --- a/Runtime/Export/ShaderKeywordSet.cs +++ b/Runtime/Export/ShaderKeywordSet.cs @@ -4,6 +4,7 @@ using UnityEngine.Scripting; using System.Runtime.InteropServices; +using System; namespace UnityEngine.Rendering { @@ -57,6 +58,23 @@ public void Disable(ShaderKeyword keyword) } } + public ShaderKeyword[] GetShaderKeywords() + { + ShaderKeyword[] shaderKeywords = new ShaderKeyword[ShaderKeyword.k_MaxShaderKeywords]; + int keywordCount = 0; + for (int keywordIndex = 0; keywordIndex < ShaderKeyword.k_MaxShaderKeywords; ++keywordIndex) + { + ShaderKeyword keyword = new ShaderKeyword(keywordIndex); + if (IsEnabled(keyword)) + { + shaderKeywords[keywordCount] = keyword; + ++keywordCount; + } + } + Array.Resize(ref shaderKeywords, keywordCount); + return shaderKeywords; + } + const int k_SizeInBits = sizeof(uint) * 8; internal fixed uint m_Bits[8]; } From 4c1ea0fee928b7651e1d2f65cbf9abe276979402 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Thu, 24 May 2018 07:21:44 +0000 Subject: [PATCH 04/13] Unity 2018.2.0b5 C# reference source code --- .../AnimationWindowClipPopup.cs | 222 +++++++++++++----- .../AnimationWindowSelectionItem.cs | 19 ++ Editor/Mono/Animation/TimeArea.cs | 8 +- Editor/Mono/Animation/ZoomableArea.cs | 119 ++++++++-- .../BuildPipeline/MonoAssemblyStripping.cs | 8 +- Editor/Mono/HandleUtility.bindings.cs | 2 + Editor/Mono/HandleUtility.cs | 15 ++ Editor/Mono/Inspector/Editor.cs | 18 +- Editor/Mono/Inspector/GenericInspector.cs | 3 + Editor/Mono/ProjectBrowser.cs | 2 +- Editor/Mono/TerrainEditor/TerrainInspector.cs | 3 +- Modules/Terrain/Public/Terrain.bindings.cs | 2 + Modules/UIElements/ScrollView.cs | 4 +- Modules/UIElements/Slider.cs | 12 +- Modules/UIElements/VisualElement.cs | 9 +- README.md | 2 +- .../HolographicRemoting.cs | 2 +- 17 files changed, 353 insertions(+), 97 deletions(-) diff --git a/Editor/Mono/Animation/AnimationWindow/AnimationWindowClipPopup.cs b/Editor/Mono/Animation/AnimationWindow/AnimationWindowClipPopup.cs index 218dde0f47..5f659e15bb 100644 --- a/Editor/Mono/Animation/AnimationWindow/AnimationWindowClipPopup.cs +++ b/Editor/Mono/Animation/AnimationWindow/AnimationWindowClipPopup.cs @@ -13,34 +13,169 @@ namespace UnityEditor class AnimationWindowClipPopup { [SerializeField] public AnimationWindowState state; - [SerializeField] private int selectedIndex; - public void OnGUI() + static int s_ClipPopupHash = "s_ClipPopupHash".GetHashCode(); + + internal sealed class ClipPopupCallbackInfo { - if (state.selection.canChangeAnimationClip) + // The global shared popup state + public static ClipPopupCallbackInfo instance = null; + + // Name of the command event sent from the popup menu to OnGUI when user has changed selection + private const string kPopupMenuChangedMessage = "ClipPopupMenuChanged"; + + // The control ID of the popup menu that is currently displayed. + // Used to pass selection changes back again... + private readonly int m_ControlID = 0; + + // Which item was selected + private AnimationClip m_SelectedClip = null; + + // Which view should we send it to. + private readonly GUIView m_SourceView; + + public ClipPopupCallbackInfo(int controlID) { - string[] menuContent = GetClipMenuContent(); - EditorGUI.BeginChangeCheck(); - // TODO: Make this more robust - selectedIndex = EditorGUILayout.Popup(ClipToIndex(state.activeAnimationClip), menuContent, EditorStyles.toolbarPopup); - if (EditorGUI.EndChangeCheck()) + m_ControlID = controlID; + m_SourceView = GUIView.current; + } + + public static AnimationClip GetSelectedClipForControl(int controlID, AnimationClip clip) + { + Event evt = Event.current; + if (evt.type == EventType.ExecuteCommand && evt.commandName == kPopupMenuChangedMessage) + { + if (instance == null) + { + Debug.LogError("Popup menu has no instance"); + return clip; + } + if (instance.m_ControlID == controlID) + { + clip = instance.m_SelectedClip; + instance = null; + GUI.changed = true; + evt.Use(); + } + } + return clip; + } + + public static void SetSelectedClip(AnimationClip clip) + { + if (instance == null) + { + Debug.LogError("Popup menu has no instance"); + return; + } + + instance.m_SelectedClip = clip; + } + + public static void SendEvent() + { + if (instance == null) { - if (menuContent[selectedIndex] == AnimationWindowStyles.createNewClip.text) + Debug.LogError("Popup menu has no instance"); + return; + } + + instance.m_SourceView.SendEvent(EditorGUIUtility.CommandEvent(kPopupMenuChangedMessage)); + } + } + + + private void DisplayClipMenu(Rect position, int controlID, AnimationClip clip) + { + AnimationClip[] clips = GetOrderedClipList(); + GUIContent[] menuContent = GetClipMenuContent(clips); + int selected = ClipToIndex(clips, clip); + + // Center popup menu around button widget + if (Application.platform == RuntimePlatform.OSXEditor) + { + position.y = position.y - selected * 16 - 19; + } + + ClipPopupCallbackInfo.instance = new ClipPopupCallbackInfo(controlID); + + EditorUtility.DisplayCustomMenu(position, menuContent, selected, (userData, options, index) => + { + if (index < clips.Length) + { + ClipPopupCallbackInfo.SetSelectedClip(clips[index]); + } + else { AnimationClip newClip = AnimationWindowUtility.CreateNewClip(state.selection.rootGameObject.name); if (newClip) { AnimationWindowUtility.AddClipToAnimationPlayerComponent(state.activeAnimationPlayer, newClip); - state.activeAnimationClip = newClip; + ClipPopupCallbackInfo.SetSelectedClip(newClip); } + } - // Layout has changed, bail out now. - EditorGUIUtility.ExitGUI(); + ClipPopupCallbackInfo.SendEvent(); + }, null); + } + + // (case 1029160) Modified version of EditorGUI.DoPopup to fit large data list query. + private AnimationClip DoClipPopup(AnimationClip clip, GUIStyle style) + { + Rect position = EditorGUILayout.GetControlRect(false, EditorGUI.kSingleLineHeight, style); + int controlID = GUIUtility.GetControlID(s_ClipPopupHash, FocusType.Keyboard, position); + + clip = ClipPopupCallbackInfo.GetSelectedClipForControl(controlID, clip); + + Event evt = Event.current; + switch (evt.type) + { + case EventType.Repaint: + Font originalFont = style.font; + if (originalFont && EditorGUIUtility.GetBoldDefaultFont() && originalFont == EditorStyles.miniFont) + { + style.font = EditorStyles.miniBoldFont; } - else + + GUIContent buttonContent = EditorGUIUtility.TempContent(CurveUtility.GetClipName(clip)); + buttonContent.tooltip = AssetDatabase.GetAssetPath(clip); + + style.Draw(position, buttonContent, controlID, false); + + style.font = originalFont; + break; + case EventType.MouseDown: + if (evt.button == 0 && position.Contains(evt.mousePosition)) { - state.activeAnimationClip = IndexToClip(selectedIndex); + DisplayClipMenu(position, controlID, clip); + GUIUtility.keyboardControl = controlID; + evt.Use(); } + break; + case EventType.KeyDown: + if (evt.MainActionKeyForControl(controlID)) + { + DisplayClipMenu(position, controlID, clip); + evt.Use(); + } + break; + } + + return clip; + } + + public void OnGUI() + { + if (state.selection.canChangeAnimationClip) + { + EditorGUI.BeginChangeCheck(); + var newClip = DoClipPopup(state.activeAnimationClip, EditorStyles.toolbarPopup); + if (EditorGUI.EndChangeCheck()) + { + state.activeAnimationClip = newClip; + + // Layout has changed, bail out now. + EditorGUIUtility.ExitGUI(); } } else if (state.activeAnimationClip != null) @@ -50,18 +185,25 @@ public void OnGUI() } } - private string[] GetClipMenuContent() + private GUIContent[] GetClipMenuContent(AnimationClip[] clips) { - List content = new List(); - content.AddRange(GetClipNames()); + int size = clips.Length; + if (state.selection.canCreateClips) + size += 2; + + GUIContent[] content = new GUIContent[size]; + for (int i = 0; i < clips.Length; i++) + { + content[i] = new GUIContent(CurveUtility.GetClipName(clips[i])); + } - if (state.selection.rootGameObject != null) + if (state.selection.canCreateClips) { - content.Add(""); - content.Add(AnimationWindowStyles.createNewClip.text); + content[content.Length - 2] = GUIContent.none; + content[content.Length - 1] = AnimationWindowStyles.createNewClip; } - return content.ToArray(); + return content; } private AnimationClip[] GetOrderedClipList() @@ -75,44 +217,14 @@ private AnimationClip[] GetOrderedClipList() return clips; } - private string[] GetClipNames() - { - AnimationClip[] clips = GetOrderedClipList(); - string[] clipNames = new string[clips.Length]; - - for (int i = 0; i < clips.Length; i++) - clipNames[i] = CurveUtility.GetClipName(clips[i]); - - return clipNames; - } - - // TODO: Make this more robust - private AnimationClip IndexToClip(int index) + private int ClipToIndex(AnimationClip[] clips, AnimationClip clip) { - if (state.activeRootGameObject != null) + for (int index = 0; index < clips.Length; ++index) { - AnimationClip[] clips = GetOrderedClipList(); - if (index >= 0 && index < clips.Length) - return clips[index]; + if (clips[index] == clip) + return index; } - return null; - } - - // TODO: Make this more robust - private int ClipToIndex(AnimationClip clip) - { - if (state.activeRootGameObject != null) - { - int index = 0; - AnimationClip[] clips = GetOrderedClipList(); - foreach (AnimationClip other in clips) - { - if (clip == other) - return index; - index++; - } - } return 0; } } diff --git a/Editor/Mono/Animation/AnimationWindow/AnimationWindowSelectionItem.cs b/Editor/Mono/Animation/AnimationWindow/AnimationWindowSelectionItem.cs index f104cd5c42..b6e0c657e6 100644 --- a/Editor/Mono/Animation/AnimationWindow/AnimationWindowSelectionItem.cs +++ b/Editor/Mono/Animation/AnimationWindow/AnimationWindowSelectionItem.cs @@ -174,6 +174,25 @@ public virtual bool canAddCurves } } + public virtual bool canCreateClips + { + get + { + Component animationPlayer = this.animationPlayer; + if (animationPlayer == null) + return false; + + Animator animator = animationPlayer as Animator; + if (animator != null) + { + // Need a valid state machine to create clips in the Animator. + return (animator.runtimeAnimatorController != null); + } + + return true; + } + } + public virtual bool canSyncSceneSelection { get { return true; } } public List curves diff --git a/Editor/Mono/Animation/TimeArea.cs b/Editor/Mono/Animation/TimeArea.cs index a5f1522175..37c9bef7c7 100644 --- a/Editor/Mono/Animation/TimeArea.cs +++ b/Editor/Mono/Animation/TimeArea.cs @@ -57,7 +57,11 @@ static void InitStyles() timeAreaStyles = new Styles2(); } - public TimeArea(bool minimalGUI) : base(minimalGUI) + public TimeArea(bool minimalGUI) : this(minimalGUI, true, true) {} + + public TimeArea(bool minimalGUI, bool enableSliderZoom) : this(minimalGUI, enableSliderZoom, enableSliderZoom) {} + + public TimeArea(bool minimalGUI, bool enableSliderZoomHorizontal, bool enableSliderZoomVertical) : base(minimalGUI, enableSliderZoomHorizontal, enableSliderZoomVertical) { float[] modulos = new float[] { @@ -529,7 +533,7 @@ public void DrawTimeOnSlider(float time, Color c, float maxTime, float leftSideP return; if (styles.horizontalScrollbar == null) - styles.InitGUIStyles(false, true); + styles.InitGUIStyles(false, allowSliderZoomHorizontal, allowSliderZoomVertical); var inMin = TimeToPixel(0, rect); // Assume 0 minTime var inMax = TimeToPixel(maxTime, rect); diff --git a/Editor/Mono/Animation/ZoomableArea.cs b/Editor/Mono/Animation/ZoomableArea.cs index b8b4691562..de958cf18b 100644 --- a/Editor/Mono/Animation/ZoomableArea.cs +++ b/Editor/Mono/Animation/ZoomableArea.cs @@ -93,22 +93,38 @@ private void SetAllowExceed(ref float rangeEnd, ref bool allowExceed, float valu public float hScaleMin { get { return m_HScaleMin; } - set { m_HScaleMin = Mathf.Clamp(value, kMinScale, kMaxScale); } + set + { + m_HScaleMin = Mathf.Clamp(value, kMinScale, kMaxScale); + styles.enableSliderZoomHorizontal = allowSliderZoomHorizontal; + } } public float hScaleMax { get { return m_HScaleMax; } - set { m_HScaleMax = Mathf.Clamp(value, kMinScale, kMaxScale); } + set + { + m_HScaleMax = Mathf.Clamp(value, kMinScale, kMaxScale); + styles.enableSliderZoomHorizontal = allowSliderZoomHorizontal; + } } public float vScaleMin { get { return m_VScaleMin; } - set { m_VScaleMin = Mathf.Clamp(value, kMinScale, kMaxScale); } + set + { + m_VScaleMin = Mathf.Clamp(value, kMinScale, kMaxScale); + styles.enableSliderZoomVertical = allowSliderZoomVertical; + } } public float vScaleMax { get { return m_VScaleMax; } - set { m_VScaleMax = Mathf.Clamp(value, kMinScale, kMaxScale); } + set + { + m_VScaleMax = Mathf.Clamp(value, kMinScale, kMaxScale); + styles.enableSliderZoomVertical = allowSliderZoomVertical; + } } @@ -128,7 +144,12 @@ public float vScaleMax [SerializeField] private bool m_EnableMouseInput = true; public bool enableMouseInput { get { return m_EnableMouseInput; } set { m_EnableMouseInput = value; } } - [SerializeField] private bool m_EnableSliderZoom = true; + [SerializeField] private bool m_EnableSliderZoomHorizontal = true; + [SerializeField] private bool m_EnableSliderZoomVertical = true; + + // if the min and max scaling does not allow for actual zooming, there is no point in allowing it + protected bool allowSliderZoomHorizontal { get { return m_EnableSliderZoomHorizontal && m_HScaleMin < m_HScaleMax; } } + protected bool allowSliderZoomVertical { get { return m_EnableSliderZoomVertical && m_VScaleMin < m_VScaleMax; } } public bool m_UniformScale; public bool uniformScale { get { return m_UniformScale; } set { m_UniformScale = value; } } @@ -182,16 +203,56 @@ public YDirection upDirection public class Styles { public GUIStyle horizontalScrollbar; - public GUIStyle horizontalMinMaxScrollbarThumb; + public GUIStyle horizontalMinMaxScrollbarThumb + { + get + { + return GetSliderAxisStyle(enableSliderZoomHorizontal).horizontal; + } + } public GUIStyle horizontalScrollbarLeftButton; public GUIStyle horizontalScrollbarRightButton; public GUIStyle verticalScrollbar; - public GUIStyle verticalMinMaxScrollbarThumb; + public GUIStyle verticalMinMaxScrollbarThumb + { + get + { + return GetSliderAxisStyle(enableSliderZoomVertical).vertical; + } + } public GUIStyle verticalScrollbarUpButton; public GUIStyle verticalScrollbarDownButton; + public bool enableSliderZoomHorizontal; + public bool enableSliderZoomVertical; + public float sliderWidth; public float visualSliderWidth; + + private bool minimalGUI; + + private SliderTypeStyles.SliderAxisStyles GetSliderAxisStyle(bool enableSliderZoom) + { + if (minimalGUI) + return enableSliderZoom ? minimalSliderStyles.minMaxSliders : minimalSliderStyles.scrollbar; + else + return enableSliderZoom ? normalSliderStyles.minMaxSliders : normalSliderStyles.scrollbar; + } + + private static SliderTypeStyles minimalSliderStyles; + private static SliderTypeStyles normalSliderStyles; + + private class SliderTypeStyles + { + public SliderAxisStyles scrollbar; + public SliderAxisStyles minMaxSliders; + public class SliderAxisStyles + { + public GUIStyle horizontal; + public GUIStyle vertical; + } + } + public Styles(bool minimalGUI) { if (minimalGUI) @@ -208,24 +269,45 @@ public Styles(bool minimalGUI) public void InitGUIStyles(bool minimalGUI, bool enableSliderZoom) { + InitGUIStyles(minimalGUI, enableSliderZoom, enableSliderZoom); + } + + public void InitGUIStyles(bool minimalGUI, bool enableSliderZoomHorizontal, bool enableSliderZoomVertical) + { + this.minimalGUI = minimalGUI; + this.enableSliderZoomHorizontal = enableSliderZoomHorizontal; + this.enableSliderZoomVertical = enableSliderZoomVertical; + if (minimalGUI) { - horizontalMinMaxScrollbarThumb = enableSliderZoom ? "MiniMinMaxSliderHorizontal" : "MiniSliderhorizontal"; + if (minimalSliderStyles == null) + { + minimalSliderStyles = new SliderTypeStyles() + { + scrollbar = new SliderTypeStyles.SliderAxisStyles() { horizontal = "MiniSliderhorizontal", vertical = "MiniSliderVertical" }, + minMaxSliders = new SliderTypeStyles.SliderAxisStyles() { horizontal = "MiniMinMaxSliderHorizontal", vertical = "MiniMinMaxSlidervertical" }, + }; + } horizontalScrollbarLeftButton = GUIStyle.none; horizontalScrollbarRightButton = GUIStyle.none; horizontalScrollbar = GUIStyle.none; - verticalMinMaxScrollbarThumb = enableSliderZoom ? "MiniMinMaxSlidervertical" : "MiniSliderVertical"; verticalScrollbarUpButton = GUIStyle.none; verticalScrollbarDownButton = GUIStyle.none; verticalScrollbar = GUIStyle.none; } else { - horizontalMinMaxScrollbarThumb = enableSliderZoom ? "horizontalMinMaxScrollbarThumb" : "horizontalscrollbarthumb"; + if (normalSliderStyles == null) + { + normalSliderStyles = new SliderTypeStyles() + { + scrollbar = new SliderTypeStyles.SliderAxisStyles() { horizontal = "horizontalscrollbarthumb", vertical = "verticalscrollbarthumb" }, + minMaxSliders = new SliderTypeStyles.SliderAxisStyles() { horizontal = "horizontalMinMaxScrollbarThumb", vertical = "verticalMinMaxScrollbarThumb" }, + }; + } horizontalScrollbarLeftButton = "horizontalScrollbarLeftbutton"; horizontalScrollbarRightButton = "horizontalScrollbarRightbutton"; horizontalScrollbar = GUI.skin.horizontalScrollbar; - verticalMinMaxScrollbarThumb = enableSliderZoom ? "verticalMinMaxScrollbarThumb" : "verticalscrollbarthumb"; verticalScrollbarUpButton = "verticalScrollbarUpbutton"; verticalScrollbarDownButton = "verticalScrollbarDownbutton"; verticalScrollbar = GUI.skin.verticalScrollbar; @@ -511,16 +593,19 @@ public ZoomableArea(bool minimalGUI) m_MinimalGUI = minimalGUI; } - public ZoomableArea(bool minimalGUI, bool enableSliderZoom) + public ZoomableArea(bool minimalGUI, bool enableSliderZoom) : this(minimalGUI, enableSliderZoom, enableSliderZoom) {} + + public ZoomableArea(bool minimalGUI, bool enableSliderZoomHorizontal, bool enableSliderZoomVertical) { m_MinimalGUI = minimalGUI; - m_EnableSliderZoom = enableSliderZoom; + m_EnableSliderZoomHorizontal = enableSliderZoomHorizontal; + m_EnableSliderZoomVertical = enableSliderZoomVertical; } public void BeginViewGUI() { if (styles.horizontalScrollbar == null) - styles.InitGUIStyles(m_MinimalGUI, m_EnableSliderZoom); + styles.InitGUIStyles(m_MinimalGUI, allowSliderZoomHorizontal, allowSliderZoomVertical); if (enableMouseInput) HandleZoomAndPanEvents(m_DrawArea); @@ -627,7 +712,7 @@ void SliderGUI() Rect hRangeSliderRect = new Rect(drawRect.x + 1, drawRect.yMax - inset, drawRect.width - otherInset, styles.sliderWidth); float shownXRange = area.width; float shownXMin = area.xMin; - if (m_EnableSliderZoom) + if (allowSliderZoomHorizontal) { EditorGUIExt.MinMaxScroller(hRangeSliderRect, horizontalScrollbarID, ref shownXMin, ref shownXRange, @@ -661,7 +746,7 @@ void SliderGUI() Rect vRangeSliderRect = new Rect(drawRect.xMax - inset, drawRect.y, styles.sliderWidth, drawRect.height - otherInset); float shownYRange = area.height; float shownYMin = -area.yMax; - if (m_EnableSliderZoom) + if (allowSliderZoomVertical) { EditorGUIExt.MinMaxScroller(vRangeSliderRect, verticalScrollbarID, ref shownYMin, ref shownYRange, @@ -690,7 +775,7 @@ void SliderGUI() Rect vRangeSliderRect = new Rect(drawRect.xMax - inset, drawRect.y, styles.sliderWidth, drawRect.height - otherInset); float shownYRange = area.height; float shownYMin = area.yMin; - if (m_EnableSliderZoom) + if (allowSliderZoomVertical) { EditorGUIExt.MinMaxScroller(vRangeSliderRect, verticalScrollbarID, ref shownYMin, ref shownYRange, diff --git a/Editor/Mono/BuildPipeline/MonoAssemblyStripping.cs b/Editor/Mono/BuildPipeline/MonoAssemblyStripping.cs index e95da98d91..190326eec5 100644 --- a/Editor/Mono/BuildPipeline/MonoAssemblyStripping.cs +++ b/Editor/Mono/BuildPipeline/MonoAssemblyStripping.cs @@ -270,13 +270,11 @@ public static AssemblyDefinition ResolveAssemblyReference(IAssemblyResolver reso { return resolver.Resolve(assemblyName, new ReaderParameters { AssemblyResolver = resolver, ApplyWindowsRuntimeProjections = true }); } - catch (AssemblyResolutionException e) + catch (AssemblyResolutionException) { // DefaultAssemblyResolver doesn't handle windows runtime references correctly. But that is okay, as they cannot derive from managed types anyway - if (e.AssemblyReference.IsWindowsRuntime) - return null; - - throw; + // Besides, if any assembly is missing, UnityLinker will stub it and we should not care about it + return null; } } diff --git a/Editor/Mono/HandleUtility.bindings.cs b/Editor/Mono/HandleUtility.bindings.cs index 8c839119e3..c14143b4ee 100644 --- a/Editor/Mono/HandleUtility.bindings.cs +++ b/Editor/Mono/HandleUtility.bindings.cs @@ -26,6 +26,8 @@ public sealed partial class HandleUtility private static extern void Internal_Repaint(); + // Register a callback for GfxDevice cleanup event + private static extern void RegisterGfxDeviceCleanup(); // Test a mesh for intersection against a ray internal static extern bool IntersectRayMesh(Ray ray, Mesh mesh, Matrix4x4 matrix, out RaycastHit hit); diff --git a/Editor/Mono/HandleUtility.cs b/Editor/Mono/HandleUtility.cs index 10d8886cd8..0018f357da 100644 --- a/Editor/Mono/HandleUtility.cs +++ b/Editor/Mono/HandleUtility.cs @@ -629,11 +629,26 @@ public static Material handleMaterial } } static Material s_HandleMaterial; + static bool s_CallbackRegistered = false; + + // Called by native code + [RequiredByNativeCode] + static void CleanupHandleMaterials() + { + // This is enough for all of them to get re-fetched in next call to InitHandleMaterials() + s_HandleWireMaterial = null; + } static void InitHandleMaterials() { if (!s_HandleWireMaterial) { + if (!s_CallbackRegistered) + { + RegisterGfxDeviceCleanup(); + s_CallbackRegistered = true; + } + s_HandleWireMaterial = (Material)EditorGUIUtility.LoadRequired("SceneView/HandleLines.mat"); s_HandleWireMaterial2D = (Material)EditorGUIUtility.LoadRequired("SceneView/2DHandleLines.mat"); s_HandleWireTextureIndex = ShaderUtil.GetTextureBindingIndex(s_HandleWireMaterial.shader, Shader.PropertyToID("_MainTex")); diff --git a/Editor/Mono/Inspector/Editor.cs b/Editor/Mono/Inspector/Editor.cs index 53efe719bb..6beca4e8dd 100644 --- a/Editor/Mono/Inspector/Editor.cs +++ b/Editor/Mono/Inspector/Editor.cs @@ -697,8 +697,9 @@ internal virtual void OnHeaderControlsGUI() GUILayout.FlexibleSpace(); bool showOpenButton = true; + var importerEditor = this as AssetImporterEditor; // only show open button for the main object of an asset and for AssetImportInProgressProxy (asset not yet imported) - if (!(this is AssetImporterEditor) && !(targets[0] is AssetImportInProgressProxy)) + if (importerEditor == null && !(targets[0] is AssetImportInProgressProxy)) { var assetPath = AssetDatabase.GetAssetPath(targets[0]); // Don't show open button if the target is not an asset @@ -713,13 +714,16 @@ internal virtual void OnHeaderControlsGUI() if (showOpenButton && !ShouldHideOpenButton()) { - if (GUILayout.Button(Styles.open, EditorStyles.miniButton)) + using (new EditorGUI.DisabledScope(importerEditor != null && importerEditor.assetTarget == null)) { - if (this is AssetImporterEditor) - AssetDatabase.OpenAsset((this as AssetImporterEditor).assetTargets); - else - AssetDatabase.OpenAsset(targets); - GUIUtility.ExitGUI(); + if (GUILayout.Button(Styles.open, EditorStyles.miniButton)) + { + if (importerEditor != null) + AssetDatabase.OpenAsset(importerEditor.assetTargets); + else + AssetDatabase.OpenAsset(targets); + GUIUtility.ExitGUI(); + } } } } diff --git a/Editor/Mono/Inspector/GenericInspector.cs b/Editor/Mono/Inspector/GenericInspector.cs index 4cd420b293..5a0ea2e923 100644 --- a/Editor/Mono/Inspector/GenericInspector.cs +++ b/Editor/Mono/Inspector/GenericInspector.cs @@ -61,7 +61,10 @@ internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out Op if (m_SerializedObject == null) m_SerializedObject = new SerializedObject(targets, m_Context) {inspectorMode = m_InspectorMode}; else + { m_SerializedObject.Update(); + m_SerializedObject.inspectorMode = m_InspectorMode; + } height = 0; SerializedProperty property = m_SerializedObject.GetIterator(); diff --git a/Editor/Mono/ProjectBrowser.cs b/Editor/Mono/ProjectBrowser.cs index 8b06b15759..b57125f4e5 100644 --- a/Editor/Mono/ProjectBrowser.cs +++ b/Editor/Mono/ProjectBrowser.cs @@ -2420,7 +2420,7 @@ void BreadCrumbBar() // Package name/displayname folderNames.Add(packageInfo.name); - folderDisplayNames.Add(packageInfo.displayName ?? packageInfo.name); + folderDisplayNames.Add(string.IsNullOrEmpty(packageInfo.displayName) ? packageInfo.name : packageInfo.displayName); // Rest of the path; if (path != packageInfo.assetPath) diff --git a/Editor/Mono/TerrainEditor/TerrainInspector.cs b/Editor/Mono/TerrainEditor/TerrainInspector.cs index 54b98ad28c..fc0b143002 100644 --- a/Editor/Mono/TerrainEditor/TerrainInspector.cs +++ b/Editor/Mono/TerrainEditor/TerrainInspector.cs @@ -530,7 +530,7 @@ class Styles public GUIContent material = EditorGUIUtility.TrTextContent("Material", "The material used to render the terrain. This will affect how the color channels of a terrain texture are interpreted."); public GUIContent reflectionProbes = EditorGUIUtility.TrTextContent("Reflection Probes", "How reflection probes are used on terrain. Only effective when using built-in standard material or a custom material which supports rendering with reflection."); public GUIContent thickness = EditorGUIUtility.TrTextContent("Thickness", "How much the terrain collision volume should extend along the negative Y-axis. Objects are considered colliding with the terrain from the surface to a depth equal to the thickness. This helps prevent high-speed moving objects from penetrating into the terrain without using expensive continuous collision detection."); - + public GUIContent preserveTreePrototypeLayers = EditorGUIUtility.TextContent("Preserve Tree Prototype Layers|Enable this option if you want your tree instances to take on the layer values of their prototype prefabs, rather than the terrain GameObject's layer."); public GUIContent drawTrees = EditorGUIUtility.TrTextContent("Draw", "Should trees, grass and details be drawn?"); public GUIContent detailObjectDistance = EditorGUIUtility.TrTextContent("Detail Distance", "The distance (from camera) beyond which details will be culled."); public GUIContent collectDetailPatches = EditorGUIUtility.TrTextContent("Collect Detail Patches", "Should detail patches in the Terrain be removed from memory when not visible?"); @@ -1187,6 +1187,7 @@ public void ShowSettings() GUILayout.Label("Tree & Detail Objects", EditorStyles.boldLabel); m_Terrain.drawTreesAndFoliage = EditorGUILayout.Toggle(styles.drawTrees, m_Terrain.drawTreesAndFoliage); m_Terrain.bakeLightProbesForTrees = EditorGUILayout.Toggle(styles.bakeLightProbesForTrees, m_Terrain.bakeLightProbesForTrees); + m_Terrain.preserveTreePrototypeLayers = EditorGUILayout.Toggle(styles.preserveTreePrototypeLayers, m_Terrain.preserveTreePrototypeLayers); m_Terrain.detailObjectDistance = EditorGUILayout.Slider(styles.detailObjectDistance, m_Terrain.detailObjectDistance, 0, 250); // former string formatting: "" m_Terrain.collectDetailPatches = EditorGUILayout.Toggle(styles.collectDetailPatches, m_Terrain.collectDetailPatches); m_Terrain.detailObjectDensity = EditorGUILayout.Slider(styles.detailObjectDensity, m_Terrain.detailObjectDensity, 0.0f, 1.0f); diff --git a/Modules/Terrain/Public/Terrain.bindings.cs b/Modules/Terrain/Public/Terrain.bindings.cs index 1a119fb41d..15d4fa16d8 100644 --- a/Modules/Terrain/Public/Terrain.bindings.cs +++ b/Modules/Terrain/Public/Terrain.bindings.cs @@ -157,6 +157,8 @@ public void GetSplatMaterialPropertyBlock(MaterialPropertyBlock dest) extern public bool bakeLightProbesForTrees { get; set; } + extern public bool preserveTreePrototypeLayers { get; set; } + extern public static Terrain activeTerrain { get; } [NativeProperty("ActiveTerrainsScriptingArray")] diff --git a/Modules/UIElements/ScrollView.cs b/Modules/UIElements/ScrollView.cs index 7b818c127f..9ae699d2b1 100644 --- a/Modules/UIElements/ScrollView.cs +++ b/Modules/UIElements/ScrollView.cs @@ -33,12 +33,12 @@ public ScrollViewUxmlTraits() m_HorizontalLowValue = new UxmlFloatAttributeDescription { name = "horizontalLowValue" }; m_HorizontalHighValue = new UxmlFloatAttributeDescription { name = "horizontalHighValue" }; - m_HorizontalPageSize = new UxmlFloatAttributeDescription { name = "horizontalPageSize" }; + m_HorizontalPageSize = new UxmlFloatAttributeDescription { name = "horizontalPageSize", defaultValue = Slider.kDefaultPageSize}; m_HorizontalValue = new UxmlFloatAttributeDescription { name = "horizontalValue" }; m_VerticalLowValue = new UxmlFloatAttributeDescription { name = "verticalLowValue" }; m_VerticalHighValue = new UxmlFloatAttributeDescription { name = "verticalHighValue" }; - m_VerticalPageSize = new UxmlFloatAttributeDescription { name = "verticalPageSize" }; + m_VerticalPageSize = new UxmlFloatAttributeDescription { name = "verticalPageSize", defaultValue = Slider.kDefaultPageSize}; m_VerticalValue = new UxmlFloatAttributeDescription { name = "verticalValue" }; } diff --git a/Modules/UIElements/Slider.cs b/Modules/UIElements/Slider.cs index 804b0c1333..1690b6e894 100644 --- a/Modules/UIElements/Slider.cs +++ b/Modules/UIElements/Slider.cs @@ -22,8 +22,8 @@ public class SliderUxmlTraits : VisualElementUxmlTraits public SliderUxmlTraits() { m_LowValue = new UxmlFloatAttributeDescription { name = "lowValue" }; - m_HighValue = new UxmlFloatAttributeDescription { name = "highValue" }; - m_PageSize = new UxmlFloatAttributeDescription { name = "pageSize" }; + m_HighValue = new UxmlFloatAttributeDescription { name = "highValue", defaultValue = kDefaultHighValue }; + m_PageSize = new UxmlFloatAttributeDescription { name = "pageSize", defaultValue = kDefaultPageSize}; m_Direction = new UxmlEnumAttributeDescription { name = "direction", defaultValue = Direction.Vertical }; m_Value = new UxmlFloatAttributeDescription { name = "value" }; } @@ -102,6 +102,7 @@ public float highValue } public float range { get { return Math.Abs(highValue - lowValue); } } + public float pageSize { get; set; } public event System.Action valueChanged; @@ -170,11 +171,14 @@ public Direction direction } } + internal const float kDefaultHighValue = 10.0f; + internal const float kDefaultPageSize = 10.0f; + public Slider() - : this(0, 10.0f, null) {} + : this(0, kDefaultHighValue, null) {} public Slider(float start, float end, System.Action valueChanged, - Direction direction = Direction.Horizontal, float pageSize = 10f) + Direction direction = Direction.Horizontal, float pageSize = kDefaultPageSize) { this.direction = direction; this.pageSize = pageSize; diff --git a/Modules/UIElements/VisualElement.cs b/Modules/UIElements/VisualElement.cs index 4e2221f846..33eca6c2d7 100644 --- a/Modules/UIElements/VisualElement.cs +++ b/Modules/UIElements/VisualElement.cs @@ -426,7 +426,14 @@ internal string typeName get { if (string.IsNullOrEmpty(m_TypeName)) - m_TypeName = GetType().Name; + { + var type = GetType(); + bool isGeneric = false; + isGeneric = type.IsGenericType; + + m_TypeName = isGeneric ? type.Name.Remove(type.Name.IndexOf('`')) : type.Name; + } + return m_TypeName; } } diff --git a/README.md b/README.md index be806d8ed2..0776a00e09 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b4 C# reference source code +## Unity 2018.2.0b5 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs b/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs index 68d97077ce..e1f0208dce 100644 --- a/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs +++ b/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs @@ -10,7 +10,7 @@ namespace UnityEngine.XR.WSA { public partial class HolographicRemoting { - public HolographicStreamerConnectionState ConnectionState + public static HolographicStreamerConnectionState ConnectionState { get { From 15562ea1a55a98587abcea8f0c4aa5bfa379788c Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Tue, 29 May 2018 14:49:22 +0000 Subject: [PATCH 05/13] Unity 2018.2.0b6 C# reference source code --- Editor/Mono/AssemblyInfo/AssemblyInfo.cs | 1 + .../BuildPipeline/BuildPipelineInterfaces.cs | 39 ++++++++++++++++++- .../Mono/BuildPipeline/CodeStrippingUtils.cs | 6 +++ .../MonoInternalCallGenerator.cs | 2 +- .../Burst/BurstCompilerService.bindings.cs | 10 ++--- .../Editor/Managed/Grid/PaintableGrid.cs | 8 ++++ .../Managed/Grid/PaintableSceneViewGrid.cs | 35 +++++++++++++---- README.md | 2 +- Runtime/Export/AssemblyInfo.cs | 1 + Runtime/Export/Hash128.bindings.cs | 3 ++ Runtime/Jobs/Managed/BatchQueries.cs | 2 +- 11 files changed, 92 insertions(+), 17 deletions(-) diff --git a/Editor/Mono/AssemblyInfo/AssemblyInfo.cs b/Editor/Mono/AssemblyInfo/AssemblyInfo.cs index c7e87c7e5c..11857aab9e 100644 --- a/Editor/Mono/AssemblyInfo/AssemblyInfo.cs +++ b/Editor/Mono/AssemblyInfo/AssemblyInfo.cs @@ -26,6 +26,7 @@ [assembly: InternalsVisibleTo("UnityEditor.XboxOne.Extensions")] [assembly: InternalsVisibleTo("UnityEditor.PSP2.Extensions")] [assembly: InternalsVisibleTo("UnityEditor.PS4.Extensions")] +[assembly: InternalsVisibleTo("UnityEditor.Switch.Extensions")] [assembly: InternalsVisibleTo("UnityEditor.WebGL.Extensions")] [assembly: InternalsVisibleTo("UnityEditor.LinuxStandalone.Extensions")] [assembly: InternalsVisibleTo("UnityEditor.WindowsStandalone.Extensions")] diff --git a/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs b/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs index 5bf4589560..ac6e4f75ac 100644 --- a/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs +++ b/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs @@ -45,6 +45,11 @@ public interface IPostprocessBuildWithReport : IOrderedCallback void OnPostprocessBuild(BuildReport report); } + public interface IPostBuildPlayerScriptDLLs : IOrderedCallback + { + void OnPostBuildPlayerScriptDLLs(BuildReport report); + } + [Obsolete("Use IProcessSceneWithReport instead")] public interface IProcessScene : IOrderedCallback { @@ -83,6 +88,7 @@ internal class Processors public List filterBuildAssembliesProcessor; public List buildTargetProcessors; public List shaderProcessors; + public List buildPlayerScriptDLLProcessors; } private static Processors m_Processors; @@ -104,7 +110,8 @@ internal enum BuildCallbacks SceneProcessors = 2, BuildTargetProcessors = 4, FilterAssembliesProcessors = 8, - ShaderProcessors = 16 + ShaderProcessors = 16, + BuildPlayerScriptDLLProcessors = 32 } //common comparer for all callback types @@ -177,6 +184,7 @@ internal static void InitializeBuildCallbacks(BuildCallbacks findFlags) bool findTargetProcessors = (findFlags & BuildCallbacks.BuildTargetProcessors) == BuildCallbacks.BuildTargetProcessors; bool findFilterProcessors = (findFlags & BuildCallbacks.FilterAssembliesProcessors) == BuildCallbacks.FilterAssembliesProcessors; bool findShaderProcessors = (findFlags & BuildCallbacks.ShaderProcessors) == BuildCallbacks.ShaderProcessors; + bool findBuildPlayerScriptDLLsProcessors = (findFlags & BuildCallbacks.BuildPlayerScriptDLLProcessors) == BuildCallbacks.BuildPlayerScriptDLLProcessors; var postProcessBuildAttributeParams = new Type[] { typeof(BuildTarget), typeof(string) }; foreach (var t in EditorAssemblies.GetAllTypesWithInterface()) @@ -215,6 +223,11 @@ internal static void InitializeBuildCallbacks(BuildCallbacks findFlags) { AddToListIfTypeImplementsInterface(t, ref instance, ref processors.shaderProcessors); } + + if (findBuildPlayerScriptDLLsProcessors) + { + AddToListIfTypeImplementsInterface(t, ref instance, ref processors.buildPlayerScriptDLLProcessors); + } } if (findBuildProcessors) @@ -249,6 +262,8 @@ internal static void InitializeBuildCallbacks(BuildCallbacks findFlags) processors.filterBuildAssembliesProcessor.Sort(CompareICallbackOrder); if (processors.shaderProcessors != null) processors.shaderProcessors.Sort(CompareICallbackOrder); + if (processors.buildPlayerScriptDLLProcessors != null) + processors.buildPlayerScriptDLLProcessors.Sort(CompareICallbackOrder); } internal static bool ValidateType(Type t) @@ -429,6 +444,27 @@ internal static ShaderCompilerData[] OnPreprocessShaders(Shader shader, ShaderSn return dataList.ToArray(); } + [RequiredByNativeCode] + internal static void OnPostBuildPlayerScriptDLLs(BuildReport report) + { + if (processors.buildPlayerScriptDLLProcessors != null) + { + foreach (var step in processors.buildPlayerScriptDLLProcessors) + { + try + { + step.OnPostBuildPlayerScriptDLLs(report); + } + catch (Exception e) + { + Debug.LogException(e); + if ((report.summary.options & BuildOptions.StrictMode) != 0 || (report.summary.assetBundleOptions & BuildAssetBundleOptions.StrictMode) != 0) + return; + } + } + } + } + [RequiredByNativeCode] internal static string[] FilterAssembliesIncludedInBuild(BuildOptions buildOptions, string[] assemblies) { @@ -471,6 +507,7 @@ internal static void CleanupBuildCallbacks() processors.sceneProcessorsWithReport = null; processors.filterBuildAssembliesProcessor = null; processors.shaderProcessors = null; + processors.buildPlayerScriptDLLProcessors = null; previousFlags = BuildCallbacks.None; } } diff --git a/Editor/Mono/BuildPipeline/CodeStrippingUtils.cs b/Editor/Mono/BuildPipeline/CodeStrippingUtils.cs index f4e1861508..7399e72798 100644 --- a/Editor/Mono/BuildPipeline/CodeStrippingUtils.cs +++ b/Editor/Mono/BuildPipeline/CodeStrippingUtils.cs @@ -645,6 +645,12 @@ private static string[] GetUserAssemblies(string strippedAssemblyDir) arguments.AddRange(files.Select(f => Path.GetFileName(f))); } + // Workaround: if there are no user assemblies (because the project does not contain scripts), add + // UnityEngine, to makes sure we pick up types required by core module. Need to remove this once + // we want to be able to strip core module for ECS only players. + if (arguments.Count == 0) + arguments.Add("UnityEngine.dll"); + return arguments.ToArray(); } } //CodeStrippingUtils diff --git a/Editor/Mono/BuildPipeline/MonoInternalCallGenerator.cs b/Editor/Mono/BuildPipeline/MonoInternalCallGenerator.cs index 4cc12bb47c..022cb6e2ce 100644 --- a/Editor/Mono/BuildPipeline/MonoInternalCallGenerator.cs +++ b/Editor/Mono/BuildPipeline/MonoInternalCallGenerator.cs @@ -102,7 +102,7 @@ static public void WriteCPlusPlusFileForStaticAOTModuleRegistration(BuildTarget HashSet nativeClasses; HashSet nativeModules; - CodeStrippingUtils.GenerateDependencies(Path.GetDirectoryName(stagingAreaDataManaged), icallSummaryPath, usedClassRegistry, stripping, out nativeClasses, out nativeModules, platformProvider); + CodeStrippingUtils.GenerateDependencies(stagingAreaDataManaged, icallSummaryPath, usedClassRegistry, stripping, out nativeClasses, out nativeModules, platformProvider); using (TextWriter w = new StreamWriter(file)) { diff --git a/Editor/Mono/Burst/BurstCompilerService.bindings.cs b/Editor/Mono/Burst/BurstCompilerService.bindings.cs index 33a198b7bf..1618875bfa 100644 --- a/Editor/Mono/Burst/BurstCompilerService.bindings.cs +++ b/Editor/Mono/Burst/BurstCompilerService.bindings.cs @@ -2,11 +2,6 @@ // Copyright (c) Unity Technologies. For terms of use, see // https://unity3d.com/legal/licenses/Unity_Reference_Only_License -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using System; -using System.IO; using UnityEngine.Bindings; using System.Reflection; @@ -24,8 +19,11 @@ internal static partial class BurstCompilerService [FreeFunction] public static extern int CompileAsyncDelegateMethod(object delegateMethod, string compilerOptions); + [FreeFunction] - public unsafe static extern void* GetAsyncCompiledAsyncDelegateMethod(int userID); + public static extern unsafe void* GetAsyncCompiledAsyncDelegateMethod(int userID); + + public static extern string GetMethodSignature(MethodInfo method); public static extern bool IsInitialized { get; } } diff --git a/Modules/TilemapEditor/Editor/Managed/Grid/PaintableGrid.cs b/Modules/TilemapEditor/Editor/Managed/Grid/PaintableGrid.cs index 745b081fb9..9d863b3e8b 100644 --- a/Modules/TilemapEditor/Editor/Managed/Grid/PaintableGrid.cs +++ b/Modules/TilemapEditor/Editor/Managed/Grid/PaintableGrid.cs @@ -13,6 +13,8 @@ namespace UnityEditor { internal abstract class PaintableGrid : ScriptableObject { + private const int k_MaxMouseCellDelta = 500; + public enum MarqueeType { None = 0, Pick, Box, Select } private int m_PermanentControlID; @@ -108,6 +110,12 @@ protected void UpdateMouseGridPosition() Vector2Int newGridPosition = ScreenToGrid(Event.current.mousePosition); if (newGridPosition != m_MouseGridPosition) { + var delta = newGridPosition - m_MouseGridPosition; + // Case 1024422: Limit mouse cell delta changes for Grid/Tilemap input handling due to camera changes when switching modes/axis views + if (Mathf.Abs(delta.x) > k_MaxMouseCellDelta) + newGridPosition.x = m_MouseGridPosition.x + Math.Sign(delta.x) * k_MaxMouseCellDelta; + if (Mathf.Abs(delta.y) > k_MaxMouseCellDelta) + newGridPosition.y = m_MouseGridPosition.y + Math.Sign(delta.y) * k_MaxMouseCellDelta; m_PreviousMouseGridPosition = m_MouseGridPosition; m_MouseGridPosition = newGridPosition; m_MouseGridPositionChanged = true; diff --git a/Modules/TilemapEditor/Editor/Managed/Grid/PaintableSceneViewGrid.cs b/Modules/TilemapEditor/Editor/Managed/Grid/PaintableSceneViewGrid.cs index b1075b6603..780698a204 100644 --- a/Modules/TilemapEditor/Editor/Managed/Grid/PaintableSceneViewGrid.cs +++ b/Modules/TilemapEditor/Editor/Managed/Grid/PaintableSceneViewGrid.cs @@ -60,16 +60,28 @@ private void OnGridSelectionChanged() public void OnSceneGUI(SceneView sceneView) { UpdateMouseGridPosition(); - base.OnGUI(); - if (PaintableGrid.InGridEditMode()) + + var dot = 1.0f; + var gridView = GetGridView(); + if (gridView != null) + { + dot = Math.Abs(Vector3.Dot(sceneView.camera.transform.forward, Grid.Swizzle(gridView.cellSwizzle, gridView.transform.forward))); + } + + // Case 1021655: Validate that grid is not totally parallel to view (+-5 degrees), otherwise tiles could be accidentally painted on large positions + if (dot > 0.1f) { - CallOnSceneGUI(); - if ((grid != null) && (GridPaintingState.activeGrid == this || GridSelection.active)) + base.OnGUI(); + if (InGridEditMode()) { - CallOnPaintSceneGUI(); + CallOnSceneGUI(); + if ((grid != null) && (GridPaintingState.activeGrid == this || GridSelection.active)) + { + CallOnPaintSceneGUI(); + } + if (Event.current.type == EventType.Repaint) + EditorGUIUtility.AddCursorRect(new Rect(0, EditorGUI.kWindowToolbarHeight, sceneView.position.width, sceneView.position.height - EditorGUI.kWindowToolbarHeight), MouseCursor.CustomCursor); } - if (Event.current.type == EventType.Repaint) - EditorGUIUtility.AddCursorRect(new Rect(0, EditorGUI.kWindowToolbarHeight, sceneView.position.width, sceneView.position.height - EditorGUI.kWindowToolbarHeight), MouseCursor.CustomCursor); } HandleMouseEnterLeave(sceneView); } @@ -280,6 +292,15 @@ private Plane GetGridPlane(Grid grid) return new Plane(grid.transform.forward * -1f, grid.transform.position); } + private GridLayout GetGridView() + { + if (tilemap != null) + return tilemap; + if (grid != null) + return grid; + return null; + } + void CallOnPaintSceneGUI() { bool hasSelection = GridSelection.active && GridSelection.target == brushTarget; diff --git a/README.md b/README.md index 0776a00e09..7f7f63ab71 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b5 C# reference source code +## Unity 2018.2.0b6 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Export/AssemblyInfo.cs b/Runtime/Export/AssemblyInfo.cs index 0f44d8337a..a2fefcd6a6 100644 --- a/Runtime/Export/AssemblyInfo.cs +++ b/Runtime/Export/AssemblyInfo.cs @@ -15,6 +15,7 @@ [assembly: InternalsVisibleTo("UnityEditor.Graphs")] [assembly: InternalsVisibleTo("UnityEditor.XboxOne.Extensions")] [assembly: InternalsVisibleTo("UnityEditor.PS4.Extensions")] +[assembly: InternalsVisibleTo("UnityEditor.Switch.Extensions")] [assembly: InternalsVisibleTo("UnityEditor.WSA.Extensions")] [assembly: InternalsVisibleTo("Assembly-CSharp-testable")] [assembly: InternalsVisibleTo("Assembly-CSharp-firstpass-testable")] diff --git a/Runtime/Export/Hash128.bindings.cs b/Runtime/Export/Hash128.bindings.cs index 4bae351f7e..405f0efa92 100644 --- a/Runtime/Export/Hash128.bindings.cs +++ b/Runtime/Export/Hash128.bindings.cs @@ -66,6 +66,9 @@ public override string ToString() [FreeFunction("Hash128ToString")] internal static extern string Internal_Hash128ToString(Hash128 hash128); + [FreeFunction("ComputeHash128FromString")] + public static extern Hash128 Compute(string hashString); + public override bool Equals(object obj) { return obj is Hash128 && this == (Hash128)obj; diff --git a/Runtime/Jobs/Managed/BatchQueries.cs b/Runtime/Jobs/Managed/BatchQueries.cs index d36ff9d1dd..e8e82308a2 100644 --- a/Runtime/Jobs/Managed/BatchQueries.cs +++ b/Runtime/Jobs/Managed/BatchQueries.cs @@ -33,7 +33,7 @@ public struct BatchQueryJobStruct where T : struct public static IntPtr Initialize() { if (jobReflectionData == IntPtr.Zero) - jobReflectionData = JobsUtility.CreateJobReflectionData(typeof(T), JobType.ParallelFor, System.IntPtr.Zero); + jobReflectionData = JobsUtility.CreateJobReflectionData(typeof(T), JobType.ParallelFor, null); return jobReflectionData; } } From 2529e30b64647118885c973243b512d14e89ec2a Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Wed, 6 Jun 2018 17:13:56 +0000 Subject: [PATCH 06/13] Unity 2018.2.0b7 C# reference source code --- .../2D/Interface/ISpriteEditorDataProvider.cs | 10 ++- .../SpriteEditorModule/ISpriteEditorModule.cs | 1 + .../SpriteFrameModule/SpriteFrameModule.cs | 18 ++++- .../SpriteFrameModuleView.cs | 2 +- .../SpriteEditorModule/SpriteOutlineModule.cs | 2 +- Editor/Mono/AssemblyInfo/AssemblyInfo.cs | 2 + .../AssetDatabase/AssetDatabase.bindings.cs | 12 +++ .../AssetDatabase/AssetDatabaseSearching.cs | 20 +++-- Editor/Mono/ContainerWindow.cs | 37 ++++++---- Editor/Mono/GUI/ColorPicker.cs | 8 +- Editor/Mono/GameView/GameView.cs | 5 +- .../AddComponent/AddComponentWindow.cs | 3 + Editor/Mono/Inspector/LineRendererEditor.cs | 12 ++- .../Mono/Inspector/LineRendererToolModes.cs | 2 +- .../Inspector/ScriptableObjectAssetEditor.cs | 35 +++++++++ Editor/Mono/InternalEditorUtility.bindings.cs | 3 + .../LookDevView/CameraControllerStandard.cs | 7 +- Editor/Mono/LookDevView/LookDevView.cs | 14 +++- Editor/Mono/ObjectSelector.cs | 6 ++ Editor/Mono/PlayerSettingsSwitch.bindings.cs | 35 +++++++++ Editor/Mono/ProjectBrowser.cs | 74 +++++++++++++------ .../Mono/ProjectBrowser/SavedSearchFilter.cs | 2 + .../ProjectWindow/CachedFilteredHierachy.cs | 12 ++- Editor/Mono/ProjectWindow/SearchFilter.cs | 19 ++++- Editor/Mono/SceneView/CameraFlyModeContext.cs | 14 +++- Editor/Mono/SceneView/SceneView.cs | 2 - Editor/Mono/SceneView/SceneViewMotion.cs | 7 +- Editor/Mono/Scripting/Compilers/APIUpdater.cs | 6 +- .../ScriptCompilation/EditorBuildRules.cs | 3 +- Editor/Mono/SearchUtility.cs | 23 ++++++ Editor/Mono/SpriteEditor/SpriteEditorMenu.cs | 16 ++-- .../Mono/SpriteEditor/SpriteEditorWindow.cs | 7 +- Editor/Mono/StyleSheets/StyleSheetEditor.cs | 2 +- .../Mono/UIElements/UIElementsViewImporter.cs | 4 + .../Mono/UIElements/VisualTreeAssetEditor.cs | 22 +----- .../Common/VCAssetModificationHooks.cs | 9 ++- .../Mono/VersionControl/UI/VCListControl.cs | 18 ++++- Editor/Mono/VersionControl/UI/VCOverlay.cs | 69 ++++++++--------- .../Mono/VersionControl/UI/VCProjectHooks.cs | 7 ++ .../SolutionSynchronizationSettings.cs | 2 + Modules/GraphViewEditor/Elements/Node.cs | 5 ++ Modules/IMGUI/GUIUtility.bindings.cs | 18 +++-- Modules/IMGUI/GUIUtility.cs | 12 ++- .../Editor/Managed/PackageInfo.cs | 5 ++ Modules/UIElements/Panel.cs | 42 ++++++----- Modules/UIElements/VisualElement.cs | 25 +++---- Projects/CSharp/UnityEditor.csproj | 6 ++ README.md | 2 +- Runtime/Export/Vector2.cs | 10 ++- Runtime/Export/Vector3.cs | 11 ++- 50 files changed, 473 insertions(+), 215 deletions(-) create mode 100644 Editor/Mono/Inspector/ScriptableObjectAssetEditor.cs create mode 100644 Editor/Mono/PlayerSettingsSwitch.bindings.cs diff --git a/Editor/Mono/2D/Interface/ISpriteEditorDataProvider.cs b/Editor/Mono/2D/Interface/ISpriteEditorDataProvider.cs index 45f7f8acab..06a3dc6297 100644 --- a/Editor/Mono/2D/Interface/ISpriteEditorDataProvider.cs +++ b/Editor/Mono/2D/Interface/ISpriteEditorDataProvider.cs @@ -52,6 +52,7 @@ public interface ISpritePhysicsOutlineDataProvider public interface ITextureDataProvider { Texture2D texture { get; } + Texture2D previewTexture { get; } void GetTextureActualWidthAndHeight(out int width , out int height); Texture2D GetReadableTexture2D(); } @@ -434,6 +435,11 @@ public Texture2D texture } } + public Texture2D previewTexture + { + get { return texture; } + } + public void GetTextureActualWidthAndHeight(out int width, out int height) { width = height = 0; @@ -444,9 +450,7 @@ public Texture2D GetReadableTexture2D() { if (m_ReadableTexture == null) { - int width = 0, height = 0; - GetTextureActualWidthAndHeight(out width, out height); - m_ReadableTexture = UnityEditor.SpriteUtility.CreateTemporaryDuplicate(texture, width, height); + m_ReadableTexture = UnityEditor.SpriteUtility.CreateTemporaryDuplicate(texture, texture.width, texture.height); if (m_ReadableTexture != null) m_ReadableTexture.filterMode = texture.filterMode; } diff --git a/Editor/Mono/2D/SpriteEditorModule/ISpriteEditorModule.cs b/Editor/Mono/2D/SpriteEditorModule/ISpriteEditorModule.cs index 5287feb5dd..598cf83551 100644 --- a/Editor/Mono/2D/SpriteEditorModule/ISpriteEditorModule.cs +++ b/Editor/Mono/2D/SpriteEditorModule/ISpriteEditorModule.cs @@ -39,6 +39,7 @@ public interface ISpriteEditor void SetDataModified(); void ApplyOrRevertModification(bool apply); VisualElement GetMainVisualContainer(); + void SetPreviewTexture(Texture2D texture, int width, int height); } [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] diff --git a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModule.cs b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModule.cs index a9fd657495..439d1525da 100644 --- a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModule.cs +++ b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModule.cs @@ -208,7 +208,7 @@ public void DoAutomaticSlicing(int minimumSpriteSize, int alignment, Vector2 piv if (slicingMethod == AutoSlicingMethod.DeleteAll) m_RectsCache.spriteRects.Clear(); - var textureToUse = m_TextureDataProvider.GetReadableTexture2D(); + var textureToUse = GetTextureToSlice(); List frames = new List(InternalSpriteUtility.GenerateAutomaticSpriteRectangles((UnityTexture2D)textureToUse, minimumSpriteSize, 0)); frames = SortRects(frames); int index = 0; @@ -221,9 +221,23 @@ public void DoAutomaticSlicing(int minimumSpriteSize, int alignment, Vector2 piv Repaint(); } + UnityTexture2D GetTextureToSlice() + { + int width, height; + m_TextureDataProvider.GetTextureActualWidthAndHeight(out width, out height); + var readableTexture = m_TextureDataProvider.GetReadableTexture2D(); + if (readableTexture == null || (readableTexture.width == width && readableTexture.height == height)) + return readableTexture; + // we want to slice based on the original texture slice. Upscale the imported texture + var texture = UnityEditor.SpriteUtility.CreateTemporaryDuplicate(readableTexture, width, height); + if (texture != null) + texture.filterMode = texture.filterMode; + return texture; + } + public void DoGridSlicing(Vector2 size, Vector2 offset, Vector2 padding, int alignment, Vector2 pivot) { - var textureToUse = m_TextureDataProvider.GetReadableTexture2D(); + var textureToUse = GetTextureToSlice(); Rect[] frames = InternalSpriteUtility.GenerateGridSpriteRectangles((UnityTexture2D)textureToUse, offset, size, padding); int index = 0; diff --git a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleView.cs b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleView.cs index 7da86a64c5..8a78cef34e 100644 --- a/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleView.cs +++ b/Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleView.cs @@ -55,7 +55,7 @@ public override void DoMainGUI() public override void DoToolbarGUI(Rect toolbarRect) { - using (new EditorGUI.DisabledScope(!containsMultipleSprites || spriteEditor.editingDisabled)) + using (new EditorGUI.DisabledScope(!containsMultipleSprites || spriteEditor.editingDisabled || m_TextureDataProvider.GetReadableTexture2D() == null)) { GUIStyle skin = EditorStyles.toolbarPopup; diff --git a/Editor/Mono/2D/SpriteEditorModule/SpriteOutlineModule.cs b/Editor/Mono/2D/SpriteEditorModule/SpriteOutlineModule.cs index 04c1621953..67d71d1111 100644 --- a/Editor/Mono/2D/SpriteEditorModule/SpriteOutlineModule.cs +++ b/Editor/Mono/2D/SpriteEditorModule/SpriteOutlineModule.cs @@ -772,7 +772,7 @@ private void DrawGizmos() protected static List GenerateSpriteRectOutline(Rect rect, float detail, byte alphaTolerance, ITextureDataProvider textureProvider) { List outline = new List(); - var texture = textureProvider.texture; + var texture = textureProvider.GetReadableTexture2D(); if (texture != null) { Vector2[][] paths; diff --git a/Editor/Mono/AssemblyInfo/AssemblyInfo.cs b/Editor/Mono/AssemblyInfo/AssemblyInfo.cs index 11857aab9e..61d241dd26 100644 --- a/Editor/Mono/AssemblyInfo/AssemblyInfo.cs +++ b/Editor/Mono/AssemblyInfo/AssemblyInfo.cs @@ -6,6 +6,8 @@ using UnityEngine; // ADD_NEW_PLATFORM_HERE +[assembly: InternalsVisibleTo("Unity.Burst")] +[assembly: InternalsVisibleTo("Unity.Burst.Editor")] [assembly: InternalsVisibleTo("UnityEditor.Advertisements")] [assembly: InternalsVisibleTo("Unity.Burst")] [assembly: InternalsVisibleTo("Unity.Burst.Editor")] diff --git a/Editor/Mono/AssetDatabase/AssetDatabase.bindings.cs b/Editor/Mono/AssetDatabase/AssetDatabase.bindings.cs index fc847905cc..6d2d7738c7 100644 --- a/Editor/Mono/AssetDatabase/AssetDatabase.bindings.cs +++ b/Editor/Mono/AssetDatabase/AssetDatabase.bindings.cs @@ -72,6 +72,18 @@ public static void ForceReserializeAssets(IEnumerable assetPaths, ForceR [FreeFunction("AssetDatabase::GetGUIDAndLocalIdentifierInFile")] extern private static bool GetGUIDAndLocalIdentifierInFile(int instanceID, out GUID outGuid, out long outLocalId); + [Obsolete("Please use the overload of this function that uses a long data type for the localId parameter, because this version can return a localID that has overflowed. This can happen when called on objects that are part of a Prefab.", true)] + public static bool TryGetGUIDAndLocalFileIdentifier(UnityEngine.Object obj, out string guid, out int localId) + { + return TryGetGUIDAndLocalFileIdentifier(obj.GetInstanceID(), out guid, out localId); + } + + [Obsolete("Please use the overload of this function that uses a long data type for the localId parameter, because this version can return a localID that has overflowed. This can happen when called on objects that are part of a Prefab.", true)] + public static bool TryGetGUIDAndLocalFileIdentifier(int instanceID, out string guid, out int localId) + { + throw new NotSupportedException("Use the overload of this function that uses a long data type for the localId parameter, because this version can return a localID that has overflowed. This can happen when called on objects that are part of a Prefab."); + } + public static bool TryGetGUIDAndLocalFileIdentifier(UnityEngine.Object obj, out string guid, out long localId) { return TryGetGUIDAndLocalFileIdentifier(obj.GetInstanceID(), out guid, out localId); diff --git a/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs b/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs index f8f2f6cf3c..d83ef76976 100644 --- a/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs +++ b/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs @@ -101,14 +101,22 @@ private static IEnumerator FindInFolders(SearchFilter searchFilter, Func FindEverywhere(SearchFilter searchFilter, Func selector) { var rootPaths = new List(); - rootPaths.Add("Assets"); - var packages = PackageManager.Packages.GetAll(); - foreach (var package in packages) + if (searchFilter.searchArea == SearchFilter.SearchArea.AllAssets || + searchFilter.searchArea == SearchFilter.SearchArea.InAssetsOnly) { - if (package.source == PackageManager.PackageSource.BuiltIn) - continue; + rootPaths.Add("Assets"); + } + if (searchFilter.searchArea == SearchFilter.SearchArea.AllAssets || + searchFilter.searchArea == SearchFilter.SearchArea.InPackagesOnly) + { + var packages = PackageManager.Packages.GetAll(); + foreach (var package in packages) + { + if (package.source == PackageManager.PackageSource.BuiltIn) + continue; - rootPaths.Add(package.assetPath); + rootPaths.Add(package.assetPath); + } } foreach (var rootPath in rootPaths) { diff --git a/Editor/Mono/ContainerWindow.cs b/Editor/Mono/ContainerWindow.cs index 2a7d84fb49..5b542a6c46 100644 --- a/Editor/Mono/ContainerWindow.cs +++ b/Editor/Mono/ContainerWindow.cs @@ -390,7 +390,7 @@ private bool TitleBarButton(GUIStyle style) // Snapping windows static Vector2 s_LastDragMousePos; - static Rect dragPosition; + float startDragDpi; private void DragTitleBar(Rect titleBarRect) { int id = GUIUtility.GetControlID(FocusType.Passive); @@ -407,8 +407,8 @@ private void DragTitleBar(Rect titleBarRect) { GUIUtility.hotControl = id; Event.current.Use(); - s_LastDragMousePos = GUIUtility.GUIToScreenPoint(evt.mousePosition); - dragPosition = position; + s_LastDragMousePos = evt.mousePosition; + startDragDpi = GUIUtility.pixelsPerPoint; Unsupported.SetAllowCursorLock(false, Unsupported.DisallowCursorLockReasons.SizeMove); } break; @@ -423,20 +423,29 @@ private void DragTitleBar(Rect titleBarRect) case EventType.MouseDrag: if (GUIUtility.hotControl == id) { - Vector2 absMouse = GUIUtility.GUIToScreenPoint(evt.mousePosition); - Vector2 movement = absMouse - s_LastDragMousePos; - - float minimumDelta = 1.0f / GUIUtility.pixelsPerPoint; - - if (Mathf.Abs(movement.x) >= minimumDelta || Mathf.Abs(movement.y) >= minimumDelta) + Vector2 mousePos = evt.mousePosition; + if (startDragDpi != GUIUtility.pixelsPerPoint) { - s_LastDragMousePos = absMouse; + // We ignore this mouse event when changing screens in multi monitor setups with + // different dpi scalings as funky things might/will happen + startDragDpi = GUIUtility.pixelsPerPoint; + s_LastDragMousePos = mousePos; + } + else + { + Vector2 movement = mousePos - s_LastDragMousePos; + + float minimumDelta = 1.0f / GUIUtility.pixelsPerPoint; - dragPosition.x += movement.x; - dragPosition.y += movement.y; - position = dragPosition; + if (Mathf.Abs(movement.x) >= minimumDelta || Mathf.Abs(movement.y) >= minimumDelta) + { + Rect dragPosition = position; + dragPosition.x += movement.x; + dragPosition.y += movement.y; + position = dragPosition; - GUI.changed = true; + GUI.changed = true; + } } } break; diff --git a/Editor/Mono/GUI/ColorPicker.cs b/Editor/Mono/GUI/ColorPicker.cs index 2d04d0c030..002fabf99b 100644 --- a/Editor/Mono/GUI/ColorPicker.cs +++ b/Editor/Mono/GUI/ColorPicker.cs @@ -1215,7 +1215,9 @@ public void OnDestroy() internal class EyeDropper : GUIView { const int kPixelSize = 10; - const int kDummyWindowSize = 8192; + // Can't be larger right now since OSX Metal surfaces can't be larger than 16384 pixels. + // This needs to be changed to a larger size since it will miss mouse events when using multiple 4K monitors + private const int kDummyWindowSize = 8192; internal static Color s_LastPickedColor; GUIView m_DelegateView; Texture2D m_Preview; @@ -1277,7 +1279,7 @@ static EyeDropper instance public static Color GetPickedColor() { - return InternalEditorUtility.ReadScreenPixel(s_PickCoordinates, 1, 1)[0]; + return InternalEditorUtility.ReadScreenPixelUnderCursor(s_PickCoordinates, 1, 1)[0]; } public static Color GetLastPickedColor() @@ -1312,7 +1314,7 @@ public static void DrawPreview(Rect position) Vector2 p = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); Vector2 mPos = p - new Vector2((width / 2), (height / 2)); - preview.SetPixels(InternalEditorUtility.ReadScreenPixel(mPos, width, height), 0); + preview.SetPixels(InternalEditorUtility.ReadScreenPixelUnderCursor(p, width, height), 0); preview.Apply(true); Graphics.DrawTexture(position, preview); diff --git a/Editor/Mono/GameView/GameView.cs b/Editor/Mono/GameView/GameView.cs index 86a42f5025..f3cca06009 100644 --- a/Editor/Mono/GameView/GameView.cs +++ b/Editor/Mono/GameView/GameView.cs @@ -806,7 +806,10 @@ private void OnGUI() GUI.BeginGroup(m_ZoomArea.drawRect); // Actually draw the game view to the screen, without alpha blending - Graphics.DrawTexture(deviceFlippedTargetInView, m_TargetTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, GUI.blitMaterial); + Rect drawRect = deviceFlippedTargetInView; + drawRect.x = Mathf.Round(drawRect.x); + drawRect.y = Mathf.Round(drawRect.y); + Graphics.DrawTexture(drawRect, m_TargetTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, GUI.blitMaterial); GUI.EndGroup(); } } diff --git a/Editor/Mono/Inspector/AddComponent/AddComponentWindow.cs b/Editor/Mono/Inspector/AddComponent/AddComponentWindow.cs index e7e6208cf6..2d317df583 100644 --- a/Editor/Mono/Inspector/AddComponent/AddComponentWindow.cs +++ b/Editor/Mono/Inspector/AddComponent/AddComponentWindow.cs @@ -110,7 +110,10 @@ internal static void ExecuteAddComponentMenuItem() { var insp = FirstInspectorWithGameObject(); if (insp != null) + { + insp.ShowTab(); insp.SendEvent(EditorGUIUtility.CommandEvent(OpenAddComponentDropdown)); + } } private static InspectorWindow FirstInspectorWithGameObject() diff --git a/Editor/Mono/Inspector/LineRendererEditor.cs b/Editor/Mono/Inspector/LineRendererEditor.cs index 2f14d78caf..42fcca0c1c 100644 --- a/Editor/Mono/Inspector/LineRendererEditor.cs +++ b/Editor/Mono/Inspector/LineRendererEditor.cs @@ -192,6 +192,7 @@ public void OnDisable() private void UndoRedoPerformed() { m_PointEditor.RemoveInvalidSelections(); + m_PositionsView.Reload(); m_PositionsView.SetSelection(m_PointEditor.m_Selection); ResetSimplifyPreview(); } @@ -367,11 +368,11 @@ private void ResetSimplifyPreview() private void DrawSimplifyPreview() { - if (!showSimplifyPreview || m_IsMultiEditing) - return; - var lineRenderer = target as LineRenderer; + if (!showSimplifyPreview || m_IsMultiEditing || !lineRenderer.enabled) + return; + if (m_PreviewPoints == null && lineRenderer.positionCount > 2) { m_PreviewPoints = new Vector3[lineRenderer.positionCount]; @@ -478,6 +479,11 @@ private void InternalOnSceneView() { case EditMode.SceneViewEditMode.LineRendererEdit: m_PointEditor.EditSceneGUI(); + if (m_Positions.arraySize != m_PositionsView.GetRows().Count) + { + m_PositionsView.Reload(); + ResetSimplifyPreview(); + } m_PositionsView.SetSelection(m_PointEditor.m_Selection, TreeViewSelectionOptions.RevealAndFrame); break; case EditMode.SceneViewEditMode.LineRendererCreate: diff --git a/Editor/Mono/Inspector/LineRendererToolModes.cs b/Editor/Mono/Inspector/LineRendererToolModes.cs index 57e09fc9ff..f948cbd26e 100644 --- a/Editor/Mono/Inspector/LineRendererToolModes.cs +++ b/Editor/Mono/Inspector/LineRendererToolModes.cs @@ -40,7 +40,7 @@ public static InputMode inputMode public static LayerMask raycastMask { - get { return EditorPrefs.GetInt("LineRendererEditorRaycastMask", 0); } + get { return EditorPrefs.GetInt("LineRendererEditorRaycastMask", -1); } set { EditorPrefs.SetInt("LineRendererEditorRaycastMask", value); } } diff --git a/Editor/Mono/Inspector/ScriptableObjectAssetEditor.cs b/Editor/Mono/Inspector/ScriptableObjectAssetEditor.cs new file mode 100644 index 0000000000..75a6086d74 --- /dev/null +++ b/Editor/Mono/Inspector/ScriptableObjectAssetEditor.cs @@ -0,0 +1,35 @@ +// Unity C# reference source +// Copyright (c) Unity Technologies. For terms of use, see +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License + +using System; +using UnityEditor; +using UnityEngine; + +namespace UnityEditor +{ + // This base class can be used when the type of an imported object derives from ScriptableObject + // Since SOs have the special need of being reloaded after a re-import + // we need to check for validity of the target in a few places + abstract internal class ScriptableObjectAssetEditor : Editor + { + // hack to avoid null references when a scriptedImporter runs and replaces the current selection + internal override string targetTitle + { + get + { + if (!target) + { + serializedObject.Update(); + InternalSetTargets(serializedObject.targetObjects); + } + return base.targetTitle; + } + } + + public override GUIContent GetPreviewTitle() + { + return GUIContent.Temp(targetTitle); + } + } +} diff --git a/Editor/Mono/InternalEditorUtility.bindings.cs b/Editor/Mono/InternalEditorUtility.bindings.cs index 914043295b..0317e34c5d 100644 --- a/Editor/Mono/InternalEditorUtility.bindings.cs +++ b/Editor/Mono/InternalEditorUtility.bindings.cs @@ -450,6 +450,9 @@ public static Version GetUnityVersion() [FreeFunction("InternalEditorUtilityBindings::ReadScreenPixel")] extern public static Color[] ReadScreenPixel(Vector2 pixelPos, int sizex, int sizey); + [FreeFunction("InternalEditorUtilityBindings::ReadScreenPixelUnderCursor")] + extern public static Color[] ReadScreenPixelUnderCursor(Vector2 cursorPosHint, int sizex, int sizey); + [StaticAccessor("GetGpuDeviceManager()", StaticAccessorType.Dot)] [NativeMethod("SetDevice")] extern public static void SetGpuDeviceAndRecreateGraphics(int index, string name); diff --git a/Editor/Mono/LookDevView/CameraControllerStandard.cs b/Editor/Mono/LookDevView/CameraControllerStandard.cs index f0ed1eadf4..d33b9cf0a3 100644 --- a/Editor/Mono/LookDevView/CameraControllerStandard.cs +++ b/Editor/Mono/LookDevView/CameraControllerStandard.cs @@ -192,7 +192,7 @@ public override void Update(CameraState cameraState, Camera cam, EditorWindow wi } var id = GUIUtility.GetControlID(FocusType.Passive); - using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(m_CameraFlyModeContext, id)) + using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(m_CameraFlyModeContext, m_CurrentViewTool, id)) { if (inputSamplingScope.inputVectorChanged) m_FlySpeed = 0; @@ -217,11 +217,6 @@ public override void Update(CameraState cameraState, Camera cam, EditorWindow wi } } - public void ActivateFlyModeContext() - { - ShortcutIntegration.instance.contextManager.SetPriorityContext(m_CameraFlyModeContext); - } - public void DeactivateFlyModeContext() { ShortcutIntegration.instance.contextManager.ClearPriorityContext(); diff --git a/Editor/Mono/LookDevView/LookDevView.cs b/Editor/Mono/LookDevView/LookDevView.cs index 5119791451..f0dec38134 100644 --- a/Editor/Mono/LookDevView/LookDevView.cs +++ b/Editor/Mono/LookDevView/LookDevView.cs @@ -14,6 +14,18 @@ namespace UnityEditor [EditorWindowTitle(title = "Look Dev", useTypeNameAsIconName = true)] internal class LookDevView : EditorWindow, IHasCustomMenu { + internal class TestUtility + { + public TestUtility(LookDevView lookDevView) + { + this.lookDevView = lookDevView; + } + + public readonly LookDevView lookDevView; + + public Camera camera => lookDevView.m_PreviewUtilityContexts[lookDevView.m_LookDevConfig.currentEditionContextIndex].m_PreviewUtility[0].camera; + } + static readonly Vector2 s_MinWindowSize = new Vector2(300, 60); // Note: Color init in OnEnable @@ -279,8 +291,6 @@ private void Initialize() { m_LookDevEnvWindow = new LookDevEnvironmentWindow(this); } - - m_CameraController.ActivateFlyModeContext(); } void InitializePreviewUtilities() diff --git a/Editor/Mono/ObjectSelector.cs b/Editor/Mono/ObjectSelector.cs index 84bc5d1b0c..a506e715e4 100644 --- a/Editor/Mono/ObjectSelector.cs +++ b/Editor/Mono/ObjectSelector.cs @@ -259,6 +259,12 @@ void FilterSettingsChanged() filter.scenePaths = new[] { scene.path }; } + // For now, we don t want to display assets from Packages + // Make sure we only search in Assets folder + if (hierarchyType == HierarchyType.Assets) + { + filter.searchArea = SearchFilter.SearchArea.InAssetsOnly; + } m_ListArea.Init(listPosition, hierarchyType, filter, true); } diff --git a/Editor/Mono/PlayerSettingsSwitch.bindings.cs b/Editor/Mono/PlayerSettingsSwitch.bindings.cs new file mode 100644 index 0000000000..af8fe89ceb --- /dev/null +++ b/Editor/Mono/PlayerSettingsSwitch.bindings.cs @@ -0,0 +1,35 @@ +// Unity C# reference source +// Copyright (c) Unity Technologies. For terms of use, see +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License + +using UnityEngine; +using UnityEngine.Bindings; +using System; +using System.Linq; +using System.Text.RegularExpressions; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.IO; + +namespace UnityEditor +{ + // Player Settings is where you define various parameters for the final game that you will build in Unity. Some of these values are used in the Resolution Dialog that launches when you open a standalone game. + public sealed partial class PlayerSettings + { + // Nintendo Switch specific player settings + [NativeHeader("Runtime/Misc/PlayerSettings.h")] + [StaticAccessor("GetPlayerSettings().GetEditorOnlyForUpdate()", StaticAccessorType.Dot)] + public sealed partial class Switch + { + [NativeProperty("switchNativeFsCacheSize", TargetType.Field)] + extern public static int nativeFsCacheSize { get; set; } + + [NativeProperty("switchIsHoldTypeHorizontal", TargetType.Field)] + extern public static bool isHoldTypeHorizontal { get; set; } + + [NativeProperty("switchSupportedNpadCount", TargetType.Field)] + extern public static int supportedNpadCount { get; set; } + } + } +} diff --git a/Editor/Mono/ProjectBrowser.cs b/Editor/Mono/ProjectBrowser.cs index b57125f4e5..3848991dae 100644 --- a/Editor/Mono/ProjectBrowser.cs +++ b/Editor/Mono/ProjectBrowser.cs @@ -48,6 +48,8 @@ public enum SearchViewState { NotSearching, AllAssets, + InAssetsOnly, + InPackagesOnly, SubFolders, AssetStore } @@ -116,7 +118,7 @@ internal bool isLocked bool m_DidSelectSearchResult = false; bool m_ItemSelectedByRightClickThisEvent = false; bool m_InternalSelectionChange = false; // to know when selection change originated in project view itself - SearchFilter.SearchArea m_LastLocalAssetsSearchArea = SearchFilter.SearchArea.AllAssets; + SearchFilter.SearchArea m_LastLocalAssetsSearchArea = SearchFilter.SearchArea.InAssetsOnly; PopupList.InputData m_AssetLabels; PopupList.InputData m_ObjectTypes; bool m_UseTreeViewSelectionInsteadOfMainSelection; @@ -176,7 +178,11 @@ bool useTreeViewSelectionInsteadOfMainSelection // Used by search menu bar [NonSerialized] - public GUIContent m_SearchAllAssets = EditorGUIUtility.TrTextContent("All Assets"); // do not localize this: Assets=folder name + public GUIContent m_SearchAllAssets = EditorGUIUtility.TrTextContent("All"); + [NonSerialized] + public GUIContent m_SearchInPackagesOnly = EditorGUIUtility.TrTextContent("In Packages"); + [NonSerialized] + public GUIContent m_SearchInAssetsOnly = EditorGUIUtility.TrTextContent("In Assets"); [NonSerialized] public GUIContent m_SearchInFolders = new GUIContent(""); // updated when needed [NonSerialized] @@ -470,6 +476,12 @@ void SetSearchViewState(SearchViewState state) case SearchViewState.AllAssets: m_SearchFilter.searchArea = SearchFilter.SearchArea.AllAssets; break; + case SearchViewState.InAssetsOnly: + m_SearchFilter.searchArea = SearchFilter.SearchArea.InAssetsOnly; + break; + case SearchViewState.InPackagesOnly: + m_SearchFilter.searchArea = SearchFilter.SearchArea.InPackagesOnly; + break; case SearchViewState.SubFolders: m_SearchFilter.searchArea = SearchFilter.SearchArea.SelectedFolders; break; @@ -490,9 +502,11 @@ SearchViewState GetSearchViewState() { switch (m_SearchFilter.GetState()) { - case SearchFilter.State.SearchingInAllAssets: return SearchViewState.AllAssets; - case SearchFilter.State.SearchingInFolders: return SearchViewState.SubFolders; - case SearchFilter.State.SearchingInAssetStore: return SearchViewState.AssetStore; + case SearchFilter.State.SearchingInAllAssets: return SearchViewState.AllAssets; + case SearchFilter.State.SearchingInAssetsOnly: return SearchViewState.InAssetsOnly; + case SearchFilter.State.SearchingInPackagesOnly: return SearchViewState.InPackagesOnly; + case SearchFilter.State.SearchingInFolders: return SearchViewState.SubFolders; + case SearchFilter.State.SearchingInAssetStore: return SearchViewState.AssetStore; } return SearchViewState.NotSearching; } @@ -503,7 +517,10 @@ void SearchButtonClickedCallback(ExposablePopupMenu.ItemData itemClicked) { SetSearchViewState((SearchViewState)itemClicked.m_UserData); - if (m_SearchFilter.searchArea == SearchFilter.SearchArea.AllAssets || m_SearchFilter.searchArea == SearchFilter.SearchArea.SelectedFolders) + if (m_SearchFilter.searchArea == SearchFilter.SearchArea.AllAssets || + m_SearchFilter.searchArea == SearchFilter.SearchArea.InAssetsOnly || + m_SearchFilter.searchArea == SearchFilter.SearchArea.InPackagesOnly || + m_SearchFilter.searchArea == SearchFilter.SearchArea.SelectedFolders) m_LastLocalAssetsSearchArea = m_SearchFilter.searchArea; } } @@ -523,6 +540,10 @@ void InitSearchMenu() bool on = state == SearchViewState.AllAssets; buttonData.Add(new ExposablePopupMenu.ItemData(m_SearchAllAssets, on ? onStyle : offStyle, on, true, (int)SearchViewState.AllAssets)); + on = state == SearchViewState.InPackagesOnly; + buttonData.Add(new ExposablePopupMenu.ItemData(m_SearchInPackagesOnly, on ? onStyle : offStyle, on, true, (int)SearchViewState.InPackagesOnly)); + on = state == SearchViewState.InAssetsOnly; + buttonData.Add(new ExposablePopupMenu.ItemData(m_SearchInAssetsOnly, on ? onStyle : offStyle, on, true, (int)SearchViewState.InAssetsOnly)); on = state == SearchViewState.SubFolders; buttonData.Add(new ExposablePopupMenu.ItemData(m_SearchInFolders, on ? onStyle : offStyle, on, hasFolderSelected, (int)SearchViewState.SubFolders)); on = state == SearchViewState.AssetStore; @@ -534,6 +555,12 @@ void InitSearchMenu() case SearchViewState.AllAssets: popupButtonContent = m_SearchAllAssets; break; + case SearchViewState.InPackagesOnly: + popupButtonContent = m_SearchInPackagesOnly; + break; + case SearchViewState.InAssetsOnly: + popupButtonContent = m_SearchInAssetsOnly; + break; case SearchViewState.SubFolders: popupButtonContent = m_SearchInFolders; break; @@ -1354,6 +1381,8 @@ void ShowAndHideFolderTreeSelectionAsNeeded() switch (state) { case SearchViewState.AllAssets: + case SearchViewState.InAssetsOnly: + case SearchViewState.InPackagesOnly: case SearchViewState.AssetStore: { if (!isSavedFilterSelected) @@ -1459,6 +1488,15 @@ static void DeleteFilter(int filterInstanceID) } } + [UsedByNativeCode] + internal static string GetSelectedPath() + { + if (s_LastInteractedProjectBrowser == null) + return string.Empty; + + return s_LastInteractedProjectBrowser.m_SelectedPath; + } + // Also called from C++ (used for AssetsMenu check if selection is Packages folder) [UsedByNativeCode] internal static bool SelectionIsPackagesRootFolder() @@ -1697,18 +1735,7 @@ void RefreshSplittedSelectedPath() else { string displayPath = m_SelectedPath; - string rootPath = "Assets/"; - if (m_SelectedPath.StartsWith(rootPath, StringComparison.CurrentCultureIgnoreCase)) - displayPath = m_SelectedPath.Substring(rootPath.Length); - else if (m_SelectedPath.StartsWith(PackageManager.Folders.GetPackagesMountPoint() + "/", StringComparison.CurrentCultureIgnoreCase)) - { - rootPath = PackageManager.Folders.GetPackagesMountPoint() + "/"; - var packageInfo = PackageManager.Packages.GetForAssetPath(m_SelectedPath); - if (packageInfo != null && !string.IsNullOrEmpty(packageInfo.displayName)) - displayPath = Regex.Replace(m_SelectedPath, @"^" + packageInfo.assetPath, packageInfo.displayName); - else - displayPath = m_SelectedPath.Substring(rootPath.Length); - } + var rootPath = string.Empty; if (m_SearchFilter.GetState() == SearchFilter.State.FolderBrowsing) { @@ -1732,13 +1759,14 @@ void RefreshSplittedSelectedPath() m_SelectedPathSplitted.Reverse (); */ - string[] split = displayPath.Split('/'); - string[] splitPath = m_SelectedPath.Split('/'); - string curPath = rootPath; - for (int i = 0, j = 1; i < split.Length; ++i, ++j) + var split = displayPath.Split('/'); + var splitPath = m_SelectedPath.Split('/'); + var curPath = rootPath; + var j = string.IsNullOrEmpty(rootPath) ? 0 : 1; + for (var i = 0; i < split.Length; ++i, ++j) { curPath += splitPath[j]; - Texture icon = AssetDatabase.GetCachedIcon(curPath); + var icon = AssetDatabase.GetCachedIcon(curPath); m_SelectedPathSplitted.Add(new GUIContent(split[i], icon)); curPath += "/"; diff --git a/Editor/Mono/ProjectBrowser/SavedSearchFilter.cs b/Editor/Mono/ProjectBrowser/SavedSearchFilter.cs index 7e3a610641..7d35db412b 100644 --- a/Editor/Mono/ProjectBrowser/SavedSearchFilter.cs +++ b/Editor/Mono/ProjectBrowser/SavedSearchFilter.cs @@ -309,6 +309,8 @@ int Add(string displayName, SearchFilter filter, float previewSize, int insertAf // Clear unused data before saving if (filterCopy.GetState() == SearchFilter.State.SearchingInAllAssets || + filterCopy.GetState() == SearchFilter.State.SearchingInAssetsOnly || + filterCopy.GetState() == SearchFilter.State.SearchingInPackagesOnly || filterCopy.GetState() == SearchFilter.State.SearchingInAssetStore) { filterCopy.folders = new string[0]; diff --git a/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs b/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs index c9a02e44eb..66f65f7bbc 100644 --- a/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs +++ b/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs @@ -174,7 +174,7 @@ void CopyPropertyData(ref FilterResult result, HierarchyProperty property) result.icon = null; } - void SearchAllAssets() + void SearchAllAssets(SearchFilter.SearchArea area) { const int k_MaxAddCount = 3000; if (m_HierarchyType == HierarchyType.Assets) @@ -183,6 +183,7 @@ void SearchAllAssets() list.AddRange(m_Results); var maxAddCount = k_MaxAddCount; + m_SearchFilter.searchArea = area; var enumerator = AssetDatabase.EnumerateAllAssets(m_SearchFilter); while (enumerator.MoveNext() && --maxAddCount >= 0) { @@ -230,6 +231,7 @@ void SearchInFolders() } } + m_SearchFilter.searchArea = SearchFilter.SearchArea.SelectedFolders; foreach (string folderPath in baseFolders) { // Ensure we do not have a filter when finding folder @@ -308,9 +310,11 @@ void AddResults() { switch (m_SearchFilter.GetState()) { - case SearchFilter.State.FolderBrowsing: FolderBrowsing(); break; - case SearchFilter.State.SearchingInAllAssets: SearchAllAssets(); break; - case SearchFilter.State.SearchingInFolders: SearchInFolders(); break; + case SearchFilter.State.FolderBrowsing: FolderBrowsing(); break; + case SearchFilter.State.SearchingInAllAssets: SearchAllAssets(SearchFilter.SearchArea.AllAssets); break; + case SearchFilter.State.SearchingInAssetsOnly: SearchAllAssets(SearchFilter.SearchArea.InAssetsOnly); break; + case SearchFilter.State.SearchingInPackagesOnly: SearchAllAssets(SearchFilter.SearchArea.InPackagesOnly); break; + case SearchFilter.State.SearchingInFolders: SearchInFolders(); break; case SearchFilter.State.SearchingInAssetStore: /*do nothing*/ break; case SearchFilter.State.EmptySearchFilter: /*do nothing*/ break; default: Debug.LogError("Unhandled enum!"); break; diff --git a/Editor/Mono/ProjectWindow/SearchFilter.cs b/Editor/Mono/ProjectWindow/SearchFilter.cs index 47ae8995fb..67f71eb66b 100644 --- a/Editor/Mono/ProjectWindow/SearchFilter.cs +++ b/Editor/Mono/ProjectWindow/SearchFilter.cs @@ -16,6 +16,8 @@ internal class SearchFilter public enum SearchArea { AllAssets, + InAssetsOnly, + InPackagesOnly, SelectedFolders, AssetStore } @@ -25,6 +27,8 @@ public enum State EmptySearchFilter, FolderBrowsing, SearchingInAllAssets, + SearchingInAssetsOnly, + SearchingInPackagesOnly, SearchingInFolders, SearchingInAssetStore } @@ -49,8 +53,7 @@ public enum State [SerializeField] private bool m_ShowAllHits = false; // If true then just one filter must match to show an object, if false then all filters must match to show an object [SerializeField] - SearchArea m_SearchArea = SearchArea.AllAssets; - + SearchArea m_SearchArea = SearchArea.InAssetsOnly; // Folder browsing [SerializeField] private string[] m_Folders = new string[0]; @@ -108,6 +111,12 @@ public State GetState() if (foldersActive && m_SearchArea == SearchArea.SelectedFolders) return State.SearchingInFolders; + if (m_SearchArea == SearchArea.InAssetsOnly) + return State.SearchingInAssetsOnly; + + if (m_SearchArea == SearchArea.InPackagesOnly) + return State.SearchingInPackagesOnly; + return State.SearchingInAllAssets; } else if (foldersActive) @@ -121,7 +130,11 @@ public State GetState() public bool IsSearching() { State state = GetState(); - return (state == State.SearchingInAllAssets || state == State.SearchingInFolders || state == State.SearchingInAssetStore); + return (state == State.SearchingInAllAssets || + state == State.SearchingInAssetsOnly || + state == State.SearchingInPackagesOnly || + state == State.SearchingInFolders || + state == State.SearchingInAssetStore); } public bool SetNewFilter(SearchFilter newFilter) diff --git a/Editor/Mono/SceneView/CameraFlyModeContext.cs b/Editor/Mono/SceneView/CameraFlyModeContext.cs index cc1b93075c..c361e456fc 100644 --- a/Editor/Mono/SceneView/CameraFlyModeContext.cs +++ b/Editor/Mono/SceneView/CameraFlyModeContext.cs @@ -28,14 +28,22 @@ public struct InputSamplingScope : IDisposable // controlID will get hotControl if using arrow keys while shortcut context is not active // passing a value of zero disables the arrow keys - public InputSamplingScope(CameraFlyModeContext context, int controlID, bool orthographic = false) + public InputSamplingScope(CameraFlyModeContext context, ViewTool currentViewTool, int controlID, bool orthographic = false) { m_ArrowKeysActive = false; m_Disposed = false; m_Context = context; + m_Context.active = currentViewTool == ViewTool.FPS; - if (!context.active) + if (m_Context.active) + { + ShortcutIntegration.instance.contextManager.SetPriorityContext(context); + } + else + { + ShortcutIntegration.instance.contextManager.ClearPriorityContext(); m_ArrowKeysActive = DoArrowKeys(controlID, orthographic); + } if (currentlyMoving && Mathf.Approximately(m_Context.m_PreviousVector.sqrMagnitude, 0f)) s_Timer.Begin(); @@ -93,7 +101,7 @@ bool DoArrowKeys(int id, bool orthographic) } } - public bool active => Tools.viewTool == ViewTool.FPS; + public bool active { get; set; } Vector3 m_PreviousVector; diff --git a/Editor/Mono/SceneView/SceneView.cs b/Editor/Mono/SceneView/SceneView.cs index 0d8ed6bbbd..9cc74db960 100644 --- a/Editor/Mono/SceneView/SceneView.cs +++ b/Editor/Mono/SceneView/SceneView.cs @@ -532,8 +532,6 @@ override public void OnEnable() if (m_CameraMode.drawMode == DrawCameraMode.UserDefined && !s_UserDefinedModes.Contains(m_CameraMode)) AddCameraMode(m_CameraMode.name, m_CameraMode.section); - SceneViewMotion.ActivateFlyModeContext(); - base.OnEnable(); } diff --git a/Editor/Mono/SceneView/SceneViewMotion.cs b/Editor/Mono/SceneView/SceneViewMotion.cs index d441b4e234..98a0dbf309 100644 --- a/Editor/Mono/SceneView/SceneViewMotion.cs +++ b/Editor/Mono/SceneView/SceneViewMotion.cs @@ -44,7 +44,7 @@ public static void DoViewTool(SceneView view) view.FixNegativeSize(); } - using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(s_CameraFlyModeContext, id, view.orthographic)) + using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(s_CameraFlyModeContext, Tools.s_LockedViewTool, id, view.orthographic)) { if (inputSamplingScope.currentlyMoving) view.viewIsLockedToObject = false; @@ -382,11 +382,6 @@ public static void ResetMotion() s_Motion = Vector3.zero; } - public static void ActivateFlyModeContext() - { - ShortcutIntegration.instance.contextManager.SetPriorityContext(s_CameraFlyModeContext); - } - public static void DeactivateFlyModeContext() { ShortcutIntegration.instance.contextManager.ClearPriorityContext(); diff --git a/Editor/Mono/Scripting/Compilers/APIUpdater.cs b/Editor/Mono/Scripting/Compilers/APIUpdater.cs index 22d268f93c..72f0030d8a 100644 --- a/Editor/Mono/Scripting/Compilers/APIUpdater.cs +++ b/Editor/Mono/Scripting/Compilers/APIUpdater.cs @@ -90,11 +90,13 @@ private static void UpdateFilesInVCIfNeeded() // Provider.GetAssetByPath() can fail i.e. the asset database GUID can not be found for the input asset path foreach (var f in files) { - var assetPath = f.Replace(tempOutputPath, ""); + var rawAssetPath = f.Replace(tempOutputPath, ""); + // VCS assets path separator is '/' , file path might be '\' or '/' + var assetPath = (Path.DirectorySeparatorChar == '\\') ? rawAssetPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) : rawAssetPath; var foundAsset = assetList.Where(asset => (asset.path == assetPath)); if (!foundAsset.Any()) { - Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to add file to list): {0}", assetPath); + Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to add file to list): {0}", rawAssetPath); ScriptUpdatingManager.ReportExpectedUpdateFailure(); return; } diff --git a/Editor/Mono/Scripting/ScriptCompilation/EditorBuildRules.cs b/Editor/Mono/Scripting/ScriptCompilation/EditorBuildRules.cs index c678da6663..6ed4b451fc 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/EditorBuildRules.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/EditorBuildRules.cs @@ -8,6 +8,7 @@ using UnityEditor.Compilation; using UnityEditor.Scripting.Compilers; using File = System.IO.File; +using UnityEditor.Utils; namespace UnityEditor.Scripting.ScriptCompilation { @@ -721,7 +722,7 @@ internal static TargetAssembly GetPredefinedTargetAssembly(string scriptPath) TargetAssembly resultAssembly = null; var extension = AssetPath.GetExtension(scriptPath).Substring(1).ToLower(); - var lowerPath = "/" + scriptPath.ToLower(); + var lowerPath = ("/" + scriptPath.ToLower()).ConvertSeparatorsToUnity(); int highestPathDepth = -1; foreach (var assembly in predefinedTargetAssemblies) diff --git a/Editor/Mono/SearchUtility.cs b/Editor/Mono/SearchUtility.cs index 094846680c..9b36997ade 100644 --- a/Editor/Mono/SearchUtility.cs +++ b/Editor/Mono/SearchUtility.cs @@ -23,6 +23,7 @@ private static void RemoveUnwantedWhitespaces(ref string searchString) // 'ref[:id]:path' syntax (e.g 'ref:1234' will show objects that references the object with instanceID 1234) // 'v:versionState' syntax (e.g 'v:modified' will show objects that are modified locally) // 's:softLockState' syntax (e.g 's:inprogress' will show objects that are modified by anyone (except you)) + // 'a:area' syntax (e.g 'a:all' will s search in all assets, 'a:assets' will s search in assets folder only and 'a:packages' will s search in packages folder only) internal static bool ParseSearchString(string searchText, SearchFilter filter) { if (string.IsNullOrEmpty(searchText)) @@ -124,6 +125,28 @@ internal static bool CheckForKeyWords(string searchString, SearchFilter filter, parsed = true; } + // Support: 'a:area' syntax + index = searchString.IndexOf("a:"); + if (index >= 0) + { + string areaString = searchString.Substring(index + 2); + if (string.Compare(areaString, "all", true) == 0) + { + filter.searchArea = SearchFilter.SearchArea.AllAssets; + parsed = true; + } + else if (string.Compare(areaString, "assets", true) == 0) + { + filter.searchArea = SearchFilter.SearchArea.InAssetsOnly; + parsed = true; + } + else if (string.Compare(areaString, "packages", true) == 0) + { + filter.searchArea = SearchFilter.SearchArea.InPackagesOnly; + parsed = true; + } + } + // Support: 'b:assetBundleName' syntax (e.g 'b:materialAssetBundle' will show assets within assetBundle 'materialAssetBundle') index = searchString.IndexOf("b:"); if (index == 0) diff --git a/Editor/Mono/SpriteEditor/SpriteEditorMenu.cs b/Editor/Mono/SpriteEditor/SpriteEditorMenu.cs index 47873aa173..adfc2b9e12 100644 --- a/Editor/Mono/SpriteEditor/SpriteEditorMenu.cs +++ b/Editor/Mono/SpriteEditor/SpriteEditorMenu.cs @@ -199,12 +199,10 @@ private void DoSlicing() private void DoAnalytics() { UsabilityAnalytics.Event("Sprite Editor", "Slice", "Type", (int)s_Setting.slicingType); - var texture = m_TextureDataProvider.texture; - if (texture != null) - { - UsabilityAnalytics.Event("Sprite Editor", "Slice", "Texture Width", texture.width); - UsabilityAnalytics.Event("Sprite Editor", "Slice", "Texture Height", texture.height); - } + int width, height; + m_TextureDataProvider.GetTextureActualWidthAndHeight(out width, out height); + UsabilityAnalytics.Event("Sprite Editor", "Slice", "Texture Width", width); + UsabilityAnalytics.Event("Sprite Editor", "Slice", "Texture Height", height); if (s_Setting.slicingType == SpriteEditorMenuSetting.SlicingType.Automatic) { @@ -254,7 +252,7 @@ private void OnGridGUI() { int width, height; m_TextureDataProvider.GetTextureActualWidthAndHeight(out width, out height); - var texture = m_TextureDataProvider.texture; + var texture = m_TextureDataProvider.GetReadableTexture2D(); int maxWidth = texture != null ? width : 4096; int maxHeight = texture != null ? height : 4096; @@ -327,7 +325,7 @@ private void OnGridGUI() private void OnAutomaticGUI() { float spacing = 38f; - var texture = m_TextureDataProvider.texture; + var texture = m_TextureDataProvider.GetReadableTexture2D(); if (texture != null && UnityEditor.TextureUtil.IsCompressedTextureFormat(texture.format)) { EditorGUILayout.LabelField(s_Styles.automaticSlicingHintLabel, s_Styles.notice); @@ -391,7 +389,7 @@ private void DetemineGridCellSizeWithCellCount() { int width, height; m_TextureDataProvider.GetTextureActualWidthAndHeight(out width, out height); - var texture = m_TextureDataProvider.texture; + var texture = m_TextureDataProvider.GetReadableTexture2D(); int maxWidth = texture != null ? width : 4096; int maxHeight = texture != null ? height : 4096; diff --git a/Editor/Mono/SpriteEditor/SpriteEditorWindow.cs b/Editor/Mono/SpriteEditor/SpriteEditorWindow.cs index 633acaedf7..be12dcce05 100644 --- a/Editor/Mono/SpriteEditor/SpriteEditorWindow.cs +++ b/Editor/Mono/SpriteEditor/SpriteEditorWindow.cs @@ -114,7 +114,7 @@ public void RefreshPropertiesCache() { int width = 0, height = 0; textureProvider.GetTextureActualWidthAndHeight(out width, out height); - m_Texture = textureProvider.texture == null ? null : new PreviewTexture2D(textureProvider.texture, width, height); + m_Texture = textureProvider.previewTexture == null ? null : new PreviewTexture2D(textureProvider.previewTexture, width, height); } } @@ -850,6 +850,11 @@ public bool editingDisabled get { return EditorApplication.isPlayingOrWillChangePlaymode; } } + public void SetPreviewTexture(UnityTexture2D texture, int width, int height) + { + m_Texture = new PreviewTexture2D(texture, width, height); + } + public void ApplyOrRevertModification(bool apply) { if (apply) diff --git a/Editor/Mono/StyleSheets/StyleSheetEditor.cs b/Editor/Mono/StyleSheets/StyleSheetEditor.cs index e6cf6ece8b..f6a58dcb69 100644 --- a/Editor/Mono/StyleSheets/StyleSheetEditor.cs +++ b/Editor/Mono/StyleSheets/StyleSheetEditor.cs @@ -10,7 +10,7 @@ namespace UnityEditor.StyleSheets { [CustomEditor(typeof(StyleSheet))] - internal class StyleSheetEditor : Editor + internal class StyleSheetEditor : ScriptableObjectAssetEditor { private Texture2D m_FileTypeIcon; diff --git a/Editor/Mono/UIElements/UIElementsViewImporter.cs b/Editor/Mono/UIElements/UIElementsViewImporter.cs index 9b943b7936..a4a2265ba1 100644 --- a/Editor/Mono/UIElements/UIElementsViewImporter.cs +++ b/Editor/Mono/UIElements/UIElementsViewImporter.cs @@ -249,6 +249,10 @@ public override void OnImportAsset(AssetImportContext args) if (!vta.inlineSheet) vta.inlineSheet = ScriptableObject.CreateInstance(); + // Make sure imported objects aren't editable in the Inspector + vta.hideFlags = HideFlags.NotEditable; + vta.inlineSheet.hideFlags = HideFlags.NotEditable; + args.AddObjectToAsset("inlineStyle", vta.inlineSheet); } diff --git a/Editor/Mono/UIElements/VisualTreeAssetEditor.cs b/Editor/Mono/UIElements/VisualTreeAssetEditor.cs index 738589e44e..25133b1eda 100644 --- a/Editor/Mono/UIElements/VisualTreeAssetEditor.cs +++ b/Editor/Mono/UIElements/VisualTreeAssetEditor.cs @@ -11,7 +11,7 @@ namespace UnityEditor.Experimental.UIElements { [CustomEditor(typeof(VisualTreeAsset))] - internal class VisualTreeAssetEditor : Editor + internal class VisualTreeAssetEditor : ScriptableObjectAssetEditor { private Panel m_Panel; private VisualElement m_Tree; @@ -26,20 +26,9 @@ protected void OnEnable() protected void OnDestroy() { m_Panel = null; - UIElementsUtility.RemoveCachedPanel(m_LastTree.GetInstanceID()); - } - - // hack to avoid null references when a scriptedImporter runs and replaces the current selection - internal override string targetTitle - { - get + if (m_LastTree != null) { - if (!target) - { - serializedObject.Update(); - InternalSetTargets(serializedObject.targetObjects); - } - return base.targetTitle; + UIElementsUtility.RemoveCachedPanel(m_LastTree.GetInstanceID()); } } @@ -48,11 +37,6 @@ public override bool HasPreviewGUI() return true; } - public override GUIContent GetPreviewTitle() - { - return GUIContent.Temp(targetTitle); - } - private void RenderIcon(Rect iconRect) { Debug.Assert(m_FileTypeIcon != null); diff --git a/Editor/Mono/VersionControl/Common/VCAssetModificationHooks.cs b/Editor/Mono/VersionControl/Common/VCAssetModificationHooks.cs index 71632b8633..b85cbe6e45 100644 --- a/Editor/Mono/VersionControl/Common/VCAssetModificationHooks.cs +++ b/Editor/Mono/VersionControl/Common/VCAssetModificationHooks.cs @@ -55,22 +55,23 @@ public static AssetMoveResult OnWillMoveAsset(string from, string to) if (asset == null || !asset.IsUnderVersionControl) return AssetMoveResult.DidNotMove; - if (asset.IsState(Asset.States.OutOfSync)) + Asset.States assetState = asset.state; + if (Asset.IsState(assetState, Asset.States.OutOfSync)) { Debug.LogError("Cannot move version controlled file that is not up to date. Please get latest changes from server"); return AssetMoveResult.FailedMove; } - else if (asset.IsState(Asset.States.DeletedRemote)) + else if (Asset.IsState(assetState, Asset.States.DeletedRemote)) { Debug.LogError("Cannot move version controlled file that is deleted on server. Please get latest changes from server"); return AssetMoveResult.FailedMove; } - else if (asset.IsState(Asset.States.CheckedOutRemote)) + else if (Asset.IsState(assetState, Asset.States.CheckedOutRemote)) { Debug.LogError("Cannot move version controlled file that is checked out on server. Please get latest changes from server"); return AssetMoveResult.FailedMove; } - else if (asset.IsState(Asset.States.LockedRemote)) + else if (Asset.IsState(assetState, Asset.States.LockedRemote)) { Debug.LogError("Cannot move version controlled file that is locked on server. Please get latest changes from server"); return AssetMoveResult.FailedMove; diff --git a/Editor/Mono/VersionControl/UI/VCListControl.cs b/Editor/Mono/VersionControl/UI/VCListControl.cs index 8ced2497e6..9ec4ef6378 100644 --- a/Editor/Mono/VersionControl/UI/VCListControl.cs +++ b/Editor/Mono/VersionControl/UI/VCListControl.cs @@ -813,10 +813,20 @@ void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selec if (item.Asset != null) { - Rect overlayRect = iconRect; - overlayRect.width += 12; - overlayRect.x -= 6; - Overlay.DrawOverlay(item.Asset, overlayRect); + bool drawOverlay = true; + string vcsType = EditorSettings.externalVersionControl; + if (vcsType == ExternalVersionControl.Disabled || + vcsType == ExternalVersionControl.AutoDetect || + vcsType == ExternalVersionControl.Generic) + drawOverlay = false; // no overlays for these version control systems + + if (drawOverlay) + { + Rect overlayRect = iconRect; + overlayRect.width += 12; + overlayRect.x -= 6; + Overlay.DrawOverlay(item.Asset, overlayRect); + } } } diff --git a/Editor/Mono/VersionControl/UI/VCOverlay.cs b/Editor/Mono/VersionControl/UI/VCOverlay.cs index cca79a3ed2..8986935db7 100644 --- a/Editor/Mono/VersionControl/UI/VCOverlay.cs +++ b/Editor/Mono/VersionControl/UI/VCOverlay.cs @@ -40,12 +40,6 @@ public static void DrawOverlay(Asset asset, Rect itemRect) if (Event.current.type != EventType.Repaint) return; - string vcsType = EditorSettings.externalVersionControl; - if (vcsType == ExternalVersionControl.Disabled || - vcsType == ExternalVersionControl.AutoDetect || - vcsType == ExternalVersionControl.Generic) - return; // no icons for these version control systems - DrawOverlays(asset, null, itemRect); } @@ -57,12 +51,6 @@ public static void DrawOverlay(Asset asset, Asset metaAsset, Rect itemRect) if (Event.current.type != EventType.Repaint) return; - string vcsType = EditorSettings.externalVersionControl; - if (vcsType == ExternalVersionControl.Disabled || - vcsType == ExternalVersionControl.AutoDetect || - vcsType == ExternalVersionControl.Generic) - return; // no icons for these version control systems - DrawOverlays(asset, metaAsset, itemRect); } @@ -112,16 +100,19 @@ static void DrawOverlays(Asset asset, Asset metaAsset, Rect itemRect) Rect bottomRight = new Rect(itemRect.xMax - iconWidth + offsetX, itemRect.yMax - iconWidth + offsetY, iconWidth, iconWidth); Rect syncRect = new Rect(itemRect.xMax - iconWidth + syncOffsetX, itemRect.yMax - iconWidth + offsetY, iconWidth, iconWidth); + Asset.States assetState = asset.state; + Asset.States metaState = metaAsset != null ? metaAsset.state : Asset.States.None; + Asset.States unmodifiedState = Asset.States.Local | Asset.States.MetaFile | Asset.States.ReadOnly | Asset.States.Synced; - bool isMetaUnmodifiedState = metaAsset == null || (metaAsset.state & unmodifiedState) == unmodifiedState; + bool isMetaUnmodifiedState = metaAsset == null || (metaState & unmodifiedState) == unmodifiedState; - Asset.States localMetaState = metaAsset == null ? Asset.States.None : metaAsset.state & (Asset.States.AddedLocal | Asset.States.CheckedOutLocal | Asset.States.DeletedLocal | Asset.States.LockedLocal); - Asset.States remoteMetaState = metaAsset == null ? Asset.States.None : metaAsset.state & (Asset.States.AddedRemote | Asset.States.CheckedOutRemote | Asset.States.DeletedRemote | Asset.States.LockedRemote); + Asset.States localMetaState = metaAsset == null ? Asset.States.None : metaState & (Asset.States.AddedLocal | Asset.States.CheckedOutLocal | Asset.States.DeletedLocal | Asset.States.LockedLocal); + Asset.States remoteMetaState = metaAsset == null ? Asset.States.None : metaState & (Asset.States.AddedRemote | Asset.States.CheckedOutRemote | Asset.States.DeletedRemote | Asset.States.LockedRemote); bool keepFolderMetaParans = asset.isFolder && Provider.isVersioningFolders; // Local state overlay - if (asset.IsState(Asset.States.AddedLocal)) + if (Asset.IsState(assetState, Asset.States.AddedLocal)) { DrawOverlay(Asset.States.AddedLocal, topLeft); @@ -129,15 +120,15 @@ static void DrawOverlays(Asset asset, Asset metaAsset, Rect itemRect) if (metaAsset != null && (localMetaState & Asset.States.AddedLocal) == 0 && !isMetaUnmodifiedState) DrawMetaOverlay(topLeft, false); } - else if (asset.IsState(Asset.States.DeletedLocal)) + else if (Asset.IsState(assetState, Asset.States.DeletedLocal)) { DrawOverlay(Asset.States.DeletedLocal, topLeft); // Meta overlay if meta file is not deleted but asset is and meta file is still present or missing (ie. should have been there) - if (metaAsset != null && (localMetaState & Asset.States.DeletedLocal) == 0 && metaAsset.IsState(Asset.States.Local | Asset.States.Missing)) + if (metaAsset != null && (localMetaState & Asset.States.DeletedLocal) == 0 && Asset.IsState(metaState, Asset.States.Local | Asset.States.Missing)) DrawMetaOverlay(topLeft, false); } - else if (asset.IsState(Asset.States.LockedLocal)) + else if (Asset.IsState(assetState, Asset.States.LockedLocal)) { DrawOverlay(Asset.States.LockedLocal, topLeft); @@ -145,7 +136,7 @@ static void DrawOverlays(Asset asset, Asset metaAsset, Rect itemRect) if (metaAsset != null && (localMetaState & Asset.States.LockedLocal) == 0 && !isMetaUnmodifiedState) DrawMetaOverlay(topLeft, false); } - else if (asset.IsState(Asset.States.CheckedOutLocal)) + else if (Asset.IsState(assetState, Asset.States.CheckedOutLocal)) { DrawOverlay(Asset.States.CheckedOutLocal, topLeft); @@ -153,55 +144,55 @@ static void DrawOverlays(Asset asset, Asset metaAsset, Rect itemRect) if (metaAsset != null && (localMetaState & Asset.States.CheckedOutLocal) == 0 && !isMetaUnmodifiedState) DrawMetaOverlay(topLeft, false); } - else if (asset.IsState(Asset.States.Local) && !(asset.IsState(Asset.States.OutOfSync) || asset.IsState(Asset.States.Synced))) + else if (Asset.IsState(assetState, Asset.States.Local) && !(Asset.IsState(assetState, Asset.States.OutOfSync) || Asset.IsState(assetState, Asset.States.Synced))) { DrawOverlay(Asset.States.Local, bottomLeft); // Meta overlay if meta file is not local only or unmodified. - if (metaAsset != null && (metaAsset.IsUnderVersionControl || !metaAsset.IsState(Asset.States.Local))) + if (metaAsset != null && (metaAsset.IsUnderVersionControl || !Asset.IsState(metaState, Asset.States.Local))) DrawMetaOverlay(bottomLeft, false); } // From here the local asset have no state that need a local state overlay. We use the meta state if there is one instead. - else if (metaAsset != null && metaAsset.IsState(Asset.States.AddedLocal)) + else if (metaAsset != null && Asset.IsState(metaState, Asset.States.AddedLocal)) { DrawOverlay(Asset.States.AddedLocal, topLeft); if (keepFolderMetaParans) DrawMetaOverlay(topLeft, false); } - else if (metaAsset != null && metaAsset.IsState(Asset.States.DeletedLocal)) + else if (metaAsset != null && Asset.IsState(metaState, Asset.States.DeletedLocal)) { DrawOverlay(Asset.States.DeletedLocal, topLeft); if (keepFolderMetaParans) DrawMetaOverlay(topLeft, false); } - else if (metaAsset != null && metaAsset.IsState(Asset.States.LockedLocal)) + else if (metaAsset != null && Asset.IsState(metaState, Asset.States.LockedLocal)) { DrawOverlay(Asset.States.LockedLocal, topLeft); if (keepFolderMetaParans) DrawMetaOverlay(topLeft, false); } - else if (metaAsset != null && metaAsset.IsState(Asset.States.CheckedOutLocal)) + else if (metaAsset != null && Asset.IsState(metaState, Asset.States.CheckedOutLocal)) { DrawOverlay(Asset.States.CheckedOutLocal, topLeft); if (keepFolderMetaParans) DrawMetaOverlay(topLeft, false); } - else if (metaAsset != null && metaAsset.IsState(Asset.States.Local) && !(metaAsset.IsState(Asset.States.OutOfSync) || metaAsset.IsState(Asset.States.Synced)) - && !(asset.IsState(Asset.States.Conflicted) || (metaAsset != null && metaAsset.IsState(Asset.States.Conflicted)))) + else if (metaAsset != null && Asset.IsState(metaState, Asset.States.Local) && !(Asset.IsState(metaState, Asset.States.OutOfSync) || Asset.IsState(metaState, Asset.States.Synced)) + && !(Asset.IsState(assetState, Asset.States.Conflicted) || (metaAsset != null && Asset.IsState(metaState, Asset.States.Conflicted)))) { DrawOverlay(Asset.States.Local, bottomLeft); if (keepFolderMetaParans) DrawMetaOverlay(bottomLeft, false); } - if (asset.IsState(Asset.States.Conflicted) || (metaAsset != null && metaAsset.IsState(Asset.States.Conflicted))) + if (Asset.IsState(assetState, Asset.States.Conflicted) || (metaAsset != null && Asset.IsState(metaState, Asset.States.Conflicted))) DrawOverlay(Asset.States.Conflicted, bottomLeft); - if ((asset.isFolder == false && asset.IsState(Asset.States.Updating)) || (metaAsset != null && metaAsset.IsState(Asset.States.Updating))) + if ((asset.isFolder == false && Asset.IsState(assetState, Asset.States.Updating)) || (metaAsset != null && Asset.IsState(metaState, Asset.States.Updating))) DrawOverlay(Asset.States.Updating, bottomRight); // Remote state overlay - if (asset.IsState(Asset.States.AddedRemote)) + if (Asset.IsState(assetState, Asset.States.AddedRemote)) { DrawOverlay(Asset.States.AddedRemote, topRight); @@ -209,7 +200,7 @@ static void DrawOverlays(Asset asset, Asset metaAsset, Rect itemRect) if (metaAsset != null && (remoteMetaState & Asset.States.AddedRemote) == 0) DrawMetaOverlay(topRight, true); } - else if (asset.IsState(Asset.States.DeletedRemote)) + else if (Asset.IsState(assetState, Asset.States.DeletedRemote)) { DrawOverlay(Asset.States.DeletedRemote, topRight); @@ -217,7 +208,7 @@ static void DrawOverlays(Asset asset, Asset metaAsset, Rect itemRect) if (metaAsset != null && (remoteMetaState & Asset.States.DeletedRemote) == 0) DrawMetaOverlay(topRight, true); } - else if (asset.IsState(Asset.States.LockedRemote)) + else if (Asset.IsState(assetState, Asset.States.LockedRemote)) { DrawOverlay(Asset.States.LockedRemote, topRight); @@ -225,7 +216,7 @@ static void DrawOverlays(Asset asset, Asset metaAsset, Rect itemRect) if (metaAsset != null && (remoteMetaState & Asset.States.LockedRemote) == 0) DrawMetaOverlay(topRight, true); } - else if (asset.IsState(Asset.States.CheckedOutRemote)) + else if (Asset.IsState(assetState, Asset.States.CheckedOutRemote)) { DrawOverlay(Asset.States.CheckedOutRemote, topRight); @@ -234,32 +225,32 @@ static void DrawOverlays(Asset asset, Asset metaAsset, Rect itemRect) DrawMetaOverlay(topRight, true); } // From here the remote asset have no state that need a remote state overlay. We use the meta state if there is one instead. - else if (metaAsset != null && metaAsset.IsState(Asset.States.AddedRemote)) + else if (metaAsset != null && Asset.IsState(metaState, Asset.States.AddedRemote)) { DrawOverlay(Asset.States.AddedRemote, topRight); if (keepFolderMetaParans) DrawMetaOverlay(topRight, true); } - else if (metaAsset != null && metaAsset.IsState(Asset.States.DeletedRemote)) + else if (metaAsset != null && Asset.IsState(metaState, Asset.States.DeletedRemote)) { DrawOverlay(Asset.States.DeletedRemote, topRight); if (keepFolderMetaParans) DrawMetaOverlay(topRight, true); } - else if (metaAsset != null && metaAsset.IsState(Asset.States.LockedRemote)) + else if (metaAsset != null && Asset.IsState(metaState, Asset.States.LockedRemote)) { DrawOverlay(Asset.States.LockedRemote, topRight); if (keepFolderMetaParans) DrawMetaOverlay(topRight, true); } - else if (metaAsset != null && metaAsset.IsState(Asset.States.CheckedOutRemote)) + else if (metaAsset != null && Asset.IsState(metaState, Asset.States.CheckedOutRemote)) { DrawOverlay(Asset.States.CheckedOutRemote, topRight); if (keepFolderMetaParans) DrawMetaOverlay(topRight, true); } - if (asset.IsState(Asset.States.OutOfSync) || (metaAsset != null && metaAsset.IsState(Asset.States.OutOfSync))) + if (Asset.IsState(assetState, Asset.States.OutOfSync) || (metaAsset != null && Asset.IsState(metaState, Asset.States.OutOfSync))) DrawOverlay(Asset.States.OutOfSync, syncRect); } diff --git a/Editor/Mono/VersionControl/UI/VCProjectHooks.cs b/Editor/Mono/VersionControl/UI/VCProjectHooks.cs index 5618ac6f9a..49fa612e62 100644 --- a/Editor/Mono/VersionControl/UI/VCProjectHooks.cs +++ b/Editor/Mono/VersionControl/UI/VCProjectHooks.cs @@ -4,6 +4,7 @@ using UnityEngine; using UnityEditor.VersionControl; +using UnityEditor; namespace UnityEditorInternal.VersionControl { @@ -16,6 +17,12 @@ public static void OnProjectWindowItem(string guid, Rect drawRect) if (!Provider.isActive) return; + string vcsType = EditorSettings.externalVersionControl; + if (vcsType == ExternalVersionControl.Disabled || + vcsType == ExternalVersionControl.AutoDetect || + vcsType == ExternalVersionControl.Generic) + return; // no icons for these version control systems + Asset asset = Provider.GetAssetByGUID(guid); if (asset != null) { diff --git a/Editor/Mono/VisualStudioIntegration/SolutionSynchronizationSettings.cs b/Editor/Mono/VisualStudioIntegration/SolutionSynchronizationSettings.cs index 251006e60d..bc4f437502 100644 --- a/Editor/Mono/VisualStudioIntegration/SolutionSynchronizationSettings.cs +++ b/Editor/Mono/VisualStudioIntegration/SolutionSynchronizationSettings.cs @@ -134,6 +134,8 @@ public virtual string GetProjectHeaderTemplate(ScriptingLanguage language) @" true", @" true", @" false", + @" false", + @" false", @" ", }; diff --git a/Modules/GraphViewEditor/Elements/Node.cs b/Modules/GraphViewEditor/Elements/Node.cs index d86e029b5d..8425984adf 100644 --- a/Modules/GraphViewEditor/Elements/Node.cs +++ b/Modules/GraphViewEditor/Elements/Node.cs @@ -321,6 +321,11 @@ public Node(string uiFile) { borderContainer.clippingOptions = ClippingOptions.ClipAndCacheContents; mainContainer = borderContainer; + var selection = main.Q(name: "selection-border"); + if (selection != null) + { + selection.clippingOptions = ClippingOptions.NoClipping; //fixes issues with selection border being clipped when zooming out + } } else { diff --git a/Modules/IMGUI/GUIUtility.bindings.cs b/Modules/IMGUI/GUIUtility.bindings.cs index 1b5dfb5809..6cd6ba969e 100644 --- a/Modules/IMGUI/GUIUtility.bindings.cs +++ b/Modules/IMGUI/GUIUtility.bindings.cs @@ -8,6 +8,7 @@ namespace UnityEngine { // Utility class for making new GUI controls. [NativeHeader("Modules/IMGUI/GUIUtility.h"), + NativeHeader("Modules/IMGUI/GUIManager.h"), NativeHeader("Runtime/Input/InputManager.h"), NativeHeader("Runtime/Utilities/CopyPaste.h"), NativeHeader("Runtime/Camera/RenderLayers/GUITexture.h")] @@ -22,6 +23,14 @@ public partial class GUIUtility [NativeProperty("GetGUIState().m_OnGUIDepth", true, TargetType.Field)] internal static extern int guiDepth {[VisibleToOtherModules("UnityEngine.UIElementsModule")] get; } + internal static extern Vector2 s_EditorScreenPointOffset + { + [NativeMethod("GetGUIManager().GetGUIPixelOffset", true)] + get; + [NativeMethod("GetGUIManager().SetGUIPixelOffset", true)] + set; + } + [NativeProperty("GetGUIState().m_CanvasGUIState.m_IsMouseUsed", true, TargetType.Field)] internal static extern bool mouseUsed { get; set; } @@ -71,17 +80,12 @@ public static extern string systemCopyBuffer [VisibleToOtherModules("UnityEngine.UIElementsModule")] internal static extern bool HasFocusableControls(); - [VisibleToOtherModules("UnityEngine.UIElementsModule")] - internal static extern Rect Internal_AlignRectToDevice(Rect rect, Matrix4x4 transform); + public static extern Rect AlignRectToDevice(Rect rect, out int widthInPixels, out int heightInPixels); // This is used in sensitive alignment-related operations. Avoid calling this method if you can. [VisibleToOtherModules("UnityEngine.UIElementsModule")] internal static extern Vector3 Internal_MultiplyPoint(Vector3 point, Matrix4x4 transform); - // This is used in sensitive alignment-related operations. Avoid calling this method if you can. - [VisibleToOtherModules("UnityEngine.UIElementsModule")] - internal static extern float Internal_Roundf(float f); - internal static extern bool GetChanged(); internal static extern void SetChanged(bool changed); internal static extern void SetDidGUIWindowsEatLastEvent(bool value); @@ -93,5 +97,7 @@ public static extern string systemCopyBuffer private static extern System.Object Internal_GetDefaultSkin(int skinMode); private static extern Object Internal_GetBuiltinSkin(int skin); private static extern void Internal_ExitGUI(); + private static extern Vector2 InternalWindowToScreenPoint(Vector2 windowPoint); + private static extern Vector2 InternalScreenToWindowPoint(Vector2 screenPoint); } } diff --git a/Modules/IMGUI/GUIUtility.cs b/Modules/IMGUI/GUIUtility.cs index 2200515dbb..ee093aa201 100644 --- a/Modules/IMGUI/GUIUtility.cs +++ b/Modules/IMGUI/GUIUtility.cs @@ -256,12 +256,10 @@ internal static void CheckOnGUI() throw new ArgumentException("You can only call GUI functions from inside OnGUI."); } - internal static Vector2 s_EditorScreenPointOffset = Vector2.zero; - // Convert a point from GUI position to screen space. public static Vector2 GUIToScreenPoint(Vector2 guiPoint) { - return GUIClip.UnclipToWindow(guiPoint) + s_EditorScreenPointOffset; + return InternalWindowToScreenPoint(GUIClip.UnclipToWindow(guiPoint)); } // Convert a rect from GUI position to screen space. @@ -276,7 +274,7 @@ internal static Rect GUIToScreenRect(Rect guiRect) // Convert a point from screen space to GUI position. public static Vector2 ScreenToGUIPoint(Vector2 screenPoint) { - return GUIClip.ClipToWindow(screenPoint) - s_EditorScreenPointOffset; + return GUIClip.ClipToWindow(InternalScreenToWindowPoint(screenPoint)); } // Convert a rect from screen space to GUI position. @@ -328,6 +326,12 @@ public void Dispose() manualTex2SRGBEnabled = m_WasEnabled; } } + + public static Rect AlignRectToDevice(Rect rect) + { + int width, height; + return AlignRectToDevice(rect, out width, out height); + } } [VisibleToOtherModules("UnityEngine.UIElementsModule")] diff --git a/Modules/PackageManager/Editor/Managed/PackageInfo.cs b/Modules/PackageManager/Editor/Managed/PackageInfo.cs index ddfe435f4f..293ee6e71c 100644 --- a/Modules/PackageManager/Editor/Managed/PackageInfo.cs +++ b/Modules/PackageManager/Editor/Managed/PackageInfo.cs @@ -75,6 +75,10 @@ public class PackageInfo [NativeName("resolvedDependencies")] private DependencyInfo[] m_ResolvedDependencies = new DependencyInfo[0]; + [SerializeField] + [NativeName("keywords")] + private string[] m_Keywords = new string[0]; + private PackageInfo() {} public string packageId { get { return m_PackageId; } } @@ -91,6 +95,7 @@ private PackageInfo() {} public VersionsInfo versions { get { return m_Versions; } } public DependencyInfo[] dependencies { get { return m_Dependencies; } } public DependencyInfo[] resolvedDependencies { get { return m_ResolvedDependencies; } } + public string[] keywords { get { return m_Keywords; } } } } diff --git a/Modules/UIElements/Panel.cs b/Modules/UIElements/Panel.cs index 39af927ff2..31ed96f018 100644 --- a/Modules/UIElements/Panel.cs +++ b/Modules/UIElements/Panel.cs @@ -518,9 +518,9 @@ private void PaintSubTree(Event e, VisualElement root, Matrix4x4 offset, VisualE } float x1 = Mathf.Max(worldBound.x, currentGlobalClip.x); - float x2 = Mathf.Min(worldBound.x + worldBound.width, currentGlobalClip.x + currentGlobalClip.width); + float x2 = Mathf.Min(worldBound.xMax, currentGlobalClip.xMax); float y1 = Mathf.Max(worldBound.y, currentGlobalClip.y); - float y2 = Mathf.Min(worldBound.y + worldBound.height, currentGlobalClip.y + currentGlobalClip.height); + float y2 = Mathf.Min(worldBound.yMax, currentGlobalClip.yMax); // new global clip and hierarchical clip space option. currentGlobalClip = new Rect(x1, y1, x2 - x1, y2 - y1); @@ -546,12 +546,14 @@ private void PaintSubTree(Event e, VisualElement root, Matrix4x4 offset, VisualE // validate cache texture size first var worldBound = root.worldBound; - int w = (int)GUIUtility.Internal_Roundf(worldBound.xMax) - (int)GUIUtility.Internal_Roundf(worldBound.xMin); - int h = (int)GUIUtility.Internal_Roundf(worldBound.yMax) - (int)GUIUtility.Internal_Roundf(worldBound.yMin); - - // This needs to be consistent with RoundRect() in GUITexture.cpp. Otherwise, the texture may be stretched. - int textureWidth = (int)GUIUtility.Internal_Roundf(w * GUIUtility.pixelsPerPoint); - int textureHeight = (int)GUIUtility.Internal_Roundf(h * GUIUtility.pixelsPerPoint); + Rect alignedRect; + int textureWidth, textureHeight; + painter.currentWorldClip = currentGlobalClip; + painter.currentTransform = offset * root.worldTransform; + using (new GUIClip.ParentClipScope(painter.currentTransform, currentGlobalClip)) + { + alignedRect = GUIUtility.AlignRectToDevice(root.rect, out textureWidth, out textureHeight); + } // Prevent the texture size from going empty, which may occur if the element has a sub-pixel size textureWidth = Math.Max(textureWidth, 1); @@ -608,12 +610,13 @@ private void PaintSubTree(Event e, VisualElement root, Matrix4x4 offset, VisualE // Calculate the offset required to translate the origin of the rect to the upper left corner // of the pixel cache. We need to round because the rect will be rounded when rendered. - var childrenOffset = Matrix4x4.Translate(new Vector3(-GUIUtility.Internal_Roundf(worldBound.x), -GUIUtility.Internal_Roundf(worldBound.y), 0)); + Rect worldAlignedRect = root.LocalToWorld(alignedRect); + var childrenOffset = Matrix4x4.Translate(new Vector3(-worldAlignedRect.x, -worldAlignedRect.y, 0)); Matrix4x4 offsetWorldTransform = childrenOffset * root.worldTransform; // reset clipping - var textureClip = new Rect(0, 0, w, h); + var textureClip = new Rect(0, 0, worldAlignedRect.width, worldAlignedRect.height); painter.currentTransform = offsetWorldTransform; // Metal ignores the sRGBWrite flag and will always do linear to gamma conversions @@ -697,18 +700,17 @@ private void PaintSubTree(Event e, VisualElement root, Matrix4x4 offset, VisualE painter.currentWorldClip = currentGlobalClip; painter.currentTransform = offset * root.worldTransform; - var painterParams = new TextureStylePainterParameters - { - rect = root.alignedRect, - uv = new Rect(0, 0, 1, 1), - texture = root.renderData.pixelCache, - color = Color.white, - scaleMode = ScaleMode.StretchToFill, - usePremultiplyAlpha = true - }; - using (new GUIClip.ParentClipScope(painter.currentTransform, currentGlobalClip)) { + var painterParams = new TextureStylePainterParameters + { + rect = GUIUtility.AlignRectToDevice(root.rect), + uv = new Rect(0, 0, 1, 1), + texture = root.renderData.pixelCache, + color = Color.white, + scaleMode = ScaleMode.StretchToFill, + usePremultiplyAlpha = true + }; painter.DrawTexture(painterParams); } } diff --git a/Modules/UIElements/VisualElement.cs b/Modules/UIElements/VisualElement.cs index 33eca6c2d7..929dcb1ddb 100644 --- a/Modules/UIElements/VisualElement.cs +++ b/Modules/UIElements/VisualElement.cs @@ -335,22 +335,19 @@ internal Rect rect } } + internal bool isWorldTransformDirty { get; set; } = true; + /// - /// rect converted to world space, aligned to the pixel-grid, and converted back to its original space. + /// Returns a matrix that cumulates the following operations (in order): + /// -Local Scaling + /// -Local Rotation + /// -Local Translation + /// -Layout Translation + /// -Parent worldTransform (recursive definition - consider identity when there is no parent) /// /// - /// The offset used when rendering to a pixel cache can yield numerical errors that result in rounding - /// differences in GUITexture.cpp, causing blur. By specifying an already-aligned rect, the numerical - /// errors aren't sufficient to generate rounding differences. + /// Multiplying the layout rect by this matrix is incorrect because it already contains the translation. /// - internal Rect alignedRect - { - get - { - return GUIUtility.Internal_AlignRectToDevice(rect, worldTransform); - } - } - public Matrix4x4 worldTransform { get @@ -1302,7 +1299,7 @@ internal static TextureStylePainterParameters GetDefaultTextureParameters(this I IStyle style = ve.style; var painterParams = new TextureStylePainterParameters { - rect = ve.alignedRect, + rect = GUIUtility.AlignRectToDevice(ve.rect), uv = new Rect(0, 0, 1, 1), color = Color.white, texture = style.backgroundImage, @@ -1321,7 +1318,7 @@ internal static RectStylePainterParameters GetDefaultRectParameters(this IStyleP IStyle style = ve.style; var painterParams = new RectStylePainterParameters { - rect = ve.alignedRect, + rect = GUIUtility.AlignRectToDevice(ve.rect), color = style.backgroundColor, }; painter.SetBorderFromStyle(ref painterParams.border, style); diff --git a/Projects/CSharp/UnityEditor.csproj b/Projects/CSharp/UnityEditor.csproj index f1dc7a8a05..a5140c409f 100644 --- a/Projects/CSharp/UnityEditor.csproj +++ b/Projects/CSharp/UnityEditor.csproj @@ -2165,6 +2165,9 @@ Editor\Mono\Inspector\ScriptExecutionOrderInspector.cs + + Editor\Mono\Inspector\ScriptableObjectAssetEditor.cs + Editor\Mono\Inspector\ShaderGUI.cs @@ -2630,6 +2633,9 @@ Editor\Mono\PlayerSettingsSplashScreen.cs + + Editor\Mono\PlayerSettingsSwitch.bindings.cs + Editor\Mono\PlayerSettingsTVOS.bindings.cs diff --git a/README.md b/README.md index 7f7f63ab71..54cd4a194c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b6 C# reference source code +## Unity 2018.2.0b7 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Export/Vector2.cs b/Runtime/Export/Vector2.cs index fee02d6b02..b4ab5ace9a 100644 --- a/Runtime/Export/Vector2.cs +++ b/Runtime/Export/Vector2.cs @@ -157,10 +157,12 @@ public static Vector2 Perpendicular(Vector2 inDirection) // Returns the angle in degrees between /from/ and /to/. public static float Angle(Vector2 from, Vector2 to) { - float dot = Mathf.Clamp(Dot(from.normalized, to.normalized), -1F, 1F); - if (Mathf.Abs(dot) > (1F - kEpsilon)) - return dot > 0F ? 0F : 180F; + // sqrt(a) * sqrt(b) = sqrt(a * b) -- valid for real numbers + float denominator = Mathf.Sqrt(from.sqrMagnitude * to.sqrMagnitude); + if (denominator < kEpsilonNormalSqrt) + return 0F; + float dot = Mathf.Clamp(Dot(from, to) / denominator, -1F, 1F); return Mathf.Acos(dot) * Mathf.Rad2Deg; } @@ -310,5 +312,7 @@ public static implicit operator Vector3(Vector2 v) // *Undocumented* public const float kEpsilon = 0.00001F; + // *Undocumented* + public const float kEpsilonNormalSqrt = 1e-15f; } } diff --git a/Runtime/Export/Vector3.cs b/Runtime/Export/Vector3.cs index 3dec8176bc..380b0993e6 100644 --- a/Runtime/Export/Vector3.cs +++ b/Runtime/Export/Vector3.cs @@ -18,7 +18,10 @@ namespace UnityEngine [StructLayout(LayoutKind.Sequential)] public partial struct Vector3 : IEquatable { + // *Undocumented* public const float kEpsilon = 0.00001F; + // *Undocumented* + public const float kEpsilonNormalSqrt = 1e-15F; // X component of the vector. public float x; @@ -222,10 +225,12 @@ public static Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal) // Returns the angle in degrees between /from/ and /to/. This is always the smallest public static float Angle(Vector3 from, Vector3 to) { - float dot = Mathf.Clamp(Dot(from.normalized, to.normalized), -1F, 1F); - if (Mathf.Abs(dot) > (1F - kEpsilon)) - return dot > 0F ? 0F : 180F; + // sqrt(a) * sqrt(b) = sqrt(a * b) -- valid for real numbers + float denominator = Mathf.Sqrt(from.sqrMagnitude * to.sqrMagnitude); + if (denominator < kEpsilonNormalSqrt) + return 0F; + float dot = Mathf.Clamp(Dot(from, to) / denominator, -1F, 1F); return Mathf.Acos(dot) * Mathf.Rad2Deg; } From 379cf0526e81a7b9699358c516afb17f714e94a5 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Wed, 13 Jun 2018 13:54:30 +0000 Subject: [PATCH 07/13] Unity 2018.2.0b8 C# reference source code --- .../AssetDatabase/AssetDatabaseSearching.cs | 10 +- .../AssetPipeline/MovieImporter.bindings.cs | 1 + .../AssetPipeline/VideoImporter.bindings.cs | 3 + Editor/Mono/BuildPlayerWindowBuildMethods.cs | 2 +- .../ImportSettings/MovieImporterInspector.cs | 1 + .../VideoClipImporterInspector.cs | 24 +-- Editor/Mono/Inspector/ClothInspector.cs | 22 +-- .../Mono/Inspector/MovieTextureInspector.cs | 1 + Editor/Mono/InternalEditorUtility.cs | 3 +- Editor/Mono/PackageManagerUtilityInternal.cs | 27 ++++ Editor/Mono/ProjectBrowser.cs | 147 ++++++++++-------- Editor/Mono/ProjectBrowserColumnOne.cs | 5 +- .../ProjectWindow/CachedFilteredHierachy.cs | 10 +- .../ScriptCompilation/MonoLibraryHelpers.cs | 13 ++ Editor/Mono/Utils/NetStandardFinder.cs | 6 + .../Mono/Utils/ProcessOutputStreamReader.cs | 5 + .../lib/mono/2.0/Boo.Lang.Compiler.dll | Bin 934912 -> 934912 bytes .../lib/mono/2.0/Boo.Lang.Parser.dll | Bin 414208 -> 414208 bytes .../lib/mono/2.0/Boo.Lang.dll | Bin 126976 -> 126976 bytes .../lib/mono/2.0/Mono.Posix.dll | Bin 184320 -> 184320 bytes .../lib/mono/2.0/Mono.Security.dll | Bin 294912 -> 294912 bytes .../lib/mono/2.0/System.Core.dll | Bin 297984 -> 297984 bytes .../lib/mono/2.0/System.Xml.Linq.dll | Bin 106496 -> 106496 bytes .../lib/mono/2.0/System.Xml.dll | Bin 1270272 -> 1270272 bytes .../monodistribution/lib/mono/2.0/System.dll | Bin 1679360 -> 1679360 bytes .../lib/mono/2.0/UnityScript.dll | Bin 177664 -> 177664 bytes .../Editor/Managed/NativeStatusCode.cs | 3 +- .../Managed/NativeStatusCodeExtensions.cs | 1 + .../Editor/Managed/PackageInfo.cs | 10 ++ .../Editor/Managed/PackageManager.cs | 63 +++++++- .../BuildEventsHandler.cs | 52 +++++-- .../EditorAnalytics.bindings.cs | 6 + .../Public/DownloadHandlerAudio.bindings.cs | 1 + .../UnityWebRequestMultimedia.cs | 2 + .../UnityWebRequestWWW/Public/WWW.bindings.cs | 1 + Modules/UnityWebRequestWWW/Public/WWW.cs | 2 + .../VideoEditor/Editor/VideoPlayerEditor.cs | 25 ++- Projects/CSharp/UnityEditor.csproj | 3 + README.md | 2 +- Runtime/Export/AnimationCurve.bindings.cs | 27 ++-- Runtime/Export/Display.bindings.cs | 3 + .../common/Audio/MovieTextureBindings.gen.cs | 1 + .../Editor/PlayerSettingsWSABindings.gen.cs | 14 +- 43 files changed, 345 insertions(+), 151 deletions(-) create mode 100644 Editor/Mono/PackageManagerUtilityInternal.cs diff --git a/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs b/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs index d83ef76976..d2deb32ccf 100644 --- a/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs +++ b/Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs @@ -56,12 +56,9 @@ private static IEnumerator FindInFolders(SearchFilter searchFilter, Func FindEverywhere(SearchFilter searchFilter, Func< if (searchFilter.searchArea == SearchFilter.SearchArea.AllAssets || searchFilter.searchArea == SearchFilter.SearchArea.InPackagesOnly) { - var packages = PackageManager.Packages.GetAll(); + var packages = PackageManagerUtilityInternal.GetAllVisiblePackages(); foreach (var package in packages) { - if (package.source == PackageManager.PackageSource.BuiltIn) - continue; - rootPaths.Add(package.assetPath); } } diff --git a/Editor/Mono/AssetPipeline/MovieImporter.bindings.cs b/Editor/Mono/AssetPipeline/MovieImporter.bindings.cs index 384c795798..fd859ca64d 100644 --- a/Editor/Mono/AssetPipeline/MovieImporter.bindings.cs +++ b/Editor/Mono/AssetPipeline/MovieImporter.bindings.cs @@ -8,6 +8,7 @@ namespace UnityEditor { // AssetImporter for importing MovieTextures + [System.Obsolete("MovieImporter is deprecated. Use VideoClipImporter instead.", false)] [NativeHeader("Editor/Src/AssetPipeline/MovieImporter.h")] public partial class MovieImporter : AssetImporter { diff --git a/Editor/Mono/AssetPipeline/VideoImporter.bindings.cs b/Editor/Mono/AssetPipeline/VideoImporter.bindings.cs index 62c2a653eb..d753f67a6b 100644 --- a/Editor/Mono/AssetPipeline/VideoImporter.bindings.cs +++ b/Editor/Mono/AssetPipeline/VideoImporter.bindings.cs @@ -216,6 +216,9 @@ internal extern static string defaultTargetName public extern int pixelAspectRatioDenominator { get; } public extern bool transcodeSkipped { get; } + + [NativeMethod("operator==")] + extern public bool Equals(VideoClipImporter rhs); } } diff --git a/Editor/Mono/BuildPlayerWindowBuildMethods.cs b/Editor/Mono/BuildPlayerWindowBuildMethods.cs index 559bd6652a..0fc09e27ee 100644 --- a/Editor/Mono/BuildPlayerWindowBuildMethods.cs +++ b/Editor/Mono/BuildPlayerWindowBuildMethods.cs @@ -342,7 +342,7 @@ static bool PickBuildLocation(BuildTargetGroup targetGroup, BuildTarget target, if (isWindowsStandalone) { extension = realExtension; - path = Path.Combine(path, Path.GetFileName(path) + '.' + extension); + path = Path.Combine(path, PlayerSettings.productName + '.' + extension); } if (!IsBuildPathValid(path)) diff --git a/Editor/Mono/ImportSettings/MovieImporterInspector.cs b/Editor/Mono/ImportSettings/MovieImporterInspector.cs index d6e1751c3f..3f5885c5c4 100644 --- a/Editor/Mono/ImportSettings/MovieImporterInspector.cs +++ b/Editor/Mono/ImportSettings/MovieImporterInspector.cs @@ -8,6 +8,7 @@ namespace UnityEditor { + [System.Obsolete("MovieImporter is deprecated. Use VideoClipImporter instead.", false)] [CustomEditor(typeof(MovieImporter))] internal class MovieImporterInspector : AssetImporterEditor { diff --git a/Editor/Mono/ImportSettings/VideoClipImporterInspector.cs b/Editor/Mono/ImportSettings/VideoClipImporterInspector.cs index 3982a1cb6e..e19cbdda13 100644 --- a/Editor/Mono/ImportSettings/VideoClipImporterInspector.cs +++ b/Editor/Mono/ImportSettings/VideoClipImporterInspector.cs @@ -745,9 +745,11 @@ public override void OnInspectorGUI() if (m_UseLegacyImporter.boolValue) { +#pragma warning disable 0618 EditorGUILayout.PropertyField( m_IsColorLinear, MovieImporterInspector.linearTextureContent); EditorGUILayout.Slider(m_Quality, 0.0f, 1.0f); +#pragma warning restore 0618 } else { @@ -786,6 +788,14 @@ public override bool HasModified() protected override void Apply() { + foreach (var t in targets) + { + var importer = (VideoClipImporter)t; + if (importer.isPlayingPreview) + importer.StopPreview(); + } + m_IsPlaying = false; + base.Apply(); WriteSettingsToBackend(); @@ -804,17 +814,13 @@ public override bool HasPreviewGUI() public override GUIContent GetPreviewTitle() { - if (m_PreviewTitle != null) - return m_PreviewTitle; - - m_PreviewTitle = new GUIContent(); + if (m_PreviewTitle == null) + m_PreviewTitle = new GUIContent(); if (targets.Length == 1) - { - AssetImporter importer = (AssetImporter)target; - m_PreviewTitle.text = Path.GetFileName(importer.assetPath); - } - else + // Asset name can change over time so we have to re-evaluate constantly. + m_PreviewTitle.text = Path.GetFileName(((AssetImporter)target).assetPath); + else if (string.IsNullOrEmpty(m_PreviewTitle.text)) m_PreviewTitle.text = targets.Length + " Video Clips"; return m_PreviewTitle; diff --git a/Editor/Mono/Inspector/ClothInspector.cs b/Editor/Mono/Inspector/ClothInspector.cs index 45d55a4d91..345b843671 100644 --- a/Editor/Mono/Inspector/ClothInspector.cs +++ b/Editor/Mono/Inspector/ClothInspector.cs @@ -94,22 +94,22 @@ private static class Styles public static readonly GUIContent editSelfInterCollisionLabel = EditorGUIUtility.TrTextContent("Edit Collision Particles"); public static readonly GUIContent selfInterCollisionParticleColor = EditorGUIUtility.TrTextContent("Visualization Color"); public static readonly GUIContent selfInterCollisionBrushColor = EditorGUIUtility.TrTextContent("Brush Color"); - public static readonly GUIContent clothSelfCollisionAndInterCollision = EditorGUIUtility.TrTextContent("Cloth Self-Collision And Inter-Collision"); + public static readonly GUIContent clothSelfCollisionAndInterCollision = EditorGUIUtility.TrTextContent("Cloth Self-Collision and Inter-Collision"); public static readonly GUIContent paintCollisionParticles = EditorGUIUtility.TrTextContent("Paint Collision Particles"); public static readonly GUIContent selectCollisionParticles = EditorGUIUtility.TrTextContent("Select Collision Particles"); public static readonly GUIContent brushRadiusString = EditorGUIUtility.TrTextContent("Brush Radius"); public static readonly GUIContent selfAndInterCollisionMode = EditorGUIUtility.TrTextContent("Paint or Select Particles"); public static readonly GUIContent backFaceManipulationMode = EditorGUIUtility.TrTextContent("Back Face Manipulation"); public static readonly GUIContent manipulateBackFaceString = EditorGUIUtility.TrTextContent("Manipulate Backfaces"); - public static readonly GUIContent selfCollisionString = EditorGUIUtility.TrTextContent("Self Collision"); + public static readonly GUIContent selfCollisionString = EditorGUIUtility.TrTextContent("Self-Collision"); public static readonly GUIContent setSelfAndInterCollisionString = EditorGUIUtility.TrTextContent("Self-Collision and Inter-Collision"); public static readonly int clothEditorWindowWidth = 300; public static GUIContent[] toolContents = { - EditorGUIUtility.IconContent("EditCollider"), - EditorGUIUtility.IconContent("EditCollider") + EditorGUIUtility.IconContent("editconstraints_16"), + EditorGUIUtility.IconContent("editCollision_16") }; public static GUIContent[] toolIcons = @@ -141,8 +141,8 @@ private static class Styles public static GUIContent[] collVisModeStrings = { - EditorGUIUtility.TrTextContent("Self Collision"), - EditorGUIUtility.TrTextContent("Inter Collision"), + EditorGUIUtility.TrTextContent("Self-Collision"), + EditorGUIUtility.TrTextContent("Inter-Collision"), }; public static GUIContent paintIcon = EditorGUIUtility.TrIconContent("ClothInspector.PaintValue", "Change this vertex coefficient value by painting in the scene view."); @@ -153,16 +153,16 @@ private static class Styles EditMode.SceneViewEditMode.ClothSelfAndInterCollisionParticles }; - public static GUIContent selfCollisionDistanceGUIContent = EditorGUIUtility.TrTextContent("Self Collision Distance"); - public static GUIContent selfCollisionStiffnessGUIContent = EditorGUIUtility.TrTextContent("Self Collision Stiffness"); + public static GUIContent selfCollisionDistanceGUIContent = EditorGUIUtility.TrTextContent("Self-Collision Distance"); + public static GUIContent selfCollisionStiffnessGUIContent = EditorGUIUtility.TrTextContent("Self-Collision Stiffness"); static Styles() { toolContents[0].tooltip = EditorGUIUtility.TrTextContent("Edit cloth constraints").text; - toolContents[1].tooltip = EditorGUIUtility.TrTextContent("Edit cloth self or inter collision").text; + toolContents[1].tooltip = EditorGUIUtility.TrTextContent("Edit cloth self/inter-collision").text; - toolIcons[0].tooltip = EditorGUIUtility.TrTextContent("Select cloth particles for use in self or inter collision").text; - toolIcons[1].tooltip = EditorGUIUtility.TrTextContent("Paint cloth particles for use in self or inter collision").text; + toolIcons[0].tooltip = EditorGUIUtility.TrTextContent("Select cloth particles for use in self/inter-collision").text; + toolIcons[1].tooltip = EditorGUIUtility.TrTextContent("Paint cloth particles for use in self/inter-collision").text; collToolModeIcons[0].tooltip = EditorGUIUtility.TrTextContent("Select cloth particles.").text; collToolModeIcons[1].tooltip = EditorGUIUtility.TrTextContent("Paint cloth particles.").text; diff --git a/Editor/Mono/Inspector/MovieTextureInspector.cs b/Editor/Mono/Inspector/MovieTextureInspector.cs index 3baaaa580e..4ca6cf17f1 100644 --- a/Editor/Mono/Inspector/MovieTextureInspector.cs +++ b/Editor/Mono/Inspector/MovieTextureInspector.cs @@ -7,6 +7,7 @@ namespace UnityEditor { + [System.Obsolete("MovieTexture is deprecated. Use VideoPlayer instead.", false)] [CustomEditor(typeof(MovieTexture))] [CanEditMultipleObjects] internal class MovieTextureInspector : TextureInspector diff --git a/Editor/Mono/InternalEditorUtility.cs b/Editor/Mono/InternalEditorUtility.cs index eca3a1d65e..2471ef8e22 100644 --- a/Editor/Mono/InternalEditorUtility.cs +++ b/Editor/Mono/InternalEditorUtility.cs @@ -12,6 +12,7 @@ using UnityEditor.Scripting.ScriptCompilation; using UnityEngine.Experimental.UIElements; using UnityEngine.StyleSheets; +using UnityEngine.Video; namespace UnityEditorInternal { @@ -71,7 +72,7 @@ public static Texture2D FindIconForFile(string fileName) case "asf": case "asx": case "avi": case "dat": case "divx": case "dvx": case "mlv": case "m2l": case "m2t": case "m2ts": case "m2v": case "m4e": case "mjp": case "mov": case "movie": case "mp21": case "mpe": case "mpv2": case "ogm": case "qt": case "rm": case "rmvb": case "wmw": case "xvid": - return AssetDatabase.GetCachedIcon(fileName) as Texture2D ?? EditorGUIUtility.FindTexture(typeof(MovieTexture)); + return AssetDatabase.GetCachedIcon(fileName) as Texture2D ?? EditorGUIUtility.FindTexture(typeof(VideoClip)); case "colors": case "gradients": case "curves": case "curvesnormalized": case "particlecurves": case "particlecurvessigned": case "particledoublecurves": case "particledoublecurvessigned": diff --git a/Editor/Mono/PackageManagerUtilityInternal.cs b/Editor/Mono/PackageManagerUtilityInternal.cs new file mode 100644 index 0000000000..f346173bce --- /dev/null +++ b/Editor/Mono/PackageManagerUtilityInternal.cs @@ -0,0 +1,27 @@ +// Unity C# reference source +// Copyright (c) Unity Technologies. For terms of use, see +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License + +using System; +using System.Linq; +using UnityEditor.PackageManager; + +namespace UnityEditor +{ + /// + /// PackageManager helper class. + /// + internal static class PackageManagerUtilityInternal + { + /// + /// Returns visibles packages, it excludes modules and non-root dependencies (used in project browser) + /// an array of package information ordererd by display name. + /// + public static PackageManager.PackageInfo[] GetAllVisiblePackages() + { + return Packages.GetAll().Where(info => info.isRootDependency && info.type != "module"). + OrderBy(info => string.IsNullOrEmpty(info.displayName) ? info.name : info.displayName, + StringComparer.InvariantCultureIgnoreCase).ToArray(); + } + } +} diff --git a/Editor/Mono/ProjectBrowser.cs b/Editor/Mono/ProjectBrowser.cs index 3848991dae..ccacbaa5d7 100644 --- a/Editor/Mono/ProjectBrowser.cs +++ b/Editor/Mono/ProjectBrowser.cs @@ -10,6 +10,7 @@ using System.IO; using System.Text.RegularExpressions; using UnityEditor.IMGUI.Controls; +using UnityEditor.PackageManager; using UnityEditor.TreeViewExamples; using UnityEditorInternal; using UnityEngine.Scripting; @@ -349,13 +350,15 @@ private void OnProjectChanged() { if (m_AssetTree != null) { - m_AssetTree.ReloadData(); + m_AssetTree = null; + InitOneColumnView(); SetSearchFoldersFromCurrentSelection(); // We could have moved, deleted or renamed a folder so ensure we get folder paths by instanceID } if (m_FolderTree != null) { - m_FolderTree.ReloadData(); + m_FolderTree = null; + InitTwoColumnView(); SetSearchFolderFromFolderTreeSelection(); // We could have moved, deleted or renamed a folder so ensure we get folders paths by instanceID } @@ -667,6 +670,61 @@ void OnGUIAssetCallback(int instanceID, Rect rect) } } + private void InitOneColumnView() + { + m_AssetTree = new TreeViewController(this, m_AssetTreeState); + m_AssetTree.deselectOnUnhandledMouseDown = true; + m_AssetTree.selectionChangedCallback += AssetTreeSelectionCallback; + m_AssetTree.keyboardInputCallback += AssetTreeKeyboardInputCallback; + m_AssetTree.contextClickItemCallback += AssetTreeViewContextClick; + m_AssetTree.contextClickOutsideItemsCallback += AssetTreeViewContextClickOutsideItems; + m_AssetTree.itemDoubleClickedCallback += AssetTreeItemDoubleClickedCallback; + m_AssetTree.onGUIRowCallback += OnGUIAssetCallback; + m_AssetTree.dragEndedCallback += AssetTreeDragEnded; + + var assetsFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); + var roots = new List(); + var packagesMountPoint = PackageManager.Folders.GetPackagesMountPoint(); + + roots.Add(new AssetsTreeViewDataSource.RootItem(assetsFolderInstanceID, null, null)); + roots.Add(new AssetsTreeViewDataSource.RootItem(kPackagesFolderInstanceId, packagesMountPoint, packagesMountPoint, true)); + foreach (var package in PackageManagerUtilityInternal.GetAllVisiblePackages()) + { + var displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name; + var packageFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath); + if (packageFolderInstanceID == 0) + continue; + + roots.Add(new AssetsTreeViewDataSource.RootItem(packageFolderInstanceID, displayName, package.assetPath)); + } + + var data = new AssetsTreeViewDataSource(m_AssetTree, roots); + data.foldersFirst = GetShouldShowFoldersFirst(); + + m_AssetTree.Init(m_TreeViewRect, + data, + new AssetsTreeViewGUI(m_AssetTree), + new AssetsTreeViewDragging(m_AssetTree) + ); + m_AssetTree.ReloadData(); + } + + private void InitTwoColumnView() + { + m_FolderTree = new TreeViewController(this, m_FolderTreeState); + m_FolderTree.deselectOnUnhandledMouseDown = false; + m_FolderTree.selectionChangedCallback += FolderTreeSelectionCallback; + m_FolderTree.contextClickItemCallback += FolderTreeViewContextClick; + m_FolderTree.onGUIRowCallback += OnGUIAssetCallback; + m_FolderTree.dragEndedCallback += FolderTreeDragEnded; + m_FolderTree.Init(m_TreeViewRect, + new ProjectBrowserColumnOneTreeViewDataSource(m_FolderTree), + new ProjectBrowserColumnOneTreeViewGUI(m_FolderTree), + new ProjectBrowserColumnOneTreeViewDragging(m_FolderTree) + ); + m_FolderTree.ReloadData(); + } + void InitViewMode(ViewMode viewMode) { m_ViewMode = viewMode; @@ -677,57 +735,14 @@ void InitViewMode(ViewMode viewMode) useTreeViewSelectionInsteadOfMainSelection = false; - if (m_ViewMode == ViewMode.OneColumn) + switch (m_ViewMode) { - m_AssetTree = new TreeViewController(this, m_AssetTreeState); - m_AssetTree.deselectOnUnhandledMouseDown = true; - m_AssetTree.selectionChangedCallback += AssetTreeSelectionCallback; - m_AssetTree.keyboardInputCallback += AssetTreeKeyboardInputCallback; - m_AssetTree.contextClickItemCallback += AssetTreeViewContextClick; - m_AssetTree.contextClickOutsideItemsCallback += AssetTreeViewContextClickOutsideItems; - m_AssetTree.itemDoubleClickedCallback += AssetTreeItemDoubleClickedCallback; - m_AssetTree.onGUIRowCallback += OnGUIAssetCallback; - m_AssetTree.dragEndedCallback += AssetTreeDragEnded; - - var assetsFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); - var roots = new List(); - var packagesMountPoint = PackageManager.Folders.GetPackagesMountPoint(); - - roots.Add(new AssetsTreeViewDataSource.RootItem(assetsFolderInstanceID, null, null)); - roots.Add(new AssetsTreeViewDataSource.RootItem(kPackagesFolderInstanceId, packagesMountPoint, packagesMountPoint, true)); - foreach (var package in PackageManager.Packages.GetAll()) - { - if (package.source == PackageManager.PackageSource.BuiltIn) - continue; - - var displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name; - roots.Add(new AssetsTreeViewDataSource.RootItem(AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath), displayName, package.assetPath)); - } - - var data = new AssetsTreeViewDataSource(m_AssetTree, roots); - data.foldersFirst = GetShouldShowFoldersFirst(); - - m_AssetTree.Init(m_TreeViewRect, - data, - new AssetsTreeViewGUI(m_AssetTree), - new AssetsTreeViewDragging(m_AssetTree) - ); - m_AssetTree.ReloadData(); - } - else if (m_ViewMode == ViewMode.TwoColumns) - { - m_FolderTree = new TreeViewController(this, m_FolderTreeState); - m_FolderTree.deselectOnUnhandledMouseDown = false; - m_FolderTree.selectionChangedCallback += FolderTreeSelectionCallback; - m_FolderTree.contextClickItemCallback += FolderTreeViewContextClick; - m_FolderTree.onGUIRowCallback += OnGUIAssetCallback; - m_FolderTree.dragEndedCallback += FolderTreeDragEnded; - m_FolderTree.Init(m_TreeViewRect, - new ProjectBrowserColumnOneTreeViewDataSource(m_FolderTree), - new ProjectBrowserColumnOneTreeViewGUI(m_FolderTree), - new ProjectBrowserColumnOneTreeViewDragging(m_FolderTree) - ); - m_FolderTree.ReloadData(); + case ViewMode.OneColumn: + InitOneColumnView(); + break; + case ViewMode.TwoColumns: + InitTwoColumnView(); + break; } float minWidth = (m_ViewMode == ViewMode.OneColumn) ? k_MinWidthOneColumn : k_MinWidthTwoColumns; @@ -1074,7 +1089,18 @@ void SetAsLastInteractedProjectBrowser() void RefreshSelectedPath() { if (Selection.activeObject != null) + { m_SelectedPath = AssetDatabase.GetAssetPath(Selection.activeObject); + if (!string.IsNullOrEmpty(m_SelectedPath)) + { + var packageInfo = Packages.GetForAssetPath(m_SelectedPath); + if (packageInfo != null && !packageInfo.isRootDependency) + { + m_SelectedPath = string.Empty; + Selection.activeObject = null; + } + } + } else m_SelectedPath = ""; @@ -2477,15 +2503,7 @@ void BreadCrumbBar() if (path == packagesMountPoint) { - m_BreadCrumbLastFolderHasSubFolders = false; - foreach (var package in PackageManager.Packages.GetAll()) - { - if (package.source == PackageManager.PackageSource.BuiltIn) - continue; - - m_BreadCrumbLastFolderHasSubFolders = true; - break; - } + m_BreadCrumbLastFolderHasSubFolders = PackageManagerUtilityInternal.GetAllVisiblePackages().Length > 0; } else { @@ -2858,13 +2876,10 @@ static internal void Show(string folder, string currentSubFolder, Rect activator // List of sub folders var subFolders = new List(); var subFolderDisplayNames = new List(); - if (folder == PackageManager.Folders.GetPackagesMountPoint()) + if (folder == Folders.GetPackagesMountPoint()) { - foreach (var package in PackageManager.Packages.GetAll()) + foreach (var package in PackageManagerUtilityInternal.GetAllVisiblePackages()) { - if (package.source == PackageManager.PackageSource.BuiltIn) - continue; - subFolders.Add(package.assetPath); var displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name; subFolderDisplayNames.Add(displayName); diff --git a/Editor/Mono/ProjectBrowserColumnOne.cs b/Editor/Mono/ProjectBrowserColumnOne.cs index eaaaf166b6..cddc208e0d 100644 --- a/Editor/Mono/ProjectBrowserColumnOne.cs +++ b/Editor/Mono/ProjectBrowserColumnOne.cs @@ -281,12 +281,9 @@ public override void FetchData() packagesRootItem.icon = emptyFolderIcon; - var packages = PackageManager.Packages.GetAll(); + var packages = PackageManagerUtilityInternal.GetAllVisiblePackages(); foreach (var package in packages) { - if (package.source == PackageManager.PackageSource.BuiltIn) - continue; - var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath); displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name; diff --git a/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs b/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs index 66f65f7bbc..80088cddea 100644 --- a/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs +++ b/Editor/Mono/ProjectWindow/CachedFilteredHierachy.cs @@ -220,12 +220,9 @@ void SearchInFolders() baseFolders.AddRange(ProjectWindowUtil.GetBaseFolders(m_SearchFilter.folders)); if (baseFolders.Remove(PackageManager.Folders.GetPackagesMountPoint())) { - var packages = PackageManager.Packages.GetAll(); + var packages = PackageManagerUtilityInternal.GetAllVisiblePackages(); foreach (var package in packages) { - if (package.source == PackageManager.PackageSource.BuiltIn) - continue; - if (!baseFolders.Contains(package.assetPath)) baseFolders.Add(package.assetPath); } @@ -261,12 +258,9 @@ void FolderBrowsing() { if (folderPath == PackageManager.Folders.GetPackagesMountPoint()) { - var packages = PackageManager.Packages.GetAll(); + var packages = PackageManagerUtilityInternal.GetAllVisiblePackages(); foreach (var package in packages) { - if (package.source == PackageManager.PackageSource.BuiltIn) - continue; - var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath); property = new HierarchyProperty(package.assetPath); if (property.Find(packageFolderInstanceId, null)) diff --git a/Editor/Mono/Scripting/ScriptCompilation/MonoLibraryHelpers.cs b/Editor/Mono/Scripting/ScriptCompilation/MonoLibraryHelpers.cs index 5613714390..f5578f113f 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/MonoLibraryHelpers.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/MonoLibraryHelpers.cs @@ -52,6 +52,7 @@ static string[] GetCachedSystemLibraryReferences(ApiCompatibilityLevel apiCompat else if (apiCompatibilityLevel == ApiCompatibilityLevel.NET_4_6) { references.AddRange(GetSystemReferences().Select(dll => Path.Combine(monoAssemblyDirectory, dll))); + references.AddRange(GetNet46SystemReferences().Select(dll => Path.Combine(monoAssemblyDirectory, dll))); // Look in the mono assembly directory for a facade folder and get a list of all the DLL's to be // used later by the language compilers. @@ -97,6 +98,9 @@ static string[] GetNetStandardClassLibraries() // Add the .NET Standard 2.0 compat shims classLibraries.AddRange(Directory.GetFiles(NetStandardFinder.GetNetStandardCompatShimsDirectory(), "*.dll")); + // Add the .NET Standard 2.0 extensions + classLibraries.AddRange(Directory.GetFiles(NetStandardFinder.GetNetStandardExtensionsDirectory(), "*.dll")); + // Add the .NET Framework compat shims classLibraries.AddRange(Directory.GetFiles(NetStandardFinder.GetDotNetFrameworkCompatShimsDirectory(), "*.dll")); @@ -116,6 +120,15 @@ static string[] GetSystemReferences() }; } + static string[] GetNet46SystemReferences() + { + return new[] + { + "System.Numerics.dll", + "System.Numerics.Vectors.dll" + }; + } + static string[] GetBooAndUsReferences() { return new[] diff --git a/Editor/Mono/Utils/NetStandardFinder.cs b/Editor/Mono/Utils/NetStandardFinder.cs index c4d148a13c..b7fc44375f 100644 --- a/Editor/Mono/Utils/NetStandardFinder.cs +++ b/Editor/Mono/Utils/NetStandardFinder.cs @@ -28,6 +28,12 @@ public static string GetNetStandardCompatShimsDirectory() return Path.Combine(prefix, Path.Combine(GetCompatShimsDirectory(), "netstandard")); } + public static string GetNetStandardExtensionsDirectory() + { + var prefix = GetNetStandardInstallation(); + return Path.Combine(prefix, Path.Combine("Extensions", "2.0.0")); + } + public static string GetDotNetFrameworkCompatShimsDirectory() { var prefix = GetNetStandardInstallation(); diff --git a/Editor/Mono/Utils/ProcessOutputStreamReader.cs b/Editor/Mono/Utils/ProcessOutputStreamReader.cs index 705f254413..8e1af08455 100644 --- a/Editor/Mono/Utils/ProcessOutputStreamReader.cs +++ b/Editor/Mono/Utils/ProcessOutputStreamReader.cs @@ -58,6 +58,11 @@ private void ThreadFunc() lines.Add("Could not read output because an ObjectDisposedException was thrown."); } } + catch (IOException) + { + // We may trigger an IOException (during domain unload) when shutting down a thread that is currently + // waiting on a synchronous syscall like ReadFile or WriteFile in mono + } } internal string[] GetOutput() diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.Compiler.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.Compiler.dll index cf322709d7a8ef578f2f420e10ca364cc9b3a058..088e5e73bd0c19041aca725686b7c75205c6beed 100644 GIT binary patch delta 217 zcmV;~04D!{h&h0WIgp41f^ZO9fsBQW0fmeLg^UA*j0A;@1%-?Tg^UMK9o38z18)6b)TVkj`U3lyT=KdVPHgK_R-$}msqiB|g z*Di;w!@7VG*F&J%1L((t#X53u6vm{m(0)i)EBmkH6PQDGBqlID?{>C z-X?Qv7S9azJ#~Q#ezF^ZuOv+?D=;i3#j!SQ_VvjpH0?2Tr2P@&GdLh{^=nS&vd~my T|E_`VpCfsBQW0fmeLg^UA*j0A;@1+|O@d`W-N9&q;H*PTSQ zdE$L>4ekasEyENHL>E4~p+$rNVDBtfhDP6yf$3gI1Kn@~LqgNWh-ql97K;zv!ZJu& zjM4|%-Ep(3grmQsg0|Pa0suJFH)Lul%KlkEZ|$dX-BdKaWTL!9J|?Nr*=SM!VbcMStnIH zj0fq`irDJ`-j`^sITJpe8hKFOm~8`i`SI7Wj5l09h{22Oo81G`#4jHEIbNyHJMS59L!VXfV5)`U^O+Sgz$w-HbVb^*5zOa}4=!XjLn diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.dll index 1b728d30ee073eb26fcc1bf8db3a99c8dad623bd..924f4f50ecb13fa119f2e7b73afbc7029b80c3f2 100644 GIT binary patch delta 178 zcmV;j08RgZ;0J)<2at#aesB<5fsD0`0R-iL$AoQ$A56SJf$vU0-hFfW&`vUVC@(CIZ^tiyFVj#N!VU g`vkj@U-W#ImM3-cJ!k#nL$?v`0qy~}4(I{$2fsmC5C8xG delta 178 zcmV;j08RgZ;0J)<2at#a(tzw*fsD0`0R-iLb^~yL;MpcXxE5WBz9p-(v+V>xl2xnJ z*{kdrsepy3^IKYAHww573>(FA*!nU}E*+wH*{GO~_RRWj^d(893X8wRx#7UAFs3i{ z(n6(|?d8ZAmU~tYc)vHf-KCx@C0}!tLwTyMa1FC}GzANIO8OYlmLFn~c|oxtJIf9c g{1s?b6SDCcHj>?yE(jjsptlk30qy~}4(I{$2O2+CT>t<8 diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/Mono.Posix.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/Mono.Posix.dll index 4f2424ee8f8848b01002114f241b20c7d21f3a9d..2141b172a176ce1ddba44291aa237a30890c4c53 100644 GIT binary patch delta 180 zcmV;l089UXpbLPY3y_EevTYDsfsBQW0kw<*c*uWw&8ia;R}4e5)TBUb%h-;b9=O7F z^v-(PpvKh_AIf#LcTv<>b`S;vc7pB&og2s4n7x<=O`+3_Zs}ny##%+REoGJ z5JEjgqCL2@rT=0EdbbYB0`djmI$1OT delta 180 zcmV;l089UXpbLPY3y_Ee9DeLtfsBQW0kw<*c*uWEhMrNH*8fkBlBbfqpl4XZy7;B! zNY@t)HblpcmLYwbOxb{w#qpbTq58mXqp7w)+OEZT3Fq^VXKwG)@%bWd(9!(0AZpOk z)_#)_8qi3*5cLMuRrGS;kBcviK__5!lW~Dp($dbBLF^TeT#DgDz$9@=lf#9jMGsO> iBW@9ky5ul`W{m*@5{Vg*I#=a9mr>0EdbbYB0`dir;9GnE diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/Mono.Security.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/Mono.Security.dll index d166926d871a0b91e0f735e4062a9846c8ecffa0..e925040ee8c7c37ad1bdd2512ed1feda84e29bd8 100644 GIT binary patch delta 186 zcmV;r07d_RfD(X!5|D@lxor?zfsBQW0fmeLg^UBWj08M*e=fy+k4|syMuS#UfogWB z%AqXU(zj?r>J^5j!_xN;po+wDUa-!nPY6Vg4{Yv{U&+rnjSYBN$_f8V3Rmb$ETC9A zC<=CAqClSOIF^bmRFs{*2aX{kW@bz0OxAR83ng_l%g1=Cr5ipK16?3cVwGW0X@E%l o-)@A-AA*>l5%zULmRJ^@BzFU^PzfsBQW0fmeLg^UBWj08M*e*u7lFwy30L9r*(pI*?% zSH^mWtbOK)=~lwxPy9AnU*ELQ-lvkeU7YzCA;mZX!XSwXJaW47z9s}xDyyyKVmA`0 zI(Dvpmie=C_ODWbAk>q-rRXl>Tnmux#XO604_B?HCd>zwUt-D_3d-LgUKj8 z;AKV&sf0peZI4Hupv}&3XJ+P#8LQ(7jq));h0QGV(7JV@g5#ni2j;-Ac#huN=2O3x z0Yd$NC`Nu#L1r%;sZ|93+Xfu6uJP>xX}|Rws8aq)xWrHKkB{|I%Ju3Xgwels;7nu7 p_#V{TG^F`p5eWO$t@+!ZZ!$0GokQ8q)jqcoiUbw`w+@B`@&!7AU&jCd delta 187 zcmV;s07Us!KKreR)~a+FqfL5_ngaGP zr$3F@kQL>K=s`n>GIlA->NMC7^O5UZEPl0E>qEA$o~{!e3j(Az&QG4u%5+wqhDnFu p4fG+Pvp29~5s;i@$8%583~&B1-UhE8E0DJliUbw`w+@B`@&(o1T6+Kh diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.Linq.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.Linq.dll index 2ba343f968f65d77e73bc2bd929a287641f85ed5..8d93f08fc74402bbb4e2ec110e61bd16958b053b 100644 GIT binary patch delta 180 zcmV;l089UXzy^T829SsZfNl_5fsD0`0qB%}Y!mEv7RjqkyTf2)agzpEUr)~++K3*5 z(8Sdx+`q!+%q|^y`Zq$P4Z8HV$#xH@{q^AEG%elO$@l=ucyD8kEqW&#C)uqZ^uI%M zxRZybJZ?bw=#+EkTl|GA!!9(IvZ{>ku@|1p7-j9}l!(fE;zvnHn7B+kyytvl8!z$^ i)YL+LfUi8DPrs5R2&7<*Wv2n00RoXQ3bziJ0rCfVj#?Z5 delta 180 zcmV;l089UXzy^T829SsZ-G1y^fsD0`0qB%}nKbp5ibjq`ygtXgG&jW^rt!eTSL3>E za2+nM;Fouim#=NoCqLr^?hwt%iIQ-C8hO#GjcaX=a;|x)7L=}CN+a37Gfk-$8x(Gj z6p0+*lX0$h63^0^Yy{o>WF&)uszQr6iL2zfHRUXY&hwCg!MbtWs0=uoCN)p&34<09 ie-{%XVB}0a*%4FwX+6oKG^YWa0RoXQ3bziJ0rCgyz*VdO diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.dll index 192e55160dd71dd27993a56abff638657cd54972..bc4a33a5b70cb363da48d3e23b4f44a04daa4774 100644 GIT binary patch delta 231 zcmVarmZ{7*}gJy!F^sE%xRtOI`lrsywCAzPAl~4d3t;rN? z=EY@IXTAn?GT0LE8ZD}u0-4Gh6ue@3;I$~JN$4bt*Nu5zrHRRX=d hMiKF+tmd>pxsJnxBEORUF)n+T5nvPAw+>tr@&%V+VWZgujFeyrhTk0;U1# z?IX|+LWuch)S)aaBeJRWxuZBfkE)rv*eq;#I%t0t(``;yML6z?T%AMuY8!75nvPAw+>tr@&!^5YAFB! diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/System.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/System.dll index d43c8780c423211cdd37c38752eab457db720e98..2b045a346f6f9cb533cb3b0fbcd148e98982e54c 100644 GIT binary patch delta 247 zcmVhs!$_n!K| zjZ()h!9|a0V3FJ5l_TYxdkbj4awv{i>HE&zvG!_UxRlky0!n0Gn^%pV3j6eE*Ehcu xx2*H1bb3Whm*zCf9%Ut6*0akI+^(?zonMBs@^{T^A9~o|6pUOXwu{VVEMw%&%nwmxW+=<|2a*lj zr_Wvwg3v| zTQ6ss5;TQaCXg+Xe;!rRSrnQqv!3N>tzmDw(`n&~>5fDH?qP@@B<0u!T9qYaR? n{r5(unT!I@VomB-zu4&0f9>sQfyvFDlN*_0w=-^G`p*ae(w|QV delta 256 zcmZp8!`1MHYeEOhi-tE*jXhg?7&WY!1zDK3Z?|T=&B&wA#K2Om2_%@R^|sHmWqe`B z#K|&DF)}t)F)}w}P$|jCEZ+VzoJm|%T_qSgAf}bI*zJs4nEo>Y0M9#3+yDRo diff --git a/Modules/PackageManager/Editor/Managed/NativeStatusCode.cs b/Modules/PackageManager/Editor/Managed/NativeStatusCode.cs index b4f01f00f2..e4730b15ab 100644 --- a/Modules/PackageManager/Editor/Managed/NativeStatusCode.cs +++ b/Modules/PackageManager/Editor/Managed/NativeStatusCode.cs @@ -13,7 +13,8 @@ enum NativeStatusCode InProgress, Done, Error, - NotFound + NotFound, + Cancelled } } diff --git a/Modules/PackageManager/Editor/Managed/NativeStatusCodeExtensions.cs b/Modules/PackageManager/Editor/Managed/NativeStatusCodeExtensions.cs index 83aa199710..2b686174ce 100644 --- a/Modules/PackageManager/Editor/Managed/NativeStatusCodeExtensions.cs +++ b/Modules/PackageManager/Editor/Managed/NativeStatusCodeExtensions.cs @@ -18,6 +18,7 @@ public static StatusCode ConvertToManaged(this NativeStatusCode status) return StatusCode.InProgress; case NativeStatusCode.Error: case NativeStatusCode.NotFound: + case NativeStatusCode.Cancelled: return StatusCode.Failure; case NativeStatusCode.Done: return StatusCode.Success; diff --git a/Modules/PackageManager/Editor/Managed/PackageInfo.cs b/Modules/PackageManager/Editor/Managed/PackageInfo.cs index 293ee6e71c..387b32252a 100644 --- a/Modules/PackageManager/Editor/Managed/PackageInfo.cs +++ b/Modules/PackageManager/Editor/Managed/PackageInfo.cs @@ -23,6 +23,10 @@ public class PackageInfo [NativeName("packageId")] private string m_PackageId = ""; + [SerializeField] + [NativeName("isRootDependency")] + private bool m_IsRootDependency = false; + [SerializeField] [NativeName("version")] private string m_Version = ""; @@ -51,6 +55,10 @@ public class PackageInfo [NativeName("category")] private string m_Category = ""; + [SerializeField] + [NativeName("type")] + private string m_Type = ""; + [SerializeField] [NativeName("description")] private string m_Description = ""; @@ -82,6 +90,7 @@ public class PackageInfo private PackageInfo() {} public string packageId { get { return m_PackageId; } } + internal bool isRootDependency { get { return m_IsRootDependency; } } public string version { get { return m_Version; } } public PackageSource source { get { return m_Source; } } public string resolvedPath { get { return m_ResolvedPath; } } @@ -89,6 +98,7 @@ private PackageInfo() {} public string name { get { return m_Name; } } public string displayName { get { return m_DisplayName; } } public string category { get { return m_Category; } } + internal string type { get { return m_Type; } } public string description { get { return m_Description; } } public PackageStatus status { get { return m_Status; } } public Error[] errors { get { return m_Errors; } } diff --git a/Modules/PackageManager/Editor/Managed/PackageManager.cs b/Modules/PackageManager/Editor/Managed/PackageManager.cs index b6b7a3331c..fb2df01d87 100644 --- a/Modules/PackageManager/Editor/Managed/PackageManager.cs +++ b/Modules/PackageManager/Editor/Managed/PackageManager.cs @@ -4,6 +4,7 @@ using System; using UnityEditor.Compilation; +using System.Collections.Generic; using Assembly = System.Reflection.Assembly; namespace UnityEditor.PackageManager @@ -27,19 +28,18 @@ public static PackageInfo GetForAssetPath(string assetPath) return null; } - public static PackageInfo GetForAssembly(Assembly assembly) + private static string GetRelativePathForAssemblyFilePath(string fullPath) { - if (assembly == null) - throw new ArgumentNullException("assembly"); + if (fullPath == null) + throw new ArgumentNullException("fullPath"); - var fullPath = assembly.Location; if (fullPath.StartsWith(Environment.CurrentDirectory + System.IO.Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)) { // Path is inside the project dir var relativePath = fullPath.Substring(Environment.CurrentDirectory.Length + 1).Replace('\\', '/'); // See if there is an asmdef file for this assembly - use it if so - var asmdefPath = CompilationPipeline.GetAssemblyDefinitionFilePathFromAssemblyName(assembly.GetName().Name); + var asmdefPath = CompilationPipeline.GetAssemblyDefinitionFilePathFromAssemblyName(fullPath); if (asmdefPath != null) relativePath = asmdefPath; @@ -48,8 +48,59 @@ public static PackageInfo GetForAssembly(Assembly assembly) return null; if (relativePath.StartsWith(Folders.GetPackagesMountPoint() + "/", StringComparison.OrdinalIgnoreCase)) - return GetForAssetPath(relativePath); + return relativePath; + } + return String.Empty; + } + + public static List GetForAssemblyFilePaths(List assemblyPaths) + { + // We will first get all the relative paths from assembly paths + Dictionary matchingRelativePaths = new Dictionary(); + foreach (string assemblyPath in assemblyPaths) + { + string relativePath = GetRelativePathForAssemblyFilePath(assemblyPath); + if (relativePath != null) + matchingRelativePaths.Add(assemblyPath, relativePath); + } + + // We will loop thru all the packages and see if they match the relative paths + List matchingPackages = new List(); + foreach (var package in GetAll()) + { + foreach (var item in matchingRelativePaths) + { + bool found; + string relativePath = item.Value; + if (!String.IsNullOrEmpty(relativePath)) + found = (relativePath == package.assetPath || relativePath.StartsWith(package.assetPath + '/')); + else + found = item.Key.StartsWith(package.resolvedPath + System.IO.Path.DirectorySeparatorChar); + + if (found) + { + matchingPackages.Add(package); + matchingRelativePaths.Remove(item.Key); + break; + } + } + if (matchingRelativePaths.Count == 0) + break; } + return matchingPackages; + } + + public static PackageInfo GetForAssembly(Assembly assembly) + { + if (assembly == null) + throw new ArgumentNullException("assembly"); + + string fullPath = assembly.Location; + string relativePath = GetRelativePathForAssemblyFilePath(fullPath); + if (!String.IsNullOrEmpty(relativePath)) + return GetForAssetPath(relativePath); + else if (relativePath == null) + return null; // Path is outside the project dir - or possibly inside the project dir but local (e.g. in LocalPackages in the test project) // Might be in the global package cache, might be a built-in engine module, etc. Do a scan through all packages for one that owns diff --git a/Modules/UnityEditorAnalyticsEditor/BuildEventsHandler.cs b/Modules/UnityEditorAnalyticsEditor/BuildEventsHandler.cs index 7f57e0fec7..222d694513 100644 --- a/Modules/UnityEditorAnalyticsEditor/BuildEventsHandler.cs +++ b/Modules/UnityEditorAnalyticsEditor/BuildEventsHandler.cs @@ -6,31 +6,39 @@ using System.Collections.Generic; using System.IO; using System.Xml; +using System.Linq; using UnityEngine; using Object = UnityEngine.Object; using UnityEditor.Build; using UnityEditor.Build.Reporting; using UnityEditor.Utils; +using UnityEditor.PackageManager; namespace UnityEditor { - [Serializable] - internal struct SceneViewInfo + internal class BuildEventsHandlerPostProcess : IPostprocessBuildWithReport { - public int total_scene_views; - public int num_of_2d_views; - public bool is_default_2d_mode; - } + [Serializable] + internal struct SceneViewInfo + { + public int total_scene_views; + public int num_of_2d_views; + public bool is_default_2d_mode; + } - [Serializable] - struct AndroidBuildPermissions - { - public string[] features; - public string[] permissions; - } + [Serializable] + internal struct BuildPackageIds + { + public string[] package_ids; + } + + [Serializable] + internal struct AndroidBuildPermissions + { + public string[] features; + public string[] permissions; + } - internal class BuildEventsHandlerPostProcess : IPostprocessBuildWithReport - { private static bool s_EventSent = false; private static int s_NumOfSceneViews = 0; private static int s_NumOf2dSceneViews = 0; @@ -42,12 +50,28 @@ internal class BuildEventsHandlerPostProcess : IPostprocessBuildWithReport public void OnPostprocessBuild(BuildReport report) { ReportSceneViewInfo(); + ReportBuildPackageIds(report.files); if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) { ReportBuildTargetPermissions(); } } + private void ReportBuildPackageIds(BuildFile[] buildFiles) + { + List managedLibraries = new List(); + foreach (BuildFile file in buildFiles) + { + if (file.role == "ManagedLibrary") + managedLibraries.Add(file.path); + } + + var matchingPackages = Packages.GetForAssemblyFilePaths(managedLibraries); + var packageIds = matchingPackages.Select(item => item.packageId).ToArray(); + if (packageIds.Length > 0) + EditorAnalytics.SendEventBuildPackageList(new BuildPackageIds() { package_ids = packageIds }); + } + private void ReportSceneViewInfo() { Object[] views = Resources.FindObjectsOfTypeAll(typeof(SceneView)); diff --git a/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs b/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs index b57ef721db..1126e11eca 100644 --- a/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs +++ b/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs @@ -54,6 +54,12 @@ internal static bool SendEventSceneViewInfo(object parameters) return EditorAnalytics.SendEvent("sceneViewInfo", parameters); } + internal static bool SendEventBuildPackageList(object parameters) + { + return EditorAnalytics.SendEvent("buildPackageList", parameters, + SendEventOptions.kAppendBuildGuid | SendEventOptions.kAppendBuildTarget); + } + internal static bool SendEventBuildTargetPermissions(object parameters) { return EditorAnalytics.SendEvent("buildTargetPermissions", parameters, diff --git a/Modules/UnityWebRequestAudio/Public/DownloadHandlerAudio.bindings.cs b/Modules/UnityWebRequestAudio/Public/DownloadHandlerAudio.bindings.cs index 790e500cb5..dbc8c4accb 100644 --- a/Modules/UnityWebRequestAudio/Public/DownloadHandlerAudio.bindings.cs +++ b/Modules/UnityWebRequestAudio/Public/DownloadHandlerAudio.bindings.cs @@ -53,6 +53,7 @@ public static AudioClip GetContent(UnityWebRequest www) } + [System.Obsolete("MovieTexture is deprecated. Use VideoPlayer instead.", false)] [StructLayout(LayoutKind.Sequential)] [NativeHeader("Modules/UnityWebRequestAudio/Public/DownloadHandlerMovieTexture.h")] [NativeHeader("Runtime/Video/MovieTexture.h")] // for BIND_MANAGED_TYPE_NAME diff --git a/Modules/UnityWebRequestAudio/UnityWebRequestMultimedia.cs b/Modules/UnityWebRequestAudio/UnityWebRequestMultimedia.cs index 3ba60a2d37..bc75933600 100644 --- a/Modules/UnityWebRequestAudio/UnityWebRequestMultimedia.cs +++ b/Modules/UnityWebRequestAudio/UnityWebRequestMultimedia.cs @@ -19,11 +19,13 @@ public static UnityWebRequest GetAudioClip(Uri uri, AudioType audioType) } + [System.Obsolete("MovieTexture is deprecated. Use VideoPlayer instead.", false)] public static UnityWebRequest GetMovieTexture(string uri) { return new UnityWebRequest(uri, UnityWebRequest.kHttpVerbGET, new DownloadHandlerMovieTexture(), null); } + [System.Obsolete("MovieTexture is deprecated. Use VideoPlayer instead.", false)] public static UnityWebRequest GetMovieTexture(Uri uri) { return new UnityWebRequest(uri, UnityWebRequest.kHttpVerbGET, new DownloadHandlerMovieTexture(), null); diff --git a/Modules/UnityWebRequestWWW/Public/WWW.bindings.cs b/Modules/UnityWebRequestWWW/Public/WWW.bindings.cs index 3c978fc664..7caab7b804 100644 --- a/Modules/UnityWebRequestWWW/Public/WWW.bindings.cs +++ b/Modules/UnityWebRequestWWW/Public/WWW.bindings.cs @@ -15,6 +15,7 @@ internal static class WebRequestWWW [FreeFunction("UnityWebRequestCreateAudioClip")] internal extern static AudioClip InternalCreateAudioClipUsingDH(DownloadHandler dh, string url, bool stream, bool compressed, AudioType audioType); + [System.Obsolete("MovieTexture is deprecated. Use VideoPlayer instead.", false)] [FreeFunction("UnityWebRequestCreateMovieTexture")] internal extern static MovieTexture InternalCreateMovieTextureUsingDH(DownloadHandler dh); } diff --git a/Modules/UnityWebRequestWWW/Public/WWW.cs b/Modules/UnityWebRequestWWW/Public/WWW.cs index a070973721..c1505f4449 100644 --- a/Modules/UnityWebRequestWWW/Public/WWW.cs +++ b/Modules/UnityWebRequestWWW/Public/WWW.cs @@ -310,6 +310,7 @@ internal Object GetAudioClipInternal(bool threeD, bool stream, bool compressed, return WebRequestWWW.InternalCreateAudioClipUsingDH(_uwr.downloadHandler, _uwr.url, stream, compressed, audioType); } + [System.Obsolete("MovieTexture is deprecated. Use VideoPlayer instead.", false)] internal object GetMovieTextureInternal() { return WebRequestWWW.InternalCreateMovieTextureUsingDH(_uwr.downloadHandler); @@ -351,6 +352,7 @@ public AudioClip GetAudioClipCompressed(bool threeD, AudioType audioType) return (AudioClip)GetAudioClipInternal(threeD, false, true, audioType); } + [System.Obsolete("MovieTexture is deprecated. Use VideoPlayer instead.", false)] public MovieTexture GetMovieTexture() { return (MovieTexture)GetMovieTextureInternal(); diff --git a/Modules/VideoEditor/Editor/VideoPlayerEditor.cs b/Modules/VideoEditor/Editor/VideoPlayerEditor.cs index 19a1cb31de..96564f8dfc 100644 --- a/Modules/VideoEditor/Editor/VideoPlayerEditor.cs +++ b/Modules/VideoEditor/Editor/VideoPlayerEditor.cs @@ -543,8 +543,8 @@ private void HandleAudio() else { ushort trackCountBefore = (ushort)m_ControlledAudioTrackCount.intValue; - HandleControlledAudioTrackCount(); - if (m_ControlledAudioTrackCount.hasMultipleDifferentValues) + bool useControlledAudioTrackCount = HandleControlledAudioTrackCount(); + if (useControlledAudioTrackCount && m_ControlledAudioTrackCount.hasMultipleDifferentValues) EditorGUILayout.HelpBox(s_Styles.selectUniformAudioTracksHelp, MessageType.Warning, false); else { @@ -555,9 +555,19 @@ private void HandleAudio() // HandleControlledAudioTrackCount(). But this adjustment is // only done later so we conservatively only iterate over the // smallest known number of tracks we know are initialized. - ushort trackCount = (ushort)Math.Min( - (ushort)m_ControlledAudioTrackCount.intValue, trackCountBefore); - trackCount = (ushort)Math.Min(trackCount, m_EnabledAudioTracks.arraySize); + ushort trackCount = 0; + if (useControlledAudioTrackCount) + { + trackCount = (ushort)Math.Min( + (ushort)m_ControlledAudioTrackCount.intValue, trackCountBefore); + trackCount = (ushort)Math.Min(trackCount, m_EnabledAudioTracks.arraySize); + } + else + { + var clip = ((VideoPlayer)target).clip; + if (clip != null) + trackCount = clip.audioTrackCount; + } for (ushort trackIdx = 0; trackIdx < trackCount; ++trackIdx) { @@ -629,13 +639,13 @@ GUIContent GetAudioTrackEnabledContent(ushort trackIdx) return info.content; } - private void HandleControlledAudioTrackCount() + private bool HandleControlledAudioTrackCount() { // Won't show the widget for number of controlled tracks if we're // just using VideoClips (for which editing this property doesn't // make sense) or mixing VideoClips and URLs. if (m_DataSourceIsClip.value || m_DataSource.hasMultipleDifferentValues) - return; + return false; VideoPlayer player = (VideoPlayer)target; ushort audioTrackCount = serializedObject.isEditingMultipleObjects ? (ushort)0 : player.audioTrackCount; @@ -664,6 +674,7 @@ private void HandleControlledAudioTrackCount() } EditorGUILayout.PropertyField(m_ControlledAudioTrackCount, controlledAudioTrackCountContent); + return true; } private void PrepareCompleted(VideoPlayer vp) diff --git a/Projects/CSharp/UnityEditor.csproj b/Projects/CSharp/UnityEditor.csproj index a5140c409f..73b045964c 100644 --- a/Projects/CSharp/UnityEditor.csproj +++ b/Projects/CSharp/UnityEditor.csproj @@ -2459,6 +2459,9 @@ Editor\Mono\ObjectTreeForSelector.cs + + Editor\Mono\PackageManagerUtilityInternal.cs + Editor\Mono\PackageUtility.bindings.cs diff --git a/README.md b/README.md index 54cd4a194c..f6527f9413 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b7 C# reference source code +## Unity 2018.2.0b8 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Export/AnimationCurve.bindings.cs b/Runtime/Export/AnimationCurve.bindings.cs index 3fd532ea4a..21e59fe40b 100644 --- a/Runtime/Export/AnimationCurve.bindings.cs +++ b/Runtime/Export/AnimationCurve.bindings.cs @@ -160,29 +160,30 @@ public class AnimationCurve } // Evaluate the curve at /time/. + [ThreadSafe] extern public float Evaluate(float time); // All keys defined in the animation curve. public Keyframe[] keys { get { return GetKeys(); } set { SetKeys(value); } } // Add a new key to the curve. - [FreeFunction("AnimationCurveBindings::AddKeySmoothTangents", HasExplicitThis = true)] + [FreeFunction("AnimationCurveBindings::AddKeySmoothTangents", HasExplicitThis = true, IsThreadSafe = true)] extern public int AddKey(float time, float value); // Add a new key to the curve. public int AddKey(Keyframe key) { return AddKey_Internal(key); } - [NativeMethod("AddKey")] + [NativeMethod("AddKey", IsThreadSafe = true)] extern private int AddKey_Internal(Keyframe key); // Removes the keyframe at /index/ and inserts key. [NativeThrows] - [FreeFunction("AnimationCurveBindings::MoveKey", HasExplicitThis = true)] + [FreeFunction("AnimationCurveBindings::MoveKey", HasExplicitThis = true, IsThreadSafe = true)] extern public int MoveKey(int index, Keyframe key); // Removes a key [NativeThrows] - [FreeFunction("AnimationCurveBindings::RemoveKey", HasExplicitThis = true)] + [FreeFunction("AnimationCurveBindings::RemoveKey", HasExplicitThis = true, IsThreadSafe = true)] extern public void RemoveKey(int index); // Retrieves the key at index (RO) @@ -194,24 +195,24 @@ public Keyframe this[int index] // The number of keys in the curve (RO) extern public int length { - [NativeMethod("GetKeyCount")] + [NativeMethod("GetKeyCount", IsThreadSafe = true)] get; } // Replace all keyframes with the /keys/ array. - [FreeFunction("AnimationCurveBindings::SetKeys", HasExplicitThis = true)] + [FreeFunction("AnimationCurveBindings::SetKeys", HasExplicitThis = true, IsThreadSafe = true)] extern private void SetKeys(Keyframe[] keys); [NativeThrows] - [FreeFunction("AnimationCurveBindings::GetKey", HasExplicitThis = true)] + [FreeFunction("AnimationCurveBindings::GetKey", HasExplicitThis = true, IsThreadSafe = true)] extern private Keyframe GetKey(int index); - [FreeFunction("AnimationCurveBindings::GetKeys", HasExplicitThis = true)] + [FreeFunction("AnimationCurveBindings::GetKeys", HasExplicitThis = true, IsThreadSafe = true)] extern private Keyframe[] GetKeys(); // Smooth the in and out tangents of the keyframe at /index/. [NativeThrows] - [FreeFunction("AnimationCurveBindings::SmoothTangents", HasExplicitThis = true)] + [FreeFunction("AnimationCurveBindings::SmoothTangents", HasExplicitThis = true, IsThreadSafe = true)] extern public void SmoothTangents(int index, float weight); // A constant line at /value/ starting at /timeStart/ and ending at /timeEnd/ @@ -238,18 +239,18 @@ public static AnimationCurve EaseInOut(float timeStart, float valueStart, float // The behaviour of the animation before the first keyframe extern public WrapMode preWrapMode { - [NativeMethod("GetPreInfinity")] + [NativeMethod("GetPreInfinity", IsThreadSafe = true)] get; - [NativeMethod("SetPreInfinity")] + [NativeMethod("SetPreInfinity", IsThreadSafe = true)] set; } // The behaviour of the animation after the last keyframe extern public WrapMode postWrapMode { - [NativeMethod("GetPostInfinity")] + [NativeMethod("GetPostInfinity", IsThreadSafe = true)] get; - [NativeMethod("SetPostInfinity")] + [NativeMethod("SetPostInfinity", IsThreadSafe = true)] set; } diff --git a/Runtime/Export/Display.bindings.cs b/Runtime/Export/Display.bindings.cs index bc4b512d4d..0ed9227796 100644 --- a/Runtime/Export/Display.bindings.cs +++ b/Runtime/Export/Display.bindings.cs @@ -132,6 +132,9 @@ public static Vector3 RelativeMouseAt(Vector3 inputMouseCoordinates) [RequiredByNativeCode] private static void RecreateDisplayList(IntPtr[] nativeDisplay) { + if (nativeDisplay.Length == 0) // case 1017288 + return; + Display.displays = new Display[nativeDisplay.Length]; for (int i = 0; i < nativeDisplay.Length; ++i) Display.displays[i] = new Display(nativeDisplay[i]); diff --git a/artifacts/generated/bindings_old/common/Audio/MovieTextureBindings.gen.cs b/artifacts/generated/bindings_old/common/Audio/MovieTextureBindings.gen.cs index 6933321cd0..763edec2b7 100644 --- a/artifacts/generated/bindings_old/common/Audio/MovieTextureBindings.gen.cs +++ b/artifacts/generated/bindings_old/common/Audio/MovieTextureBindings.gen.cs @@ -21,6 +21,7 @@ namespace UnityEngine [ExcludeFromPreset] [ExcludeFromObjectFactory] +[Obsolete("MovieTexture is deprecated. Use VideoPlayer instead.", false)] public sealed partial class MovieTexture : Texture { private MovieTexture() {} diff --git a/artifacts/generated/bindings_old/common/Editor/PlayerSettingsWSABindings.gen.cs b/artifacts/generated/bindings_old/common/Editor/PlayerSettingsWSABindings.gen.cs index c7a0036a6c..419532afef 100644 --- a/artifacts/generated/bindings_old/common/Editor/PlayerSettingsWSABindings.gen.cs +++ b/artifacts/generated/bindings_old/common/Editor/PlayerSettingsWSABindings.gen.cs @@ -77,7 +77,19 @@ public enum WSACapability VoipCall = 21, Bluetooth = 22, SpatialPerception = 23, - InputInjectionBrokered = 24 + InputInjectionBrokered = 24, + Appointments = 25, + BackgroundMediaPlayback = 26, + Contacts = 27, + LowLevelDevices = 28, + OfflineMapsManagement = 29, + PhoneCallHistoryPublic = 30, + PointOfService = 31, + RecordedCallsFolder = 32, + RemoteSystem = 33, + SystemManagement = 34, + UserDataTasks = 35, + UserNotificationListener = 36, } public enum WSAImageScale From 96187e5fc1a23847206bf66b6f2d0e4a1ad43301 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Tue, 19 Jun 2018 13:54:09 +0000 Subject: [PATCH 08/13] Unity 2018.2.0b9 C# reference source code --- Editor/Mono/AssemblyInfo/AssemblyInfo.cs | 1 + Editor/Mono/BuildPipeline.bindings.cs | 6 ++ Editor/Mono/EditorGUIUtility.bindings.cs | 2 +- Editor/Mono/EditorUtility.cs | 2 +- Editor/Mono/GameView/GameView.cs | 23 +++++- Editor/Mono/LookDevView/LookDevConfig.cs | 10 ++- Editor/Mono/LookDevView/LookDevView.cs | 2 +- .../PreferencesWindow/PreferencesWindow.cs | 73 ++++++++-------- .../ScriptCompilation/EditorBuildRules.cs | 78 ++++++++++++++++-- .../ScriptCompilation/EditorCompilation.cs | 16 ++-- Editor/Mono/UIElements/Controls/EnumField.cs | 7 +- .../lib/mono/2.0/Boo.Lang.Compiler.dll | Bin 934912 -> 934912 bytes .../lib/mono/2.0/Boo.Lang.Parser.dll | Bin 414208 -> 414208 bytes .../lib/mono/2.0/Boo.Lang.dll | Bin 126976 -> 126976 bytes .../lib/mono/2.0/Mono.Posix.dll | Bin 184320 -> 184320 bytes .../lib/mono/2.0/Mono.Security.dll | Bin 294912 -> 294912 bytes .../lib/mono/2.0/System.Core.dll | Bin 297984 -> 297984 bytes .../lib/mono/2.0/System.Xml.Linq.dll | Bin 106496 -> 106496 bytes .../lib/mono/2.0/System.Xml.dll | Bin 1270272 -> 1270272 bytes .../monodistribution/lib/mono/2.0/System.dll | Bin 1679360 -> 1679360 bytes .../lib/mono/2.0/UnityScript.dll | Bin 177664 -> 177664 bytes .../Managed/BuildUsageCache.bindings.cs | 50 +++++++++++ .../Managed/ContentBuildInterface.bindings.cs | 36 +++++++- .../ShortcutManagerEditor/ShortcutEntry.cs | 25 +----- .../ShortcutProfileManager.cs | 69 ++++++++++------ .../Public/WebRequestExtensions.cs | 10 ++- Projects/CSharp/UnityEditor.csproj | 3 + README.md | 2 +- .../AnimationStreamHandles.bindings.cs | 45 ++++------ Runtime/Export/GraphicsComponents.bindings.cs | 4 +- Runtime/Export/GraphicsRenderers.bindings.cs | 4 +- .../RenderPipeline/CullingParameters.cs | 5 +- .../common/Core/LightBindings.gen.cs | 10 +++ 33 files changed, 337 insertions(+), 146 deletions(-) create mode 100644 Modules/BuildPipeline/Editor/Managed/BuildUsageCache.bindings.cs diff --git a/Editor/Mono/AssemblyInfo/AssemblyInfo.cs b/Editor/Mono/AssemblyInfo/AssemblyInfo.cs index 61d241dd26..1691ad1beb 100644 --- a/Editor/Mono/AssemblyInfo/AssemblyInfo.cs +++ b/Editor/Mono/AssemblyInfo/AssemblyInfo.cs @@ -89,5 +89,6 @@ [assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.004")] [assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.005")] [assembly: InternalsVisibleTo("com.unity.editor.resources-testable")] +[assembly: InternalsVisibleTo("Unity.XR.Remoting.Editor")] [assembly: AssemblyIsEditorAssembly] diff --git a/Editor/Mono/BuildPipeline.bindings.cs b/Editor/Mono/BuildPipeline.bindings.cs index e43e7aeb26..fa5494c040 100644 --- a/Editor/Mono/BuildPipeline.bindings.cs +++ b/Editor/Mono/BuildPipeline.bindings.cs @@ -444,6 +444,9 @@ public static AssetBundleManifest BuildAssetBundles(string outputPath, BuildAsse internal static AssetBundleManifest BuildAssetBundles(string outputPath, BuildAssetBundleOptions assetBundleOptions, BuildTargetGroup targetPlatformGroup, BuildTarget targetPlatform) { + if (isBuildingPlayer) + throw new InvalidOperationException("Cannot build asset bundles while a build is in progress."); + if (!System.IO.Directory.Exists(outputPath)) throw new ArgumentException("The output path \"" + outputPath + "\" doesn't exist"); @@ -461,6 +464,9 @@ public static AssetBundleManifest BuildAssetBundles(string outputPath, AssetBund internal static AssetBundleManifest BuildAssetBundles(string outputPath, AssetBundleBuild[] builds, BuildAssetBundleOptions assetBundleOptions, BuildTargetGroup targetPlatformGroup, BuildTarget targetPlatform) { + if (isBuildingPlayer) + throw new InvalidOperationException("Cannot build asset bundles while a build is in progress."); + if (!System.IO.Directory.Exists(outputPath)) throw new ArgumentException("The output path \"" + outputPath + "\" doesn't exist"); diff --git a/Editor/Mono/EditorGUIUtility.bindings.cs b/Editor/Mono/EditorGUIUtility.bindings.cs index 3c130c17a0..7ff219e37c 100644 --- a/Editor/Mono/EditorGUIUtility.bindings.cs +++ b/Editor/Mono/EditorGUIUtility.bindings.cs @@ -148,7 +148,7 @@ public static void RenderGameViewCameras(RenderTexture target, int targetDisplay internal static extern Texture2D GetIconForObject(Object obj); // Render all ingame cameras bound to a specific Display. - internal static extern void RenderGameViewCamerasInternal(RenderTexture target, int targetDisplay, Rect screenRect, Vector2 mousePosition, bool gizmos); + internal static extern void RenderGameViewCamerasInternal(RenderTexture target, int targetDisplay, Rect screenRect, Vector2 mousePosition, bool gizmos, bool sendInput); private static extern Texture2D FindTextureByName(string name); private static extern Texture2D FindTextureByType([NotNull] Type type); diff --git a/Editor/Mono/EditorUtility.cs b/Editor/Mono/EditorUtility.cs index 4f549185bf..ce20e0b403 100644 --- a/Editor/Mono/EditorUtility.cs +++ b/Editor/Mono/EditorUtility.cs @@ -317,7 +317,7 @@ internal static void Internal_DisplayPopupMenu(Rect position, string menuItemPat internal static void InitInstantiatedPreviewRecursive(GameObject go) { - go.hideFlags = HideFlags.DontSave; + go.hideFlags = HideFlags.HideAndDontSave; go.layer = Camera.PreviewCullingLayer; foreach (Transform c in go.transform) InitInstantiatedPreviewRecursive(c.gameObject); diff --git a/Editor/Mono/GameView/GameView.cs b/Editor/Mono/GameView/GameView.cs index f3cca06009..fbef4f35b0 100644 --- a/Editor/Mono/GameView/GameView.cs +++ b/Editor/Mono/GameView/GameView.cs @@ -726,6 +726,26 @@ private void EnforceZoomAreaConstraints() m_ZoomArea.shownArea = shownArea; } + public void RenderToHMDOnly() + { + ConfigureTargetTexture((int)targetSize.x, (int)targetSize.y); + + if (m_TargetTexture.IsCreated()) + { + var gizmos = false; + var targetDisplay = 0; + var sendInput = false; + + EditorGUIUtility.RenderGameViewCamerasInternal( + m_TargetTexture, + targetDisplay, + GUIClip.Unclip(viewInWindow), + Vector2.zero, + gizmos, + sendInput); + } + } + private void OnGUI() { if (position.size * EditorGUIUtility.pixelsPerPoint != m_LastWindowPixelSize) // pixelsPerPoint only reliable in OnGUI() @@ -800,7 +820,8 @@ private void OnGUI() } if (m_TargetTexture.IsCreated()) { - EditorGUIUtility.RenderGameViewCamerasInternal(m_TargetTexture, currentTargetDisplay, GUIClip.Unclip(viewInWindow), gameMousePosition, m_Gizmos); + var sendInput = true; + EditorGUIUtility.RenderGameViewCamerasInternal(m_TargetTexture, currentTargetDisplay, GUIClip.Unclip(viewInWindow), gameMousePosition, m_Gizmos, sendInput); oldState.ApplyAndForget(); GUIUtility.s_EditorScreenPointOffset = oldOffset; diff --git a/Editor/Mono/LookDevView/LookDevConfig.cs b/Editor/Mono/LookDevView/LookDevConfig.cs index c4e60b9a83..8b2a4613e5 100644 --- a/Editor/Mono/LookDevView/LookDevConfig.cs +++ b/Editor/Mono/LookDevView/LookDevConfig.cs @@ -428,7 +428,7 @@ public void SetCurrentPreviewObject(GameObject go, LookDevEditionContext context m_PreviewObjects[index][i] = m_LookDevView.previewUtilityContexts[index].m_PreviewUtility[i].InstantiatePrefabInScene(m_OriginalGameObject[index]); m_PreviewObjects[index][i].transform.position = new Vector3(0.0f, 0.0f, 0.0f); m_PreviewObjects[index][i].transform.rotation = Quaternion.identity; - EditorUtility.InitInstantiatedPreviewRecursive(m_PreviewObjects[index][i]); + InitInstantiatedPreviewRecursiveWithoutHidding(m_PreviewObjects[index][i]); DisableRendererProperties(m_PreviewObjects[index][i]); // Avoid light probe influence from the main scene (but still have the default probe lighting) PreviewRenderUtility.SetEnabledRecursive(m_PreviewObjects[index][i], false); } @@ -437,6 +437,14 @@ public void SetCurrentPreviewObject(GameObject go, LookDevEditionContext context } } + public static void InitInstantiatedPreviewRecursiveWithoutHidding(GameObject go) + { + go.hideFlags = HideFlags.DontSave; + go.layer = Camera.PreviewCullingLayer; + foreach (Transform c in go.transform) + InitInstantiatedPreviewRecursiveWithoutHidding(c.gameObject); + } + public void OnEnable() { if (m_LookDevContexts[0] == null) diff --git a/Editor/Mono/LookDevView/LookDevView.cs b/Editor/Mono/LookDevView/LookDevView.cs index f0dec38134..e3d378caa5 100644 --- a/Editor/Mono/LookDevView/LookDevView.cs +++ b/Editor/Mono/LookDevView/LookDevView.cs @@ -1346,7 +1346,7 @@ void EditorUpdate() if (currentObject == null) continue; - EditorUtility.InitInstantiatedPreviewRecursive(currentObject); // hide objects in hierarchy + LookDevConfig.InitInstantiatedPreviewRecursiveWithoutHidding(currentObject); LookDevConfig.DisableRendererProperties(currentObject); PreviewRenderUtility.SetEnabledRecursive(currentObject, false); } diff --git a/Editor/Mono/PreferencesWindow/PreferencesWindow.cs b/Editor/Mono/PreferencesWindow/PreferencesWindow.cs index 4ad68bb6af..d9ec7eb38c 100644 --- a/Editor/Mono/PreferencesWindow/PreferencesWindow.cs +++ b/Editor/Mono/PreferencesWindow/PreferencesWindow.cs @@ -3,7 +3,6 @@ // https://unity3d.com/legal/licenses/Unity_Reference_Only_License using UnityEngine; -using UnityEditor.VersionControl; using UnityEditor.Modules; using UnityEditorInternal; using System.Collections.Generic; @@ -12,12 +11,9 @@ using System.Reflection; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using UnityEditor.Connect; using UnityEditor.ShortcutManagement; -using Directory = System.IO.Directory; using UnityEditor.Collaboration; -using UnityEditor.Web; namespace UnityEditor { @@ -72,11 +68,10 @@ internal class Styles public static readonly GUIContent verifySavingAssets = EditorGUIUtility.TrTextContent("Verify Saving Assets"); public static readonly GUIContent scriptChangesDuringPlay = EditorGUIUtility.TrTextContent("Script Changes While Playing"); public static readonly GUIContent editorSkin = EditorGUIUtility.TrTextContent("Editor Skin"); - public static readonly GUIContent[] editorSkinOptions = new GUIContent[] { EditorGUIUtility.TrTextContent("Personal"), EditorGUIUtility.TrTextContent("Professional"), }; + public static readonly GUIContent[] editorSkinOptions = { EditorGUIUtility.TrTextContent("Personal"), EditorGUIUtility.TrTextContent("Professional") }; public static readonly GUIContent enableAlphaNumericSorting = EditorGUIUtility.TrTextContent("Enable Alpha Numeric Sorting"); // External Tools - public static readonly GUIContent downloadMonoDevelopInstaller = EditorGUIUtility.TrTextContent("Download MonoDevelop Installer"); public static readonly GUIContent addUnityProjeToSln = EditorGUIUtility.TrTextContent("Add .unityproj's to .sln"); public static readonly GUIContent editorAttaching = EditorGUIUtility.TrTextContent("Editor Attaching"); public static readonly GUIContent changingThisSettingRequiresRestart = EditorGUIUtility.TrTextContent("Changing this setting requires a restart to take effect."); @@ -213,11 +208,12 @@ private struct GICacheSettings private const string kRecentScriptAppsKey = "RecentlyUsedScriptApp"; private const string kRecentImageAppsKey = "RecentlyUsedImageApp"; - private const string m_ExpressNotSupportedMessage = - "Unfortunately Visual Studio Express does not allow itself to be controlled by external applications. " + - "You can still use it by manually opening the Visual Studio project file, but Unity cannot automatically open files for you when you doubleclick them. " + - "\n(This does work with Visual Studio Pro)"; - private const string kKeyCollisionFormat = "Key {0} can't be used for action \"{1}\" because it's already used for action \"{2}\""; + private static readonly string k_ExpressNotSupportedMessage = L10n.Tr( + "Unfortunately Visual Studio Express does not allow itself to be controlled by external applications. " + + "You can still use it by manually opening the Visual Studio project file, but Unity cannot automatically open files for you when you doubleclick them. " + + "\n(This does work with Visual Studio Pro)" + ); + private static readonly string k_KeyCollisionFormat = L10n.Tr("Key {0} can't be used for action \"{1}\" because it's already used for action \"{2}\""); private const int kRecentAppsCount = 10; @@ -428,7 +424,7 @@ private void ShowExternalApplications() { GUILayout.BeginHorizontal(EditorStyles.helpBox); GUILayout.Label("", constants.warningIcon); - GUILayout.Label(m_ExpressNotSupportedMessage, constants.errorLabel); + GUILayout.Label(k_ExpressNotSupportedMessage, constants.errorLabel); GUILayout.EndHorizontal(); } @@ -666,6 +662,9 @@ private SortedDictionary>> OrderPrefs(IE return retval; } + private readonly List> m_SortedKeyEntries = + new List>(); + private object ShowShortcutsAndKeys(int controlID) { int current = 0; @@ -674,35 +673,32 @@ private object ShowShortcutsAndKeys(int controlID) PrefKey currentPrefKey = null; var shortcutProfileManager = ShortcutIntegration.instance.profileManager; - foreach (ShortcutEntry shortcut in shortcutProfileManager.GetAllShortcuts()) + m_SortedKeyEntries.Clear(); + m_SortedKeyEntries.AddRange( + shortcutProfileManager.GetAllShortcuts().Select( + s => new KeyValuePair(s.identifier.path, s) + ) + ); + m_SortedKeyEntries.AddRange( + Settings.Prefs().Select(pk => new KeyValuePair(pk.Key, pk.Value)) + ); + m_SortedKeyEntries.Sort((k1, k2) => k1.Key.CompareTo(k2.Key)); + foreach (var keyEntry in m_SortedKeyEntries) { ++current; - selected = (current == m_SelectedShortcut); + selected = current == m_SelectedShortcut; + bool legacy = typeof(PrefKey).IsAssignableFrom(keyEntry.Value.GetType()); if (selected) - currentShortcutEntry = shortcut; - - using (var changeCheckScope = new EditorGUI.ChangeCheckScope()) { - if (GUILayout.Toggle(selected, shortcut.identifier.path, constants.keysElement)) - { - m_ValidKeyChange = !selected; - m_SelectedShortcut = current; - } - - if (changeCheckScope.changed) - GUIUtility.keyboardControl = controlID; + if (legacy) + currentPrefKey = (PrefKey)keyEntry.Value; + else + currentShortcutEntry = (ShortcutEntry)keyEntry.Value; } - } - foreach (KeyValuePair keypair in Settings.Prefs()) - { - ++current; - selected = (current == m_SelectedShortcut); - if (selected) - currentPrefKey = keypair.Value; using (var changeCheckScope = new EditorGUI.ChangeCheckScope()) { - if (GUILayout.Toggle(selected, keypair.Key, constants.keysElement)) + if (GUILayout.Toggle(selected, keyEntry.Key, constants.keysElement)) { m_ValidKeyChange = !selected; m_SelectedShortcut = current; @@ -776,7 +772,7 @@ private void CheckForCollisions(Event e, ShortcutEntry selectedShortcut, PrefKey if (collisions.Any()) { m_ValidKeyChange = false; - m_InvalidKeyMessage = string.Format(kKeyCollisionFormat, BuildDescription(e), identifier, collisions[0].identifier); + m_InvalidKeyMessage = string.Format(k_KeyCollisionFormat, BuildDescription(e), identifier, collisions[0].identifier); return; } @@ -794,20 +790,19 @@ private void CheckForCollisions(Event e, ShortcutEntry selectedShortcut, PrefKey if (collision.Key != null) { m_ValidKeyChange = false; - m_InvalidKeyMessage = string.Format(kKeyCollisionFormat, BuildDescription(e), identifier, collision.Key); + m_InvalidKeyMessage = string.Format(k_KeyCollisionFormat, BuildDescription(e), identifier, collision.Key); } } private void ShowShortcutConfiguration(int controlID, ShortcutEntry selectedShortcut) { // TODO: chords - Event e = selectedShortcut.combinations.First().ToKeyboardEvent(); + Event e = selectedShortcut.combinations.FirstOrDefault().ToKeyboardEvent(); GUI.changed = false; // FIXME: Are we going to support/enforce paths like this? - var splitKey = selectedShortcut.identifier.path.Split(kShortcutIdentifierSplitters, 2); - GUILayout.Label(splitKey[0], EditorStyles.boldLabel); - GUILayout.Label(splitKey[1], EditorStyles.boldLabel); + foreach (var label in selectedShortcut.identifier.path.Split(kShortcutIdentifierSplitters, 2)) + GUILayout.Label(label, EditorStyles.boldLabel); using (new GUILayout.HorizontalScope()) { diff --git a/Editor/Mono/Scripting/ScriptCompilation/EditorBuildRules.cs b/Editor/Mono/Scripting/ScriptCompilation/EditorBuildRules.cs index 6ed4b451fc..e4cf7e18c1 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/EditorBuildRules.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/EditorBuildRules.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using UnityEditor.Compilation; using UnityEditor.Scripting.Compilers; @@ -34,6 +35,7 @@ internal class TargetAssembly public string Filename { get; private set; } public SupportedLanguage Language { get; set; } public AssemblyFlags Flags { get; private set; } + public string PathPrefix { get; private set; } public Func PathFilter { get; private set; } public Func IsCompatibleFunc { get; private set; } public List References { get; private set; } @@ -50,6 +52,7 @@ public TargetAssembly(string name, SupportedLanguage language, AssemblyFlags flags, TargetAssemblyType type, + string pathPrefix, Func pathFilter, Func compatFunc, ScriptCompilerOptions compilerOptions) : this() @@ -57,6 +60,7 @@ public TargetAssembly(string name, Language = language; Filename = name; Flags = flags; + PathPrefix = pathPrefix; PathFilter = pathFilter; IsCompatibleFunc = compatFunc; Type = type; @@ -151,6 +155,35 @@ public static PrecompiledAssembly CreateEditorCompiledAssembly(string path) }; } + internal static bool FastStartsWith(string str, string prefix, string prefixLowercase) + { + int strLength = str.Length; + int prefixLength = prefix.Length; + + if (prefixLength > strLength) + return false; + + int lastPrefixCharIndex = prefixLength - 1; + + // Check last char in prefix is equal. Since we are comparing + // file paths against directory paths, the last char will be '/'. + if (str[lastPrefixCharIndex] != prefix[lastPrefixCharIndex]) + return false; + + for (int i = 0; i < prefixLength; ++i) + { + if (str[i] == prefix[i]) + continue; + + char strC = char.ToLower(str[i], CultureInfo.InvariantCulture); + + if (strC != prefixLowercase[i]) + return false; + } + + return true; + } + public static TargetAssembly[] CreateTargetAssemblies(IEnumerable customScriptAssemblies) { if (customScriptAssemblies == null) @@ -168,16 +201,18 @@ public static TargetAssembly[] CreateTargetAssemblies(IEnumerable(); var nameToTargetAssembly = new Dictionary(); + // Create TargetAssemblies foreach (var customAssembly in customScriptAssemblies) { - var pathPrefixLowerCase = customAssembly.PathPrefix.ToLower(); + var lowerPathPrefix = customAssembly.PathPrefix.ToLower(CultureInfo.InvariantCulture); var targetAssembly = new TargetAssembly(customAssembly.Name + ".dll", null, customAssembly.AssemblyFlags, TargetAssemblyType.Custom, - path => path.StartsWith(pathPrefixLowerCase) ? pathPrefixLowerCase.Length : -1, + customAssembly.PathPrefix, + path => FastStartsWith(path, customAssembly.PathPrefix, lowerPathPrefix) ? customAssembly.PathPrefix.Length : -1, (BuildTarget target, EditorScriptCompilationOptions options) => customAssembly.IsCompatibleWith(target, options), customAssembly.CompilerOptions) { @@ -641,6 +676,7 @@ internal static TargetAssembly[] CreatePredefinedTargetAssemblies() language, AssemblyFlags.FirstPass, TargetAssemblyType.Predefined, + null, FilterAssemblyInFirstpassFolder, null, scriptCompilerOptions); @@ -651,12 +687,14 @@ internal static TargetAssembly[] CreatePredefinedTargetAssemblies() TargetAssemblyType.Predefined, null, null, + null, scriptCompilerOptions); var editorFirstPass = new TargetAssembly("Assembly-" + languageName + "-Editor-firstpass" + ".dll", language, AssemblyFlags.EditorOnly | AssemblyFlags.FirstPass, TargetAssemblyType.Predefined, + null, FilterAssemblyInFirstpassEditorFolder, IsCompatibleWithEditor, scriptCompilerOptions) @@ -668,6 +706,7 @@ internal static TargetAssembly[] CreatePredefinedTargetAssemblies() language, AssemblyFlags.EditorOnly, TargetAssemblyType.Predefined, + null, FilterAssemblyInEditorFolder, IsCompatibleWithEditor, scriptCompilerOptions) @@ -707,6 +746,26 @@ internal static TargetAssembly[] CreatePredefinedTargetAssemblies() return assemblies.ToArray(); } + internal static TargetAssembly[] GetTargetAssembliesWithScripts(IEnumerable allScripts, + string projectDirectory, + TargetAssembly[] customTargetAssemblies, + ScriptAssemblySettings settings) + { + var uniqueTargetAssemblies = new HashSet(); + + foreach (var script in allScripts) + { + var targetAssembly = GetTargetAssembly(script, projectDirectory, customTargetAssemblies); + + if (!IsCompatibleWithPlatform(targetAssembly, settings)) + continue; + + uniqueTargetAssemblies.Add(targetAssembly); + } + + return uniqueTargetAssemblies.ToArray(); + } + internal static TargetAssembly GetTargetAssembly(string scriptPath, string projectDirectory, TargetAssembly[] customTargetAssemblies) { TargetAssembly resultAssembly = GetCustomTargetAssembly(scriptPath, projectDirectory, customTargetAssemblies); @@ -758,11 +817,16 @@ internal static TargetAssembly GetCustomTargetAssembly(string scriptPath, string // CustomScriptAssembly paths are absolute, so we convert the scriptPath to an absolute path, if necessary. bool isPathAbsolute = AssetPath.IsPathRooted(scriptPath); - var lowerFullPath = isPathAbsolute ? AssetPath.GetFullPath(scriptPath).ToLower() : AssetPath.Combine(projectDirectory, scriptPath).ToLower(); + var fullPath = isPathAbsolute ? AssetPath.GetFullPath(scriptPath) : AssetPath.Combine(projectDirectory, scriptPath); foreach (var assembly in customTargetAssemblies) { - int pathDepth = assembly.PathFilter(lowerFullPath); + int maxPathDepth = assembly.PathPrefix.Length; + + if (maxPathDepth <= highestPathDepth) + continue; + + int pathDepth = assembly.PathFilter(fullPath); if (pathDepth <= highestPathDepth) continue; @@ -804,15 +868,15 @@ static int FilterAssemblyInFirstpassEditorFolder(string pathName) static int FilterAssemblyInEditorFolder(string pathName) { const string editorSegment = "/editor/"; - int editorSegmentIndex = pathName.IndexOf(editorSegment); + int editorSegmentIndex = pathName.IndexOf(editorSegment, StringComparison.InvariantCulture); if (editorSegmentIndex == -1) return -1; return editorSegmentIndex + editorSegment.Length; } - static int FilterAssemblyPathBeginsWith(string pathName, string prefix) + static int FilterAssemblyPathBeginsWith(string pathName, string lowerPrefix) { - return pathName.StartsWith(prefix) ? prefix.Length : -1; + return FastStartsWith(pathName, lowerPrefix, lowerPrefix) ? lowerPrefix.Length : -1; } } } diff --git a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs index 0ff8a66593..c890b9070c 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs @@ -1155,17 +1155,15 @@ public TargetAssemblyInfo[] GetTargetAssemblies() public TargetAssemblyInfo[] GetTargetAssembliesWithScripts(EditorScriptCompilationOptions options) { - var scriptAssemblies = GetAllScriptAssemblies(EditorScriptCompilationOptions.BuildingForEditor | options); - var targetAssemblies = new TargetAssemblyInfo[scriptAssemblies.Length]; + ScriptAssemblySettings settings = CreateEditorScriptAssemblySettings(EditorScriptCompilationOptions.BuildingForEditor | options); + var targetAssemblies = EditorBuildRules.GetTargetAssembliesWithScripts(allScripts, projectDirectory, customTargetAssemblies, settings); - for (int i = 0; i < scriptAssemblies.Length; ++i) - { - var scriptAssembly = scriptAssemblies[i]; - targetAssemblies[i].Name = scriptAssembly.Filename; - targetAssemblies[i].Flags = scriptAssembly.Flags; - } + var targetAssemblyInfos = new TargetAssemblyInfo[targetAssemblies.Length]; - return targetAssemblies; + for (int i = 0; i < targetAssemblies.Length; ++i) + targetAssemblyInfos[i] = ToTargetAssemblyInfo(targetAssemblies[i]); + + return targetAssemblyInfos; } public ScriptAssembly[] GetAllScriptAssembliesForLanguage(EditorScriptCompilationOptions additionalOptions) where T : SupportedLanguage diff --git a/Editor/Mono/UIElements/Controls/EnumField.cs b/Editor/Mono/UIElements/Controls/EnumField.cs index c7d7a1df25..b829d48550 100644 --- a/Editor/Mono/UIElements/Controls/EnumField.cs +++ b/Editor/Mono/UIElements/Controls/EnumField.cs @@ -105,12 +105,15 @@ public override void SetValueAndNotify(Enum newValue) } } - protected internal override void ExecuteDefaultAction(EventBase evt) + protected internal override void ExecuteDefaultActionAtTarget(EventBase evt) { - base.ExecuteDefaultAction(evt); + base.ExecuteDefaultActionAtTarget(evt); if ((evt as MouseDownEvent)?.button == (int)MouseButton.LeftMouse || (evt as KeyDownEvent)?.character == '\n') + { ShowMenu(); + evt.StopPropagation(); + } } private void ShowMenu() diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.Compiler.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.Compiler.dll index 088e5e73bd0c19041aca725686b7c75205c6beed..e6fa458cece914f0b836c8d3a97357f4d5be1fe2 100644 GIT binary patch delta 216 zcmV;}04M)|h&h0WIgp40mbo5*i-n5;g^L1(ivxv=1ci$Qg^LD-iwA{^2!)FYg^LP> ziwlK|426pgwTljoIe);!LZj7;JxY+}`@j(LQnGK1<<=pk5etG|7Biz#AG3m%rH!<7 z9IMOgkpBKk%g(xrN@o0R3jTvt*K_7k+&|5Cnym4{nb_bT+47DTCB3$mS=HkgwEYf? zSdu{s0k;l34)O ziwlK|426pgwTljoIe+t|)x&8AWKFNAL0)hjKMC0sZO4^fWDMlgAW{l*5^m_v3XDG_T8*!i*;xqe!Lb$!m{ S@=SiWK|l^>0k;l34)Odh2*WqigHOH9 z56xfe?lfpI-unQLU3rhzU9FDs7aJ5bB)_%5D`?%U`*?eArJ}hLTTC05l{wp0k;lJ2J!`~Xj=*Z delta 192 zcmV;x06+hLq#1yu8IXtrg>Vpoi-n5;g^L1(ivxv=1ci$QwTlLQNq^BEaQ5KWokX>H z;(c)q?glh1!xRie7e2b7MT7xh?<`k_M&FNt>0U?!-Ead#Les{GX=tt%ix1txGDupC z(g)hzakHv~qranqw%5G^065e)WNInO{#ih8?Wb|wR5ZP0qP#^uCaKZcXi@)TB1yeO uJ{|4wR{liQ?b*fvZ4sXE;2m_8ed=7l#KBVuhMQZr5l{wp0k;lJ2J!{gm|3y_ diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/Boo.Lang.dll index 924f4f50ecb13fa119f2e7b73afbc7029b80c3f2..8314c4243f250877818dc12ab6e4f058dfefc2cf 100644 GIT binary patch delta 177 zcmV;i08ama;0J)<2at#ZlDQs%i?xdZ1?7M0gZg#|Q58+T4=E6?lMn&p&X{YV0Tav9R&;FNr z;w86ABsv^G9UFIZJMF`N6nwW2M8bP1(93f}po#nW1;*G!D(yz2Op#=h4B+p6E42|N f8CDv8xE%;D*wD&==+qi;w-N3E?g6(B=mGKvRhd!| delta 177 zcmV;i08ama;0J)<2at#ZesB*djY^}E45XmM{$whZqK_*J_@wW&)AoDq_s_Q$!e2at*@mR#@-Bt hgAugU8H>N$UERGxeYCT+tc=%}QOyE+w+_kz@&!R>Te<)M delta 179 zcmV;k08IaYpbLPY3y_EdvTYE7i-n5;wTl9I$bWgwsuL1d3`4Wjq(E!S*p8eYxWaYx z&U)IQ#?=xZ%5}AOQPfy=5C#Hvg6;*K8^_p~y_g0~q0@|SnF|w5aZk;?1bwkoint~a zLOn&IJ-D=`|9VBC!sPwu8Z(;I{6>9kq-xTszV_I%%()w4PKUfK^3xl#5|okkH6O1U hml5f9?m&ec&*E|#>V_wbK;VLxQOyE+w+_kz@&%pgSk?dl diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/Mono.Security.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/Mono.Security.dll index e925040ee8c7c37ad1bdd2512ed1feda84e29bd8..66ad7863c6ee6e47ba148f82d67f7d3825163c01 100644 GIT binary patch delta 185 zcmV;q07n0SfD(X!5|D@k_qHB^i-n5;g^L1(ivzWb1U-0v#SLX?rtGdmf>3o!Pe5D= zI|D3M*JQK-S&iFtAr_Ot7gtpbuzChOPG!_&QZM^nZk$i)=v1eU{y}EDkAzI#P zK-$v_ncq86dh$KXWsmrVs1#V4^{Ao4`4Clh`4oiykk2DlaWLQa$c8-D2ImK$bR-jH naO`OoATjh2@!B@Z6O6QH>1>A5CpuR8!i-n5;g^L1(ivzWb1l@ywXX;XO+ZHoSfazIDqzh*_ z=>bK@GRlzM^AREv*el|{aX|Y+fq2-BiKwDn`S_jem89vqM z9400--J>Gptr&|GYY%e>hv67xrHMB?x&k#n!4K}dEJFZGSQbxt2E}xnFzx5laQvOP~#82^$kM&Z@_39vm(Z6-zOk>OV o9@N`3r1@YG2>aEo`P-jwGB4?!L)p&NKDQBy1Qr3e4u%Bs1@u8*X8-^I diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.Linq.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.Linq.dll index 8d93f08fc74402bbb4e2ec110e61bd16958b053b..aeb934e28f35d3a6f36fbff8a2b34d9b4d8a54c6 100644 GIT binary patch delta 179 zcmV;k08IaYzy^T829SsYuD2e6i?xdZ>6CxVr&mwQG{Z=fhcqU%nAFb49Y>cR|9*_Q zldD*EfuBCMTULN$a&dW`3@68xfzJNvMh+OUUwK{APfxL>df(&WHf=SXPqX<+9{n#F z3DP$RR86(9>Co*C%44%{jP?kQgaLShMipSx<~T?}J3KfLbVC6`d_0JCo)>mkgbfkG h!FE2d%;{H_+`;>O(ki|trvaP+0+BEZw+@&A@&}U6Q^^1T delta 179 zcmV;k08IaYzy^T829SsYfNl_hi?xdZ>6CwL6YO^u$*WDf!(e1_lLlB{PtP6Nh#rH` z#MLF-zryCsE**LLH$tQhy7afnb`Pli_2A<)E#273_yEdyZ)1%udM6tv*{vV+ze97l zlZU1}Zb13ylym1>{DmyTE;N?1s*LWj7oN))W$ovbh{}87M@dMSxJ)~|=X_%uFY*!8 h)IxrMuRNenzmg;fq+pF@rvaP+0+BEZw+@&A@&`BES-$`P diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/System.Xml.dll index bc4a33a5b70cb363da48d3e23b4f44a04daa4774..8860890f02280e26e23058e10c10457917b9c3da 100644 GIT binary patch delta 230 zcmV ziwlK|426pgg^Lb_iw}j15QU2og^LokixU}If5L{dUdZC-N0y{;*TEe*Zj2*X!I$(^ z@({a1u>891afXhf_3Txurq++h7st~;0fl{<{0_O9TrVBMG0N$=fbgv9LnI8z5M-ZN zfyU*O(g#3*w{62v9o&%!d7E?O3}9o6J}awJ3AMCHHO-jp98hGAZ3RpM_N3q!ml=KD g5jER47Gq2v4qHE;cM&_B?cSFWU=!N64qOxR1;_?z*8l(j delta 230 zcmV ziwlK|426pgg^Lb_iw}j15QU2og^LokixU}Ie+#_}nNc!oO`uRq8!(m5u^ORMpcE*> z>_jAD&3%L*F9`LO g5%H(2=CnY$j>Ci^zmonjE_;^|U=!N64qOxR1vL|4IRF3v diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/System.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/System.dll index 2b045a346f6f9cb533cb3b0fbcd148e98982e54c..6683bb3f0bce4e03adc517cee95ced0c994a241a 100644 GIT binary patch delta 246 zcmV ziwlK|426pgg^Lb_iw}j15QU2og^Ln}ixY*56orcwg^L!2ix-897`2NT*_eOZ05M^3 z5C=e+OOd?iL*^3xyyep&qd&HQ=F$?E#DwEACyt8(c9CBWz9q!(c0sEH#FZ7lyeaS4 z#}Dbfnzq;XX1?1JWL`zUm%Ob5xZ;qr9!5SCr#-_O))pRI_3+5-Yp)m@OARDWVg64l wd&Z5rzbZQTZm;l}qbt0)UhNS=i<^yIy3-J8kNr ziwlK|426pgg^Lb_iw}j15QU2og^Ln}ixY*56orcwg^L!2ix-897`2NT*_eOv{E6_% zSC2@sS{K}~a5ZNf=scg<@bdf49-ks%tl4w@PA1(&aRtN;K2 diff --git a/External/Mono/builds/monodistribution/lib/mono/2.0/UnityScript.dll b/External/Mono/builds/monodistribution/lib/mono/2.0/UnityScript.dll index 39c785618d73017da2dd1163a45a7f752f285c9b..b8b660dd56a5dd89841ada41aa669f1947d258f6 100644 GIT binary patch delta 123 zcmV->0EGX5>0EGX5> m_DefaultCombinations = new List(); - public readonly KeyCombination? prefKeyMigratedValue; List m_OverridenCombinations; readonly Action m_Action; @@ -71,14 +70,13 @@ class ShortcutEntry public Type context => m_Context; public ShortcutType type => m_Type; - internal ShortcutEntry(Identifier id, List defaultCombination, Action action, Type context, ShortcutType type, KeyCombination? prefKeyMigratedValue = null) + internal ShortcutEntry(Identifier id, List defaultCombination, Action action, Type context, ShortcutType type) { m_Identifier = id; m_DefaultCombinations = new List(defaultCombination); m_Context = context ?? ContextManager.globalContextType; m_Action = action; m_Type = type; - this.prefKeyMigratedValue = prefKeyMigratedValue; } internal static ShortcutEntry CreateFromAttribute(MethodInfo methodInfo, ShortcutAttribute attribute) @@ -107,26 +105,7 @@ internal static ShortcutEntry CreateFromAttribute(MethodInfo methodInfo, Shortcu }; } - KeyCombination? prefKeyMigratedValue = null; - var prefKeyAttr = methodInfo.GetCustomAttributes( - typeof(FormerlyPrefKeyAsAttribute), false - ).FirstOrDefault() as FormerlyPrefKeyAsAttribute; - if (prefKeyAttr != null) - { - var prefKeyDefaultValue = new KeyCombination(Event.KeyboardEvent(prefKeyAttr.defaultValue)); - string name; - Event keyboardEvent; - if ( - PrefKey.TryParseUniquePrefString(EditorPrefs.GetString(prefKeyAttr.name, prefKeyAttr.defaultValue), out name, out keyboardEvent) - ) - { - var prefKeyCurrentValue = new KeyCombination(keyboardEvent); - if (!prefKeyCurrentValue.Equals(prefKeyDefaultValue)) - prefKeyMigratedValue = prefKeyCurrentValue; - } - } - - return new ShortcutEntry(identifier, defaultCombination, action, attribute.context, type, prefKeyMigratedValue); + return new ShortcutEntry(identifier, defaultCombination, action, attribute.context, type); } public override string ToString() diff --git a/Modules/ShortcutManagerEditor/ShortcutProfileManager.cs b/Modules/ShortcutManagerEditor/ShortcutProfileManager.cs index 1aceb74b59..f1921c6762 100644 --- a/Modules/ShortcutManagerEditor/ShortcutProfileManager.cs +++ b/Modules/ShortcutManagerEditor/ShortcutProfileManager.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using UnityEngine; namespace UnityEditor.ShortcutManagement @@ -23,7 +24,7 @@ interface IShortcutProfileManager class ShortcutProfileManager : IShortcutProfileManager { const string k_UserProfileId = "UserProfile"; - IEnumerable entries; + readonly List m_Entries; ShortcutProfile m_ActiveProfile = new ShortcutProfile(); public event Action shortcutsModified; @@ -32,35 +33,19 @@ class ShortcutProfileManager : IShortcutProfileManager public ShortcutProfileManager(IEnumerable baseProfile) { - entries = baseProfile.ToList(); + m_Entries = baseProfile.ToList(); } public IEnumerable GetAllShortcuts() { - return entries; + return m_Entries; } - internal void ApplyProfile(ShortcutProfile shortcutProfile, bool migratePrefKeys = false) + internal void ApplyProfile(ShortcutProfile shortcutProfile) { - // pref keys should only be migrated when the default user profile is applied - if (migratePrefKeys) - { - foreach (var entry in entries) - { - if (entry.prefKeyMigratedValue != null) - { - var overrideEntry = new SerializableShortcutEntry - { - identifier = entry.identifier, - keyCombination = new List { entry.prefKeyMigratedValue.Value } - }; - entry.ApplyOverride(overrideEntry); - } - } - } foreach (var shortcutOverride in shortcutProfile.entries) { - var entry = entries.FirstOrDefault(e => e.identifier.Equals(shortcutOverride.identifier)); + var entry = m_Entries.FirstOrDefault(e => e.identifier.Equals(shortcutOverride.identifier)); if (entry != null) { entry.ApplyOverride(shortcutOverride); @@ -71,7 +56,7 @@ internal void ApplyProfile(ShortcutProfile shortcutProfile, bool migratePrefKeys public void ResetToDefault() { - foreach (var entry in entries) + foreach (var entry in m_Entries) { entry.ResetToDefault(); } @@ -80,12 +65,48 @@ public void ResetToDefault() public void ApplyActiveProfile() { m_ActiveProfile = new ShortcutProfile(k_UserProfileId); - ApplyProfile(m_ActiveProfile, true); + ApplyProfile(m_ActiveProfile); + MigrateUserSpecifiedPrefKeys( + EditorAssemblies.GetAllMethodsWithAttribute(), m_Entries + ); + } + + internal static void MigrateUserSpecifiedPrefKeys( + IEnumerable methodsWithFormerlyPrefKeyAs, List entries + ) + { + foreach (var method in methodsWithFormerlyPrefKeyAs) + { + var shortcutAttr = + Attribute.GetCustomAttribute(method, typeof(ShortcutAttribute), true) as ShortcutAttribute; + if (shortcutAttr == null) + continue; + + var entry = entries.Find(e => string.Equals(e.identifier.path, shortcutAttr.identifier)); + // ignore former PrefKeys if the shortcut profile has already loaded and applied an override + if (entry == null || entry.overridden) + continue; + + var prefKeyAttr = + (FormerlyPrefKeyAsAttribute)Attribute.GetCustomAttribute(method, typeof(FormerlyPrefKeyAsAttribute)); + var prefKeyDefaultValue = new KeyCombination(Event.KeyboardEvent(prefKeyAttr.defaultValue)); + string name; + Event keyboardEvent; + var parsed = PrefKey.TryParseUniquePrefString( + EditorPrefs.GetString(prefKeyAttr.name, prefKeyAttr.defaultValue), out name, out keyboardEvent + ); + if (!parsed) + continue; + var prefKeyCurrentValue = new KeyCombination(keyboardEvent); + // only migrate pref keys that the user actually overwrote + if (!prefKeyCurrentValue.Equals(prefKeyDefaultValue)) + entry.SetOverride(new List { prefKeyCurrentValue }); + } } public void ModifyShortcutEntry(Identifier identifier, List combinationSequence) { - var shortcutEntry = entries.FirstOrDefault(e => e.identifier.Equals(identifier)); + var shortcutEntry = m_Entries.FirstOrDefault(e => e.identifier.Equals(identifier)); shortcutEntry.SetOverride(combinationSequence); SerializableShortcutEntry profileEntry = null; diff --git a/Modules/UnityWebRequest/Public/WebRequestExtensions.cs b/Modules/UnityWebRequest/Public/WebRequestExtensions.cs index 9f1a7170cc..6ea44043ab 100644 --- a/Modules/UnityWebRequest/Public/WebRequestExtensions.cs +++ b/Modules/UnityWebRequest/Public/WebRequestExtensions.cs @@ -321,6 +321,9 @@ public static string UnEscapeURL(string s, Encoding e) public static byte[] SerializeFormSections(List multipartFormSections, byte[] boundary) { + if (multipartFormSections == null || multipartFormSections.Count == 0) + return null; + byte[] crlf = System.Text.Encoding.UTF8.GetBytes("\r\n"); byte[] dDash = WWWForm.DefaultEncoding.GetBytes("--"); @@ -367,7 +370,12 @@ public static byte[] SerializeFormSections(List multipart formData.AddRange(section.sectionData); } - formData.TrimExcess(); + // end sections with boundary delimiter (https://tools.ietf.org/html/rfc2046) + formData.AddRange(crlf); + formData.AddRange(dDash); + formData.AddRange(boundary); + formData.AddRange(dDash); + formData.AddRange(crlf); return formData.ToArray(); } diff --git a/Projects/CSharp/UnityEditor.csproj b/Projects/CSharp/UnityEditor.csproj index 73b045964c..0109f76336 100644 --- a/Projects/CSharp/UnityEditor.csproj +++ b/Projects/CSharp/UnityEditor.csproj @@ -3707,6 +3707,9 @@ Modules\BuildPipeline\Editor\Managed\BuildSettings.cs + + Modules\BuildPipeline\Editor\Managed\BuildUsageCache.bindings.cs + Modules\BuildPipeline\Editor\Managed\BuildUsageTagGlobal.cs diff --git a/README.md b/README.md index f6527f9413..e56b56694e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b8 C# reference source code +## Unity 2018.2.0b9 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Animation/ScriptBindings/AnimationStreamHandles.bindings.cs b/Runtime/Animation/ScriptBindings/AnimationStreamHandles.bindings.cs index 186359acc1..3ad48639b4 100644 --- a/Runtime/Animation/ScriptBindings/AnimationStreamHandles.bindings.cs +++ b/Runtime/Animation/ScriptBindings/AnimationStreamHandles.bindings.cs @@ -38,7 +38,7 @@ public bool IsValid(AnimationStream stream) private bool IsValidInternal(ref AnimationStream stream) { - return stream.isValid && createdByNative; + return stream.isValid && createdByNative && hasHandleIndex; } private bool createdByNative @@ -82,7 +82,6 @@ private bool IsResolvedInternal(ref AnimationStream stream) { return IsValidInternal(ref stream) && IsSameVersionAsStream(ref stream) && - hasHandleIndex && hasSkeletonIndex; } @@ -95,7 +94,7 @@ private void CheckIsValidAndResolve(ref AnimationStream stream) return; // Handle create directly by user are never valid - if (!createdByNative) + if (!createdByNative || !hasHandleIndex) throw new InvalidOperationException("The TransformStreamHandle is invalid. Please use proper function to create the handle."); if (!IsSameVersionAsStream(ref stream) || (hasHandleIndex && !hasSkeletonIndex)) @@ -172,7 +171,7 @@ public bool IsValid(AnimationStream stream) private bool IsValidInternal(ref AnimationStream stream) { - return stream.isValid && createdByNative; + return stream.isValid && createdByNative && hasHandleIndex && hasBindType; } private bool createdByNative @@ -221,8 +220,6 @@ private bool IsResolvedInternal(ref AnimationStream stream) { return IsValidInternal(ref stream) && IsSameVersionAsStream(ref stream) && - hasBindType && - hasHandleIndex && hasValueArrayIndex; } @@ -235,7 +232,7 @@ private void CheckIsValidAndResolve(ref AnimationStream stream) return; // Handle create directly by user are never valid - if (!createdByNative || !hasBindType) + if (!createdByNative || !hasHandleIndex || !hasBindType) throw new InvalidOperationException("The PropertyStreamHandle is invalid. Please use proper function to create the handle."); if (!IsSameVersionAsStream(ref stream) || (hasHandleIndex && !hasValueArrayIndex)) @@ -327,10 +324,11 @@ public struct TransformSceneHandle public bool IsValid(AnimationStream stream) { + // [case 1032369] Cannot call native code before validating that handle was created in native and has a valid handle index return stream.isValid && createdByNative && - HasValidTransform(ref stream) && - hasTransformSceneHandleDefinitionIndex; + hasTransformSceneHandleDefinitionIndex && + HasValidTransform(ref stream); } private bool createdByNative @@ -348,19 +346,13 @@ private void CheckIsValid(ref AnimationStream stream) // Verify stream. stream.CheckIsValid(); - var hasValidTransform = HasValidTransform(ref stream); - if (createdByNative && hasValidTransform && hasTransformSceneHandleDefinitionIndex) - return; - // Handle create directly by user are never valid - if (!createdByNative) + if (!createdByNative || !hasTransformSceneHandleDefinitionIndex) throw new InvalidOperationException("The TransformSceneHandle is invalid. Please use proper function to create the handle."); - if (!hasValidTransform) + // [case 1032369] Cannot call native code before validating that handle was created in native and has a valid handle index + if (!HasValidTransform(ref stream)) throw new NullReferenceException("The transform is invalid."); - - if (!hasTransformSceneHandleDefinitionIndex) - throw new InvalidOperationException("The TransformSceneHandle cannot be resolved."); } public Vector3 GetPosition(AnimationStream stream) @@ -471,10 +463,11 @@ public bool IsValid(AnimationStream stream) private bool IsValidInternal(ref AnimationStream stream) { + // [case 1032369] Cannot call native code before validating that handle was created in native and has a valid handle index return stream.isValid && createdByNative && - HasValidTransform(ref stream) && - hasHandleIndex; + hasHandleIndex && + HasValidTransform(ref stream); } private bool createdByNative @@ -503,19 +496,13 @@ private void CheckIsValid(ref AnimationStream stream) // Verify stream. stream.CheckIsValid(); - var hasValidTransform = HasValidTransform(ref stream); - if (createdByNative && hasValidTransform && hasHandleIndex) - return; - // Handle create directly by user are never valid - if (!createdByNative) + if (!createdByNative || !hasHandleIndex) throw new InvalidOperationException("The PropertySceneHandle is invalid. Please use proper function to create the handle."); - if (!hasValidTransform) + // [case 1032369] Cannot call native code before validating that handle was created in native and has a valid handle index + if (!HasValidTransform(ref stream)) throw new NullReferenceException("The transform is invalid."); - - if (!hasHandleIndex) - throw new InvalidOperationException("The PropertySceneHandle cannot be resolved."); } public float GetFloat(AnimationStream stream) diff --git a/Runtime/Export/GraphicsComponents.bindings.cs b/Runtime/Export/GraphicsComponents.bindings.cs index 50de529da0..24e58db973 100644 --- a/Runtime/Export/GraphicsComponents.bindings.cs +++ b/Runtime/Export/GraphicsComponents.bindings.cs @@ -111,8 +111,10 @@ public sealed partial class Skybox : Behaviour [NativeHeader("Runtime/Graphics/Mesh/MeshFilter.h")] public sealed partial class MeshFilter : Component { + [RequiredByNativeCode] // MeshFilter is used in the VR Splash screen. + private void DontStripMeshFilter() {} + extern public Mesh sharedMesh { get; set; } - [RequiredByNativeCode] // Used in the VR Splash screen. extern public Mesh mesh {[NativeName("GetInstantiatedMeshFromScript")] get; [NativeName("SetInstantiatedMesh")] set; } } diff --git a/Runtime/Export/GraphicsRenderers.bindings.cs b/Runtime/Export/GraphicsRenderers.bindings.cs index ad57e106a2..c8144076fe 100644 --- a/Runtime/Export/GraphicsRenderers.bindings.cs +++ b/Runtime/Export/GraphicsRenderers.bindings.cs @@ -298,7 +298,9 @@ public partial class SkinnedMeshRenderer : Renderer [NativeHeader("Runtime/Graphics/Mesh/MeshRenderer.h")] public partial class MeshRenderer : Renderer { - [RequiredByNativeCode] // Used in the VR Splash screen. + [RequiredByNativeCode] // MeshRenderer is used in the VR Splash screen. + private void DontStripMeshRenderer() {} + extern public Mesh additionalVertexStreams { get; set; } extern public int subMeshStartIndex {[NativeName("GetSubMeshStartIndex")] get; } } diff --git a/Runtime/Export/RenderPipeline/CullingParameters.cs b/Runtime/Export/RenderPipeline/CullingParameters.cs index 899c14bf89..e3123a3d26 100644 --- a/Runtime/Export/RenderPipeline/CullingParameters.cs +++ b/Runtime/Export/RenderPipeline/CullingParameters.cs @@ -119,8 +119,9 @@ public enum CullFlag ForceEvenIfCameraIsNotActive = 1 << 0, OcclusionCull = 1 << 1, NeedsLighting = 1 << 2, - Stereo = 1 << 3, - DisablePerObjectCulling = 1 << 4 + NeedsReflectionProbes = 1 << 3, + Stereo = 1 << 4, + DisablePerObjectCulling = 1 << 5 }; diff --git a/artifacts/generated/bindings_old/common/Core/LightBindings.gen.cs b/artifacts/generated/bindings_old/common/Core/LightBindings.gen.cs index 8f77a71896..2625b41e97 100644 --- a/artifacts/generated/bindings_old/common/Core/LightBindings.gen.cs +++ b/artifacts/generated/bindings_old/common/Core/LightBindings.gen.cs @@ -71,6 +71,16 @@ public extern float shadowSoftnessFade set; } + public extern float[] layerShadowCullDistances + { + [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration + [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] + get; + [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration + [System.Runtime.CompilerServices.MethodImplAttribute((System.Runtime.CompilerServices.MethodImplOptions)0x1000)] + set; + } + public extern float cookieSize { [UnityEngine.Scripting.GeneratedByOldBindingsGeneratorAttribute] // Temporarily necessary for bindings migration From 54dd67f09e090b1ad5ba1f55886f327106406b0c Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Tue, 26 Jun 2018 13:53:45 +0000 Subject: [PATCH 09/13] Unity 2018.2.0b10 C# reference source code --- Editor/Mono/BuildPipeline.bindings.cs | 2 +- .../AndroidPostGenerateGradleProject.cs | 55 ++++++++++++ Editor/Mono/BuildPlayerWindow.cs | 3 +- Editor/Mono/Commands/GOCreationCommands.cs | 1 + Editor/Mono/ContainerWindow.cs | 1 + Editor/Mono/EditorApplication.bindings.cs | 9 +- .../TreeViewControl/TreeViewControl.cs | 7 ++ .../Mono/GUI/TreeView/TreeViewController.cs | 6 +- Editor/Mono/Inspector/CameraEditor.cs | 8 +- Editor/Mono/Inspector/CameraEditorUtils.cs | 84 +++++++++++++------ Editor/Mono/Inspector/LightEditor.cs | 11 +-- Editor/Mono/Modules/ModuleManager.cs | 2 +- .../ScriptCompilation/EditorCompilation.cs | 13 +++ .../EditorCompilationInterface.cs | 6 ++ Projects/CSharp/UnityEditor.csproj | 3 + README.md | 2 +- .../AnimationStream.bindings.cs | 8 +- .../AnimatorJobExtensions.bindings.cs | 1 + Runtime/Export/Camera.bindings.cs | 6 +- Runtime/Export/GraphicsEnums.cs | 1 + Runtime/Export/SystemInfo.bindings.cs | 26 +++++- .../HolographicRemoting.cs | 2 +- 22 files changed, 204 insertions(+), 53 deletions(-) create mode 100644 Editor/Mono/BuildPipeline/Android/AndroidPostGenerateGradleProject.cs diff --git a/Editor/Mono/BuildPipeline.bindings.cs b/Editor/Mono/BuildPipeline.bindings.cs index fa5494c040..5dc5d68408 100644 --- a/Editor/Mono/BuildPipeline.bindings.cs +++ b/Editor/Mono/BuildPipeline.bindings.cs @@ -512,7 +512,7 @@ internal static string GetPlaybackEngineDirectory(BuildTarget target, BuildOptio [FreeFunction(IsThreadSafe = true)] internal static extern string GetPlaybackEngineExtensionDirectory(BuildTargetGroup buildTargetGroup, BuildTarget target, BuildOptions options); - internal static extern void SetPlaybackEngineDirectory(BuildTarget target, BuildOptions options, string playbackEngineDirectory); + internal static extern void SetPlaybackEngineDirectory(BuildTargetGroup targetGroup, BuildTarget target, BuildOptions options, string playbackEngineDirectory); [FreeFunction(IsThreadSafe = true)] internal static extern string GetBuildToolsDirectory(BuildTarget target); diff --git a/Editor/Mono/BuildPipeline/Android/AndroidPostGenerateGradleProject.cs b/Editor/Mono/BuildPipeline/Android/AndroidPostGenerateGradleProject.cs new file mode 100644 index 0000000000..253e7ec385 --- /dev/null +++ b/Editor/Mono/BuildPipeline/Android/AndroidPostGenerateGradleProject.cs @@ -0,0 +1,55 @@ +// Unity C# reference source +// Copyright (c) Unity Technologies. For terms of use, see +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License + +using System; +using System.Collections.Generic; +using UnityEditor.Build; +using UnityEngine; + +namespace UnityEditor.Android +{ + public interface IPostGenerateGradleAndroidProject : IOrderedCallback + { + void OnPostGenerateGradleAndroidProject(string path); + } + + internal static class AndroidBuildPipelineInterfaces + { + private static List buildPostProjectGeneratedProcessors; + + internal static void InitializeBuildCallbacks() + { + buildPostProjectGeneratedProcessors = new List(); + + foreach (var type in EditorAssemblies.GetAllTypesWithInterface()) + { + if (type.IsAbstract || type.IsInterface) + continue; + buildPostProjectGeneratedProcessors.Add(Activator.CreateInstance(type) as IPostGenerateGradleAndroidProject); + } + + buildPostProjectGeneratedProcessors.Sort(BuildPipelineInterfaces.CompareICallbackOrder); + } + + internal static void OnGeneratePlatformProjectPostprocess(string path, bool strict) + { + if (buildPostProjectGeneratedProcessors != null) + { + foreach (var pggapp in buildPostProjectGeneratedProcessors) + { + try + { + pggapp.OnPostGenerateGradleAndroidProject(path); + } + catch (Exception ex) + { + Debug.LogException(ex); + if (strict) + throw; + } + } + } + } + } +} diff --git a/Editor/Mono/BuildPlayerWindow.cs b/Editor/Mono/BuildPlayerWindow.cs index 309b1b9d7e..e03858708c 100644 --- a/Editor/Mono/BuildPlayerWindow.cs +++ b/Editor/Mono/BuildPlayerWindow.cs @@ -488,7 +488,8 @@ static bool IsColorSpaceValid(BuildPlatform platform) { "OSXStandalone", "Mac" }, { "WindowsStandalone", "Windows" }, { "LinuxStandalone", "Linux" }, - { "Facebook", "Facebook-Games"} + { "Facebook", "Facebook-Games"}, + { "Metro", "UWP-IL2CPP"} }; static public string GetPlaybackEngineDownloadURL(string moduleName) { diff --git a/Editor/Mono/Commands/GOCreationCommands.cs b/Editor/Mono/Commands/GOCreationCommands.cs index 61f798bcfc..9d5748114f 100644 --- a/Editor/Mono/Commands/GOCreationCommands.cs +++ b/Editor/Mono/Commands/GOCreationCommands.cs @@ -183,6 +183,7 @@ static void CreateAreaLight(MenuCommand menuCommand) var go = CreateGameObject(null, "Area Light", typeof(Light)); go.GetComponent().type = LightType.Area; + go.GetComponent().shadows = LightShadows.Soft; go.GetComponent().SetLocalEulerAngles(new Vector3(90, 0, 0), RotationOrder.OrderZXY); Place(go, parent); diff --git a/Editor/Mono/ContainerWindow.cs b/Editor/Mono/ContainerWindow.cs index 5b542a6c46..2e0b94c26d 100644 --- a/Editor/Mono/ContainerWindow.cs +++ b/Editor/Mono/ContainerWindow.cs @@ -163,6 +163,7 @@ public void Close() // Guard against destroy window or window in the process of being destroyed. if (this && m_WindowPtr.m_IntPtr != IntPtr.Zero) InternalClose(); + DestroyImmediate(this, true); } internal bool IsNotDocked() diff --git a/Editor/Mono/EditorApplication.bindings.cs b/Editor/Mono/EditorApplication.bindings.cs index 9b6aed47b2..07370e0dbc 100644 --- a/Editor/Mono/EditorApplication.bindings.cs +++ b/Editor/Mono/EditorApplication.bindings.cs @@ -3,6 +3,7 @@ // https://unity3d.com/legal/licenses/Unity_Reference_Only_License using System; +using UnityEditor.Scripting.ScriptCompilation; using UnityEngine; using UnityEngine.Bindings; using Object = UnityEngine.Object; @@ -72,10 +73,12 @@ public static extern bool isPaused } // Is editor currently compiling scripts? (RO) - public static extern bool isCompiling + public static bool isCompiling { - [FreeFunction("IsCompiling")] - get; + get + { + return EditorCompilationInterface.IsCompiling(); + } } // Is editor currently updating? (RO) diff --git a/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs b/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs index 0e0f140974..77eafbe821 100644 --- a/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs +++ b/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs @@ -21,6 +21,13 @@ namespace UnityEditor.IMGUI.Controls public abstract partial class TreeView { + public delegate List GetNewSelectionFunction(TreeViewItem clickedItem, bool keepMultiSelection, bool useActionKeyAsShift); + + protected GetNewSelectionFunction getNewSelectionOverride + { + set { m_TreeView.getNewSelectionOverride = (x, y, z) => value(x, y, z); } + } + TreeViewController m_TreeView; TreeViewControlDataSource m_DataSource; TreeViewControlGUI m_GUI; diff --git a/Editor/Mono/GUI/TreeView/TreeViewController.cs b/Editor/Mono/GUI/TreeView/TreeViewController.cs index e5833fc6c8..8c6d72bc7d 100644 --- a/Editor/Mono/GUI/TreeView/TreeViewController.cs +++ b/Editor/Mono/GUI/TreeView/TreeViewController.cs @@ -2,6 +2,7 @@ // Copyright (c) Unity Technologies. For terms of use, see // https://unity3d.com/legal/licenses/Unity_Reference_Only_License +using System; using System.Collections.Generic; using System.Linq; using UnityEditor.AnimatedValues; @@ -27,7 +28,6 @@ namespace UnityEditor.IMGUI.Controls */ - [System.Serializable] public class TreeViewState { @@ -1124,9 +1124,13 @@ bool GetFirstAndLastSelected(List items, out int firstIndex, out i return firstIndex != -1 && lastIndex != -1; } + public Func> getNewSelectionOverride { private get; set; } + // Returns list of selected ids List GetNewSelection(TreeViewItem clickedItem, bool keepMultiSelection, bool useShiftAsActionKey) { + if (getNewSelectionOverride != null) + return getNewSelectionOverride(clickedItem, keepMultiSelection, useShiftAsActionKey); // Get ids from items var visibleRows = data.GetRows(); List allIDs = new List(visibleRows.Count); diff --git a/Editor/Mono/Inspector/CameraEditor.cs b/Editor/Mono/Inspector/CameraEditor.cs index 8a787b2fcf..9552e64eb5 100644 --- a/Editor/Mono/Inspector/CameraEditor.cs +++ b/Editor/Mono/Inspector/CameraEditor.cs @@ -632,6 +632,12 @@ public virtual void OnOverlayGUI(Object target, SceneView sceneView) // Apply normalizedviewport rect of camera Rect normalizedViewPortRect = c.rect; + // clamp normalized rect in [0,1] + normalizedViewPortRect.xMin = Math.Max(normalizedViewPortRect.xMin, 0f); + normalizedViewPortRect.yMin = Math.Max(normalizedViewPortRect.yMin, 0f); + normalizedViewPortRect.xMax = Math.Min(normalizedViewPortRect.xMax, 1f); + normalizedViewPortRect.yMax = Math.Min(normalizedViewPortRect.yMax, 1f); + previewSize.x *= Mathf.Max(normalizedViewPortRect.width, 0f); previewSize.y *= Mathf.Max(normalizedViewPortRect.height, 0f); @@ -741,7 +747,7 @@ public virtual void OnSceneGUI() SceneViewOverlay.Window(EditorGUIUtility.TrTextContent("Camera Preview"), OnOverlayGUI, (int)SceneViewOverlay.Ordering.Camera, target, SceneViewOverlay.WindowDisplayOption.OneWindowPerTarget); - CameraEditorUtils.HandleFrustum(c); + CameraEditorUtils.HandleFrustum(c, referenceTargetIndex); } } } diff --git a/Editor/Mono/Inspector/CameraEditorUtils.cs b/Editor/Mono/Inspector/CameraEditorUtils.cs index a91e62ac4e..59a535b465 100644 --- a/Editor/Mono/Inspector/CameraEditorUtils.cs +++ b/Editor/Mono/Inspector/CameraEditorUtils.cs @@ -15,15 +15,20 @@ public static class CameraEditorUtils static int s_MovingHandleId = 0; static Vector3 s_InitialFarMid; - static readonly int[] s_FrustrumHandleIds = + static readonly int[] s_FrustumHandleIds = { - "CameraEditor_FrustrumHandleTop".GetHashCode(), - "CameraEditor_FrustrumHandleBottom".GetHashCode(), - "CameraEditor_FrustrumHandleLeft".GetHashCode(), - "CameraEditor_FrustrumHandleRight".GetHashCode() + "CameraEditor_FrustumHandleTop".GetHashCode(), + "CameraEditor_FrustumHandleBottom".GetHashCode(), + "CameraEditor_FrustumHandleLeft".GetHashCode(), + "CameraEditor_FrustumHandleRight".GetHashCode() }; public static void HandleFrustum(Camera c) + { + HandleFrustum(c, 0); + } + + public static void HandleFrustum(Camera c, int cameraEditorTargetIndex) { Color orgHandlesColor = Handles.color; Color slidersColor = k_ColorThemeCameraGizmo; @@ -47,12 +52,12 @@ public static void HandleFrustum(Camera c) Vector3 farMid = Vector3.Lerp(leftBottomFar, rightTopFar, 0.5f); if (s_MovingHandleId != 0) { - if (!s_FrustrumHandleIds.Contains(GUIUtility.hotControl)) + if (!s_FrustumHandleIds.Contains(GUIUtility.hotControl - cameraEditorTargetIndex)) s_MovingHandleId = GUIUtility.hotControl; else farMid = s_InitialFarMid; } - else if (s_FrustrumHandleIds.Contains(GUIUtility.hotControl)) + else if (s_FrustumHandleIds.Contains(GUIUtility.hotControl - cameraEditorTargetIndex)) { s_MovingHandleId = GUIUtility.hotControl; s_InitialFarMid = farMid; @@ -61,17 +66,17 @@ public static void HandleFrustum(Camera c) // FOV handles // Top and bottom handles float halfHeight = -1.0f; - Vector3 changedPosition = MidPointPositionSlider(s_FrustrumHandleIds[0], leftTopFar, rightTopFar, c.transform.up); + Vector3 changedPosition = MidPointPositionSlider(s_FrustumHandleIds[0] + cameraEditorTargetIndex, leftTopFar, rightTopFar, c.transform.up); if (!GUI.changed) - changedPosition = MidPointPositionSlider(s_FrustrumHandleIds[1], leftBottomFar, rightBottomFar, -c.transform.up); + changedPosition = MidPointPositionSlider(s_FrustumHandleIds[1] + cameraEditorTargetIndex, leftBottomFar, rightBottomFar, -c.transform.up); if (GUI.changed) halfHeight = (changedPosition - farMid).magnitude; // Left and right handles GUI.changed = false; - changedPosition = MidPointPositionSlider(s_FrustrumHandleIds[2], rightBottomFar, rightTopFar, c.transform.right); + changedPosition = MidPointPositionSlider(s_FrustumHandleIds[2] + cameraEditorTargetIndex, rightBottomFar, rightTopFar, c.transform.right); if (!GUI.changed) - changedPosition = MidPointPositionSlider(s_FrustrumHandleIds[3], leftBottomFar, leftTopFar, -c.transform.right); + changedPosition = MidPointPositionSlider(s_FrustumHandleIds[3] + cameraEditorTargetIndex, leftBottomFar, leftTopFar, -c.transform.right); if (GUI.changed) halfHeight = (changedPosition - farMid).magnitude / frustumAspect; @@ -126,26 +131,56 @@ public static bool TryGetFrustum(Camera camera, Vector3[] near, Vector3[] far, o if (far != null) { - far[0] = new Vector3(0, 0, camera.farClipPlane); // leftBottomFar - far[1] = new Vector3(0, 1, camera.farClipPlane); // leftTopFar - far[2] = new Vector3(1, 1, camera.farClipPlane); // rightTopFar - far[3] = new Vector3(1, 0, camera.farClipPlane); // rightBottomFar - for (int i = 0; i < 4; ++i) - far[i] = camera.ViewportToWorldPointWithoutGateFit(far[i]); + if (camera.projectionMatrixMode == (int)Camera.ProjectionMatrixMode.Explicit) + { + far[0] = new Vector3(0, 0, camera.farClipPlane); // leftBottomFar + far[1] = new Vector3(0, 1, camera.farClipPlane); // leftTopFar + far[2] = new Vector3(1, 1, camera.farClipPlane); // rightTopFar + far[3] = new Vector3(1, 0, camera.farClipPlane); // rightBottomFar + for (int i = 0; i < 4; ++i) + far[i] = camera.ViewportToWorldPoint(far[i]); + } + else + { + CalculateFrustumPlaneAt(camera, camera.farClipPlane, far); + } } if (near != null) { - near[0] = new Vector3(0, 0, camera.nearClipPlane); // leftBottomNear - near[1] = new Vector3(0, 1, camera.nearClipPlane); // leftTopNear - near[2] = new Vector3(1, 1, camera.nearClipPlane); // rightTopNear - near[3] = new Vector3(1, 0, camera.nearClipPlane); // rightBottomNear - for (int i = 0; i < 4; ++i) - near[i] = camera.ViewportToWorldPointWithoutGateFit(near[i]); + if (camera.projectionMatrixMode == (int)Camera.ProjectionMatrixMode.Explicit) + { + near[0] = new Vector3(0, 0, camera.nearClipPlane); // leftBottomNear + near[1] = new Vector3(0, 1, camera.nearClipPlane); // leftTopNear + near[2] = new Vector3(1, 1, camera.nearClipPlane); // rightTopNear + near[3] = new Vector3(1, 0, camera.nearClipPlane); // rightBottomNear + for (int i = 0; i < 4; ++i) + near[i] = camera.ViewportToWorldPoint(near[i]); + } + else + { + CalculateFrustumPlaneAt(camera, camera.nearClipPlane, near); + } } return true; } + private static void CalculateFrustumPlaneAt(Camera camera, float distance, Vector3[] plane) + { + Vector2 planeSize = camera.GetFrustumPlaneSizeAt(distance) * .5f; + Vector3 rightOffset = camera.gameObject.transform.right * planeSize.x; + Vector3 upOffset = camera.gameObject.transform.up * planeSize.y; + Vector3 localAim = camera.GetLocalSpaceAim() * distance; + localAim.z = -localAim.z; + + Vector3 planePosition = camera.cameraToWorldMatrix.MultiplyPoint(localAim); + + plane[0] = planePosition - rightOffset - upOffset; // leftBottom + plane[1] = planePosition - rightOffset + upOffset; // leftTop + plane[2] = planePosition + rightOffset + upOffset; // rightTop + plane[3] = planePosition + rightOffset - upOffset; // rightBottom + } + public static bool IsViewportRectValidToRender(Rect normalizedViewPortRect) { if (normalizedViewPortRect.width <= 0f || normalizedViewPortRect.height <= 0f) @@ -163,8 +198,7 @@ public static float GetFrustumAspectRatio(Camera camera) if (normalizedViewPortRect.width <= 0f || normalizedViewPortRect.height <= 0f) return -1f; - return camera.usePhysicalProperties ? - camera.sensorSize.x / camera.sensorSize.y : GameViewAspectRatio * normalizedViewPortRect.width / normalizedViewPortRect.height; + return GameViewAspectRatio * normalizedViewPortRect.width / normalizedViewPortRect.height; } public static Vector3 PerspectiveClipToWorld(Matrix4x4 clipToWorld, Vector3 viewPositionWS, Vector3 positionCS) diff --git a/Editor/Mono/Inspector/LightEditor.cs b/Editor/Mono/Inspector/LightEditor.cs index 5d09834e3a..71d4287758 100644 --- a/Editor/Mono/Inspector/LightEditor.cs +++ b/Editor/Mono/Inspector/LightEditor.cs @@ -636,16 +636,11 @@ public override void OnInspectorGUI() void ShadowsGUI() { //NOTE: FadeGroup's dont support nesting. Thus we just multiply the fade values here. - - // Shadows drop-down. Area lights can only be baked and always have shadows. - float show = 1 - m_AnimShowAreaOptions.faded; - - if (EditorGUILayout.BeginFadeGroup(show)) - settings.DrawShadowsType(); - EditorGUILayout.EndFadeGroup(); + settings.DrawShadowsType(); EditorGUI.indentLevel += 1; - show *= m_AnimShowShadowOptions.faded; + + float show = m_AnimShowAreaOptions.faded; // Baked Shadow radius if (EditorGUILayout.BeginFadeGroup(show * m_AnimBakedShadowRadiusOptions.faded)) diff --git a/Editor/Mono/Modules/ModuleManager.cs b/Editor/Mono/Modules/ModuleManager.cs index 6418080227..79770302be 100644 --- a/Editor/Mono/Modules/ModuleManager.cs +++ b/Editor/Mono/Modules/ModuleManager.cs @@ -400,7 +400,7 @@ static bool InitializePackageManager(Assembly assembly, Unity.DataContract.Packa else InternalEditorUtility.RegisterPrecompiledAssembly(Path.GetFileName(dllpath), dllpath); } - BuildPipeline.SetPlaybackEngineDirectory(target, BuildOptions.None /* TODO */, engine.basePath); + BuildPipeline.SetPlaybackEngineDirectory(buildTargetGroup, target, BuildOptions.None /* TODO */, engine.basePath); InternalEditorUtility.SetPlatformPath(engine.basePath); s_PackageManager.LoadPackage(engine); } diff --git a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs index c890b9070c..428b47d49f 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs @@ -950,6 +950,19 @@ public bool DoesProjectFolderHaveAnyScripts() return allScripts != null && allScripts.Count > 0; } + public bool DoesProjectHaveAnyCustomScriptAssemblies() + { + foreach (var script in allScripts) + { + var targetAssembly = EditorBuildRules.GetTargetAssembly(script, projectDirectory, customTargetAssemblies); + + if (targetAssembly.Type == EditorBuildRules.TargetAssemblyType.Custom) + return true; + } + + return false; + } + ScriptAssemblySettings CreateScriptAssemblySettings(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget, EditorScriptCompilationOptions options) { var defines = InternalEditorUtility.GetCompilationDefines(options, buildTargetGroup, buildTarget); diff --git a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilationInterface.cs b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilationInterface.cs index a9a18e9007..bd10b6b008 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilationInterface.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilationInterface.cs @@ -240,6 +240,12 @@ public static bool DoesProjectFolderHaveAnyScripts() return Instance.DoesProjectFolderHaveAnyScripts(); } + [RequiredByNativeCode] + public static bool DoesProjectHaveAnyCustomScriptAssemblies() + { + return Instance.DoesProjectHaveAnyCustomScriptAssemblies(); + } + [RequiredByNativeCode] public static EditorCompilation.AssemblyCompilerMessages[] GetCompileMessages() { diff --git a/Projects/CSharp/UnityEditor.csproj b/Projects/CSharp/UnityEditor.csproj index 0109f76336..887efa2f6a 100644 --- a/Projects/CSharp/UnityEditor.csproj +++ b/Projects/CSharp/UnityEditor.csproj @@ -659,6 +659,9 @@ Editor\Mono\BuildPipelineExperimental.cs + + Editor\Mono\BuildPipeline\Android\AndroidPostGenerateGradleProject.cs + Editor\Mono\BuildPipeline\AssemblyStripper.cs diff --git a/README.md b/README.md index e56b56694e..aa563375ac 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b9 C# reference source code +## Unity 2018.2.0b10 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Animation/ScriptBindings/AnimationStream.bindings.cs b/Runtime/Animation/ScriptBindings/AnimationStream.bindings.cs index 96f5b6c60b..dee7240bf4 100644 --- a/Runtime/Animation/ScriptBindings/AnimationStream.bindings.cs +++ b/Runtime/Animation/ScriptBindings/AnimationStream.bindings.cs @@ -33,9 +33,7 @@ public struct AnimationStream private System.IntPtr output; private System.IntPtr workspace; private System.IntPtr inputStreamAccessor; - private System.IntPtr streamHandles; - private System.IntPtr transformSceneHandles; - private System.IntPtr propertySceneHandles; + private System.IntPtr animationHandleBinder; internal const int InvalidIndex = ~0; @@ -53,9 +51,7 @@ public bool isValid input != System.IntPtr.Zero && output != System.IntPtr.Zero && workspace != System.IntPtr.Zero && - streamHandles != System.IntPtr.Zero && - transformSceneHandles != System.IntPtr.Zero && - propertySceneHandles != System.IntPtr.Zero; + animationHandleBinder != System.IntPtr.Zero; } } diff --git a/Runtime/Animation/ScriptBindings/AnimatorJobExtensions.bindings.cs b/Runtime/Animation/ScriptBindings/AnimatorJobExtensions.bindings.cs index 3162b91562..dc26d27517 100644 --- a/Runtime/Animation/ScriptBindings/AnimatorJobExtensions.bindings.cs +++ b/Runtime/Animation/ScriptBindings/AnimatorJobExtensions.bindings.cs @@ -13,6 +13,7 @@ namespace UnityEngine.Experimental.Animations [NativeHeader("Runtime/Animation/Animator.h")] [NativeHeader("Runtime/Animation/Director/AnimationStreamHandles.h")] [NativeHeader("Runtime/Animation/Director/AnimationSceneHandles.h")] + [NativeHeader("Runtime/Animation/Director/AnimationStream.h")] [StaticAccessor("AnimatorJobExtensionsBindings", StaticAccessorType.DoubleColon)] public static class AnimatorJobExtensions { diff --git a/Runtime/Export/Camera.bindings.cs b/Runtime/Export/Camera.bindings.cs index 6ca25d3bc7..04c2d0dc2c 100644 --- a/Runtime/Export/Camera.bindings.cs +++ b/Runtime/Export/Camera.bindings.cs @@ -86,10 +86,12 @@ public float[] layerCullDistances extern public void ResetReplacementShader(); internal enum ProjectionMatrixMode{ Explicit, Implicit, PhysicalPropertiesBased }; + extern internal ProjectionMatrixMode projectionMatrixMode { get; } extern public bool usePhysicalProperties { get; set; } extern public Vector2 sensorSize { get; set; } extern public Vector2 lensShift { get; set; } extern public float focalLength { get; set; } + extern internal Vector3 GetLocalSpaceAim(); [NativeProperty("NormalizedViewportRect")] extern public Rect rect { get; set; } [NativeProperty("ScreenViewportRect")] extern public Rect pixelRect { get; set; } @@ -132,9 +134,9 @@ internal enum ProjectionMatrixMode{ Explicit, Implicit, PhysicalPropertiesBased public Vector3 ViewportToWorldPoint(Vector3 position) { return ViewportToWorldPoint(position, MonoOrStereoscopicEye.Mono); } public Vector3 ScreenToWorldPoint(Vector3 position) { return ScreenToWorldPoint(position, MonoOrStereoscopicEye.Mono); } extern public Vector3 ScreenToViewportPoint(Vector3 position); - extern internal Vector3 ViewportToWorldPointWithoutGateFit(Vector3 position); extern public Vector3 ViewportToScreenPoint(Vector3 position); + extern internal Vector2 GetFrustumPlaneSizeAt(float distance); extern private Ray ViewportPointToRay(Vector2 pos, MonoOrStereoscopicEye eye); public Ray ViewportPointToRay(Vector3 pos, MonoOrStereoscopicEye eye) { return ViewportPointToRay((Vector2)pos, eye); } public Ray ViewportPointToRay(Vector3 pos) { return ViewportPointToRay(pos, MonoOrStereoscopicEye.Mono); } @@ -156,6 +158,8 @@ public void CalculateFrustumCorners(Rect viewport, float z, MonoOrStereoscopicEy CalculateFrustumCornersInternal(viewport, z, eye, outCorners); } + extern public static float FocalLengthToFOV(float focalLength, float sensorSize); + extern public static float FOVToFocalLength(float fov, float sensorSize); extern public static Camera main {[FreeFunction("FindMainCamera")] get; } extern public static Camera current {[FreeFunction("GetCurrentCameraPtr")] get; } diff --git a/Runtime/Export/GraphicsEnums.cs b/Runtime/Export/GraphicsEnums.cs index f488e68fb0..0b3cb381ae 100644 --- a/Runtime/Export/GraphicsEnums.cs +++ b/Runtime/Export/GraphicsEnums.cs @@ -1053,6 +1053,7 @@ public enum GraphicsDeviceType Direct3D12 = 18, N3DS = 19, Vulkan = 21, + Switch = 22, XboxOneD3D12 = 23 } diff --git a/Runtime/Export/SystemInfo.bindings.cs b/Runtime/Export/SystemInfo.bindings.cs index 74ef3ec8e5..3c6daeca83 100644 --- a/Runtime/Export/SystemInfo.bindings.cs +++ b/Runtime/Export/SystemInfo.bindings.cs @@ -340,10 +340,30 @@ public static int supportsStencil get { return 1; } } + // The enums are only marked as obsolete in the editor. + static bool IsObsolete(Enum value) + { + var fieldInfo = value.GetType().GetField(value.ToString()); + var attributes = (ObsoleteAttribute[])fieldInfo.GetCustomAttributes(typeof(ObsoleteAttribute), false); + return (attributes != null && attributes.Length > 0); + } + + + static bool IsValidEnumValue(Enum value) + { + if (!Enum.IsDefined(value.GetType(), value)) + return false; + + if (IsObsolete(value)) + return false; + + return true; + } + // Is render texture format supported? public static bool SupportsRenderTextureFormat(RenderTextureFormat format) { - if (!Enum.IsDefined(typeof(RenderTextureFormat), format)) + if (!IsValidEnumValue(format)) throw new ArgumentException("Failed SupportsRenderTextureFormat; format is not a valid RenderTextureFormat"); return HasRenderTextureNative(format); @@ -352,7 +372,7 @@ public static bool SupportsRenderTextureFormat(RenderTextureFormat format) // Is render texture format supports blending? public static bool SupportsBlendingOnRenderTextureFormat(RenderTextureFormat format) { - if (!Enum.IsDefined(typeof(RenderTextureFormat), format)) + if (!IsValidEnumValue(format)) throw new ArgumentException("Failed SupportsBlendingOnRenderTextureFormat; format is not a valid RenderTextureFormat"); return SupportsBlendingOnRenderTextureFormatNative(format); @@ -360,7 +380,7 @@ public static bool SupportsBlendingOnRenderTextureFormat(RenderTextureFormat for public static bool SupportsTextureFormat(TextureFormat format) { - if (!Enum.IsDefined(typeof(TextureFormat), format)) + if (!IsValidEnumValue(format)) throw new ArgumentException("Failed SupportsTextureFormat; format is not a valid TextureFormat"); return SupportsTextureFormatNative(format); diff --git a/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs b/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs index e1f0208dce..9ccf120add 100644 --- a/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs +++ b/Runtime/VR/HoloLens/HolographicEmulation/HolographicRemoting.cs @@ -18,7 +18,7 @@ public static HolographicStreamerConnectionState ConnectionState } } - public static void Connect(string clientName) + public static void Connect(string clientName, int maxBitRate = 9999) { } From cc0513fdae7a5624a12f99f3a05bd0a82dd9a366 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Tue, 3 Jul 2018 13:34:59 +0000 Subject: [PATCH 10/13] Unity 2018.2.0b11 C# reference source code --- Editor/Mono/AssetStore/AssetStoreWindow.cs | 2 +- Editor/Mono/GUI/WindowLayout.cs | 15 ++++----------- Editor/Mono/GUIDebugger/GUIViewDebuggerWindow.cs | 2 +- Editor/Mono/PerformanceTools/FrameDebugger.cs | 2 +- Editor/Mono/PlayerSettingsAndroid.bindings.cs | 2 +- .../Mono/PreferencesWindow/PreferencesWindow.cs | 2 +- .../Mono/SceneModeWindows/PhysicsDebugWindow.cs | 2 +- Editor/Mono/UnityConnect/Services/HubAccess.cs | 2 +- .../SolutionSynchronizer.cs | 1 + Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs | 4 ++-- .../ProfilerWindow/ProfilerWindow.cs | 2 +- .../UIElementsDebugger.cs | 2 +- .../EditorAnalytics.bindings.cs | 5 +++++ README.md | 2 +- Runtime/AR/ScriptBindings/ARBackgroundRenderer.cs | 12 ++++-------- Runtime/Export/AssemblyInfo.cs | 2 ++ 16 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Editor/Mono/AssetStore/AssetStoreWindow.cs b/Editor/Mono/AssetStore/AssetStoreWindow.cs index a356c007da..19ed6719ac 100644 --- a/Editor/Mono/AssetStore/AssetStoreWindow.cs +++ b/Editor/Mono/AssetStore/AssetStoreWindow.cs @@ -30,7 +30,7 @@ public static void OpenURL(string url) } // Use this for initialization - [MenuItem("Window/General/Asset Store %9", false, 20)] + [MenuItem("Window/General/Asset Store %9", false, 301)] public static AssetStoreWindow Init() { AssetStoreWindow window = EditorWindow.GetWindow(typeof(SceneView)); diff --git a/Editor/Mono/GUI/WindowLayout.cs b/Editor/Mono/GUI/WindowLayout.cs index e7a4c39495..a0e367fe94 100644 --- a/Editor/Mono/GUI/WindowLayout.cs +++ b/Editor/Mono/GUI/WindowLayout.cs @@ -889,13 +889,13 @@ void OnGUI() internal class CreateBuiltinWindows { - [MenuItem("Window/General/Scene %1", false, 5)] + [MenuItem("Window/General/Scene %1", false, 1)] static void ShowSceneView() { EditorWindow.GetWindow(); } - [MenuItem("Window/General/Game %2", false, 1)] + [MenuItem("Window/General/Game %2", false, 2)] static void ShowGameView() { EditorWindow.GetWindow(); @@ -907,13 +907,13 @@ static void ShowInspector() EditorWindow.GetWindow(); } - [MenuItem("Window/General/Hierarchy %4", false, 2)] + [MenuItem("Window/General/Hierarchy %4", false, 4)] static void ShowNewHierarchy() { EditorWindow.GetWindow(); } - [MenuItem("Window/General/Project %5", false, 4)] + [MenuItem("Window/General/Project %5", false, 5)] static void ShowProject() { EditorWindow.GetWindow(); @@ -925,13 +925,6 @@ static void ShowAnimationWindow() EditorWindow.GetWindow(); } - // Profiler is registered from native code (EditorWindowController.cpp), for license check - //[MenuItem ("Window/Profiler %7", false, 2007)] - static void ShowProfilerWindow() - { - EditorWindow.GetWindow(); - } - [MenuItem("Window/Audio/Audio Mixer %8", false, 1)] static void ShowAudioMixer() { diff --git a/Editor/Mono/GUIDebugger/GUIViewDebuggerWindow.cs b/Editor/Mono/GUIDebugger/GUIViewDebuggerWindow.cs index 7fd7238dde..a1e66a82b3 100644 --- a/Editor/Mono/GUIDebugger/GUIViewDebuggerWindow.cs +++ b/Editor/Mono/GUIDebugger/GUIViewDebuggerWindow.cs @@ -219,7 +219,7 @@ InstructionType instructionType readonly SplitterState m_InstructionListDetailSplitter = new SplitterState(new float[] { 30, 70 }, new int[] { 32, 32 }, null); //Internal Tool for now. Uncomment it to enable it. - [MenuItem("Window/Debug/IMGUI Debugger", false, 6, true)] + [MenuItem("Window/Analysis/IMGUI Debugger", false, 102, true)] static void Init() { // Get existing open window or if none, make a new one: diff --git a/Editor/Mono/PerformanceTools/FrameDebugger.cs b/Editor/Mono/PerformanceTools/FrameDebugger.cs index d9dae01339..82a525918b 100644 --- a/Editor/Mono/PerformanceTools/FrameDebugger.cs +++ b/Editor/Mono/PerformanceTools/FrameDebugger.cs @@ -342,7 +342,7 @@ private struct EventDataStrings private AttachProfilerUI m_AttachProfilerUI = new AttachProfilerUI(); - [MenuItem("Window/Debug/Frame Debugger", false, 4)] + [MenuItem("Window/Analysis/Frame Debugger", false, 10)] public static FrameDebuggerWindow ShowFrameDebuggerWindow() { var wnd = GetWindow(typeof(FrameDebuggerWindow)) as FrameDebuggerWindow; diff --git a/Editor/Mono/PlayerSettingsAndroid.bindings.cs b/Editor/Mono/PlayerSettingsAndroid.bindings.cs index 5c7273ed8f..b64a87f608 100644 --- a/Editor/Mono/PlayerSettingsAndroid.bindings.cs +++ b/Editor/Mono/PlayerSettingsAndroid.bindings.cs @@ -227,7 +227,7 @@ public static extern bool forceSDCardPermission public static extern bool androidIsGame { get; set; } // Google Tango mixed reality support - internal static extern bool androidTangoEnabled { get; set; } + public static extern bool ARCoreEnabled { get; set; } // Whether Android banner is added to the APK internal static extern bool androidBannerEnabled { get; set; } diff --git a/Editor/Mono/PreferencesWindow/PreferencesWindow.cs b/Editor/Mono/PreferencesWindow/PreferencesWindow.cs index d9ec7eb38c..af63b11955 100644 --- a/Editor/Mono/PreferencesWindow/PreferencesWindow.cs +++ b/Editor/Mono/PreferencesWindow/PreferencesWindow.cs @@ -1312,7 +1312,7 @@ public AppsListUserData(string[] paths, RefString str, Action onChanged) void AppsListClick(object userData, string[] options, int selected) { AppsListUserData ud = (AppsListUserData)userData; - if (options[selected] == "Browse...") + if (options[selected] == L10n.Tr("Browse...")) { string path = EditorUtility.OpenFilePanel("Browse for application", "", InternalEditorUtility.GetApplicationExtensionForRuntimePlatform(Application.platform)); if (path.Length != 0) diff --git a/Editor/Mono/SceneModeWindows/PhysicsDebugWindow.cs b/Editor/Mono/SceneModeWindows/PhysicsDebugWindow.cs index 9bf682862e..5e34ad6dd3 100644 --- a/Editor/Mono/SceneModeWindows/PhysicsDebugWindow.cs +++ b/Editor/Mono/SceneModeWindows/PhysicsDebugWindow.cs @@ -42,7 +42,7 @@ private static class Contents //--------------------------------------------------------------------- - [MenuItem("Window/Debug/Physics Debugger", false, 5)] + [MenuItem("Window/Analysis/Physics Debugger", false, 11)] public static PhysicsDebugWindow ShowWindow() { var window = GetWindow(typeof(PhysicsDebugWindow)) as PhysicsDebugWindow; diff --git a/Editor/Mono/UnityConnect/Services/HubAccess.cs b/Editor/Mono/UnityConnect/Services/HubAccess.cs index 05d73e6b31..126446c9f3 100644 --- a/Editor/Mono/UnityConnect/Services/HubAccess.cs +++ b/Editor/Mono/UnityConnect/Services/HubAccess.cs @@ -55,7 +55,7 @@ static HubAccess() UnityConnectServiceCollection.instance.AddService(serviceData); } - [MenuItem("Window/General/Services %0", false, 21)] + [MenuItem("Window/General/Services %0", false, 302)] private static void ShowMyWindow() { UnityConnectServiceCollection.instance.ShowService(kServiceName, true, "window_menu_item"); diff --git a/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs b/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs index 263a7d7f5e..bc2e02115b 100644 --- a/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs +++ b/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs @@ -59,6 +59,7 @@ enum Mode {"cginc", ScriptingLanguage.None}, {"hlsl", ScriptingLanguage.None}, {"glslinc", ScriptingLanguage.None}, + {"template", ScriptingLanguage.None}, }; private static readonly string[] reimportSyncExtensions = new[] { ".dll", ".asmdef" }; diff --git a/Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs b/Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs index 3c24531eed..b5156f7c9f 100644 --- a/Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs +++ b/Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs @@ -529,7 +529,7 @@ private void ErrorOnARDeviceIncompatibility(BuildTargetGroup targetGroup) { if (targetGroup == BuildTargetGroup.Android) { - if (PlayerSettings.Android.androidTangoEnabled && PlayerSettings.GetPlatformVuforiaEnabled(targetGroup)) + if (PlayerSettings.Android.ARCoreEnabled && PlayerSettings.GetPlatformVuforiaEnabled(targetGroup)) { EditorGUILayout.HelpBox("Both ARCore and Vuforia XR Device support cannot be selected at the same time. Please select only one XR Device that will manage the Android device.", MessageType.Error); } @@ -557,7 +557,7 @@ internal void TangoGUI(BuildTargetGroup targetGroup) // Google Tango settings EditorGUILayout.PropertyField(m_AndroidEnableTango, EditorGUIUtility.TrTextContent("ARCore Supported")); - if (PlayerSettings.Android.androidTangoEnabled) + if (PlayerSettings.Android.ARCoreEnabled) { EditorGUI.indentLevel++; diff --git a/Modules/ProfilerEditor/ProfilerWindow/ProfilerWindow.cs b/Modules/ProfilerEditor/ProfilerWindow/ProfilerWindow.cs index 02057d1244..6ed90cae84 100644 --- a/Modules/ProfilerEditor/ProfilerWindow/ProfilerWindow.cs +++ b/Modules/ProfilerEditor/ProfilerWindow/ProfilerWindow.cs @@ -571,7 +571,7 @@ private void OnToggleColorBlindMode() : ColorBlindCondition.Default; } - [MenuItem("Window/Debug/Profiler %7", false, 1)] + [MenuItem("Window/Analysis/Profiler %7", false, 0)] static void ShowProfilerWindow() { EditorWindow.GetWindow(false); diff --git a/Modules/UIElementsDebuggerEditor/UIElementsDebugger.cs b/Modules/UIElementsDebuggerEditor/UIElementsDebugger.cs index b0d45ff99d..f7e4ad0fd5 100644 --- a/Modules/UIElementsDebuggerEditor/UIElementsDebugger.cs +++ b/Modules/UIElementsDebuggerEditor/UIElementsDebugger.cs @@ -53,7 +53,7 @@ class UIElementsDebugger : EditorWindow private static readonly PropertyInfo[] k_FieldInfos = typeof(IStyle).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly PropertyInfo[] k_SortedFieldInfos = k_FieldInfos.OrderBy(f => f.Name).ToArray(); - [MenuItem("Window/Debug/UIElements Debugger", false, 6, true)] + [MenuItem("Window/Analysis/UIElements Debugger", false, 101, true)] public static void Open() { GetWindow().Show(); diff --git a/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs b/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs index 1126e11eca..93afa41164 100644 --- a/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs +++ b/Modules/UnityEditorAnalyticsEditor/EditorAnalytics.bindings.cs @@ -71,6 +71,11 @@ internal static bool SendCollabUserAction(object parameters) return EditorAnalytics.SendEvent("collabUserAction", parameters); } + internal static bool SendCollabOperation(object parameters) + { + return EditorAnalytics.SendEvent("collabOperation", parameters); + } + public extern static bool enabled { get; diff --git a/README.md b/README.md index aa563375ac..28d1daee80 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b10 C# reference source code +## Unity 2018.2.0b11 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/AR/ScriptBindings/ARBackgroundRenderer.cs b/Runtime/AR/ScriptBindings/ARBackgroundRenderer.cs index 87ada89122..739e76772c 100644 --- a/Runtime/AR/ScriptBindings/ARBackgroundRenderer.cs +++ b/Runtime/AR/ScriptBindings/ARBackgroundRenderer.cs @@ -170,15 +170,11 @@ protected void DisableARBackgroundRendering() if (null == m_CommandBuffer) return; - Camera camera; - - if (m_Camera != null) - camera = m_Camera; - else - camera = Camera.main; + Camera camera = m_Camera ?? Camera.main; + if (camera == null) + return; - if (camera != null) - camera.clearFlags = m_CameraClearFlags; + camera.clearFlags = m_CameraClearFlags; // Command buffer camera.RemoveCommandBuffer(CameraEvent.BeforeForwardOpaque, m_CommandBuffer); diff --git a/Runtime/Export/AssemblyInfo.cs b/Runtime/Export/AssemblyInfo.cs index a2fefcd6a6..daf0f34d1a 100644 --- a/Runtime/Export/AssemblyInfo.cs +++ b/Runtime/Export/AssemblyInfo.cs @@ -41,6 +41,8 @@ [assembly: InternalsVisibleTo("UnityEngine.TestRunner")] [assembly: InternalsVisibleTo("UnityEngine.GoogleAudioSpatializer")] [assembly: InternalsVisibleTo("Unity.Automation")] +[assembly: InternalsVisibleTo("Unity.Burst")] +[assembly: InternalsVisibleTo("Unity.Burst.Editor")] [assembly: InternalsVisibleTo("Unity.DeploymentTests.Services")] [assembly: InternalsVisibleTo("Unity.IntegrationTests")] [assembly: InternalsVisibleTo("Unity.IntegrationTests.UnityAnalytics")] From 77b82fc83b31a715f0134d7a00e2bf74f0b8e479 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Fri, 6 Jul 2018 15:20:59 +0000 Subject: [PATCH 11/13] Unity 2018.2.0f1 C# reference source code --- Editor/Mono/AssemblyHelper.cs | 8 ++++ Editor/Mono/ProjectBrowser.cs | 43 ++++++++++--------- .../Mono/ProjectWindow/ProjectWindowUtil.cs | 6 ++- README.md | 2 +- Runtime/Export/Camera.bindings.cs | 2 + 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/Editor/Mono/AssemblyHelper.cs b/Editor/Mono/AssemblyHelper.cs index 094342ac49..24c41e1993 100644 --- a/Editor/Mono/AssemblyHelper.cs +++ b/Editor/Mono/AssemblyHelper.cs @@ -11,6 +11,7 @@ using Mono.Cecil; using UnityEditor.Modules; using UnityEditor.Scripting.Compilers; +using UnityEditorInternal; using UnityEngine; namespace UnityEditor @@ -263,9 +264,16 @@ public static void ExtractAllClassesThatAreUserExtendedScripts(string path, out var group = EditorUserBuildSettings.activeBuildTargetGroup; var target = EditorUserBuildSettings.activeBuildTarget; var precompiledAssemblies = UnityEditorInternal.InternalEditorUtility.GetPrecompiledAssemblies(true, group, target); + HashSet searchPaths = new HashSet(); + + foreach (var asm in precompiledAssemblies) + searchPaths.Add(Path.GetDirectoryName(asm.Path)); + + precompiledAssemblies = UnityEditorInternal.InternalEditorUtility.GetUnityAssemblies(true, group, target); foreach (var asm in precompiledAssemblies) searchPaths.Add(Path.GetDirectoryName(asm.Path)); + foreach (var asmpath in searchPaths) assemblyResolver.AddSearchDirectory(asmpath); diff --git a/Editor/Mono/ProjectBrowser.cs b/Editor/Mono/ProjectBrowser.cs index ccacbaa5d7..24e8460dd7 100644 --- a/Editor/Mono/ProjectBrowser.cs +++ b/Editor/Mono/ProjectBrowser.cs @@ -2339,18 +2339,20 @@ void TopBarSearchSettingsChanged() InitListArea(); } + internal static int GetFolderInstanceID(string folderPath) + { + return folderPath == PackageManager.Folders.GetPackagesMountPoint() + ? kPackagesFolderInstanceId + : AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folderPath); + } + static int[] GetFolderInstanceIDs(string[] folders) { int[] folderInstanceIDs = new int[folders.Length]; for (int i = 0; i < folders.Length; ++i) { - if (folders[i] == PackageManager.Folders.GetPackagesMountPoint()) - { - folderInstanceIDs[i] = kPackagesFolderInstanceId; - continue; - } - folderInstanceIDs[i] = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folders[i]); + folderInstanceIDs[i] = GetFolderInstanceID(folders[i]); } return folderInstanceIDs; } @@ -2388,7 +2390,8 @@ void FolderTreeSelectionChanged(bool folderWasSelected) if (folderWasSelected) { SearchViewState state = GetSearchViewState(); - if (state == SearchViewState.AllAssets || state == SearchViewState.AssetStore) + if (state == SearchViewState.AllAssets || state == SearchViewState.InAssetsOnly || + state == SearchViewState.InPackagesOnly || state == SearchViewState.AssetStore) { // Clear all except folders if folder is set string[] folders = m_SearchFilter.folders; @@ -2530,12 +2533,7 @@ void BreadCrumbBar() rect.width = size.x; if (GUI.Button(rect, folderContent, style)) { - if (folderPath == PackageManager.Folders.GetPackagesMountPoint()) - { - ShowFolderContents(kPackagesFolderInstanceId, false); - continue; - } - ShowFolderContents(AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folderPath), false); + ShowFolderContents(GetFolderInstanceID(folderPath), false); } rect.x += size.x + 3f; @@ -2694,15 +2692,20 @@ private void FrameObjectInTwoColumnMode(int instanceID, bool frame, bool ping) { int folderInstanceID = 0; - string assetPath = AssetDatabase.GetAssetPath(instanceID); - if (!String.IsNullOrEmpty(assetPath)) + if (instanceID == kPackagesFolderInstanceId) + folderInstanceID = kPackagesFolderInstanceId; + else { - string containingFolder = ProjectWindowUtil.GetContainingFolder(assetPath); - if (!String.IsNullOrEmpty(containingFolder)) - folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(containingFolder); + string assetPath = AssetDatabase.GetAssetPath(instanceID); + if (!String.IsNullOrEmpty(assetPath)) + { + string containingFolder = ProjectWindowUtil.GetContainingFolder(assetPath); + if (!String.IsNullOrEmpty(containingFolder)) + folderInstanceID = GetFolderInstanceID(containingFolder); - if (folderInstanceID == 0) - folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); + if (folderInstanceID == 0) + folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets"); + } } // Could be a scene gameobject diff --git a/Editor/Mono/ProjectWindow/ProjectWindowUtil.cs b/Editor/Mono/ProjectWindow/ProjectWindowUtil.cs index 60dc55732d..7000d01ec0 100644 --- a/Editor/Mono/ProjectWindow/ProjectWindowUtil.cs +++ b/Editor/Mono/ProjectWindow/ProjectWindowUtil.cs @@ -558,6 +558,10 @@ public static int[] GetAncestors(int instanceID) { List ancestors = new List(); + // Ensure we handle packages root folder + if (instanceID == ProjectBrowser.kPackagesFolderInstanceId) + return ancestors.ToArray(); + // Ensure we add the main asset as ancestor if input is a subasset int mainAssetInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(AssetDatabase.GetAssetPath(instanceID)); bool isSubAsset = mainAssetInstanceID != instanceID; @@ -568,7 +572,7 @@ public static int[] GetAncestors(int instanceID) string currentFolderPath = GetContainingFolder(AssetDatabase.GetAssetPath(mainAssetInstanceID)); while (!string.IsNullOrEmpty(currentFolderPath)) { - int currentInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(currentFolderPath); + int currentInstanceID = ProjectBrowser.GetFolderInstanceID(currentFolderPath); ancestors.Add(currentInstanceID); currentFolderPath = GetContainingFolder(AssetDatabase.GetAssetPath(currentInstanceID)); } diff --git a/README.md b/README.md index 28d1daee80..96217bd6ac 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0b11 C# reference source code +## Unity 2018.2.0f1 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Export/Camera.bindings.cs b/Runtime/Export/Camera.bindings.cs index 04c2d0dc2c..a468585304 100644 --- a/Runtime/Export/Camera.bindings.cs +++ b/Runtime/Export/Camera.bindings.cs @@ -34,6 +34,8 @@ public partial class Camera extern public RenderingPath renderingPath { get; set; } extern public RenderingPath actualRenderingPath {[NativeName("CalculateRenderingPath")] get; } + extern public void Reset(); + extern public bool allowHDR { get; set; } extern public bool allowMSAA { get; set; } extern public bool allowDynamicResolution { get; set; } From 48d4a3b11405d6301bf839351553bd2b08338fd9 Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Mon, 9 Jul 2018 16:46:12 +0000 Subject: [PATCH 12/13] Unity 2018.2.0f2 C# reference source code --- Editor/Mono/Inspector/LightEditor.cs | 2 +- .../SolutionSynchronizer.cs | 101 ------------------ README.md | 2 +- Runtime/Export/Gradient.bindings.cs | 13 ++- 4 files changed, 8 insertions(+), 110 deletions(-) diff --git a/Editor/Mono/Inspector/LightEditor.cs b/Editor/Mono/Inspector/LightEditor.cs index 71d4287758..2b6f45c392 100644 --- a/Editor/Mono/Inspector/LightEditor.cs +++ b/Editor/Mono/Inspector/LightEditor.cs @@ -640,7 +640,7 @@ void ShadowsGUI() EditorGUI.indentLevel += 1; - float show = m_AnimShowAreaOptions.faded; + float show = m_AnimShowShadowOptions.faded; // Baked Shadow radius if (EditorGUILayout.BeginFadeGroup(show * m_AnimBakedShadowRadiusOptions.faded)) diff --git a/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs b/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs index bc2e02115b..0e36c78f10 100644 --- a/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs +++ b/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs @@ -709,107 +709,6 @@ public static string GetProjectExtension(ScriptingLanguage language) return ProjectExtensions[language]; } } - /// - /// SolutionPostProcessor inherit from AssetPostprocessor in order to be called by AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles(). - /// - /// This is a temporary solution until Visual Studio Tool for Unity (VSTU) is modified. - /// - /// - internal class SolutionPostProcessor : AssetPostprocessor - { - /// - /// Get SolutionPostProcessor process order. - /// - /// int.MaxValue to make sure we are the last one called. - public override int GetPostprocessOrder() - { - return int.MaxValue; - } - - /// - /// Replaces 'Include' attribute value with the appropiate path in the specifed node. - /// - /// The XML node. - /// The Unity project directory. - /// true if node was updated, false otherwise. - private static bool ReplacePathInNode(XmlNode node, string projectDir) - { - var path = node.Attributes["Include"].Value; - if (PackageManager.Folders.IsPackagedAssetPath(path.ConvertSeparatorsToUnity())) - { - var absolutePath = Path.GetFullPath(path).ConvertSeparatorsToWindows(); - var newPath = Paths.SkipPathPrefix(absolutePath, projectDir); - if (newPath != path) - { - node.Attributes["Include"].Value = newPath; - return true; - } - } - return false; - } - - /// - /// Replace paths in specified CSProj file if exists. - /// - /// This method will look in all 'Compile' and 'None' XML tags in the CSProj file and - /// replaces 'Include' attribute value with the appropiate path. Finally, CSProj file will be rewriten on disk if necessay. - /// - /// - /// The CSProj file path. - /// The Unity project directory. - internal static void ReplacePathsInProjectFile(string projectFile, string projectDir) - { - XmlDocument doc = new XmlDocument(); - XmlNamespaceManager manager; - try - { - var updated = false; - doc.Load(projectFile); - - manager = new XmlNamespaceManager(doc.NameTable); - manager.AddNamespace("msb", SolutionSynchronizer.MSBuildNamespaceUri); - - XmlNodeList compileNodes = doc.SelectNodes("//msb:Compile[@Include]", manager); - foreach (XmlNode node in compileNodes) - updated |= ReplacePathInNode(node, projectDir); - - XmlNodeList noneNodes = doc.SelectNodes("//msb:None[@Include]", manager); - foreach (XmlNode node in noneNodes) - updated |= ReplacePathInNode(node, projectDir); - - if (updated) - doc.Save(projectFile); - } - catch (Exception e) - { - UnityEngine.Debug.LogWarning("Post processing of CS project file " + projectFile + " failed, reason: " + e.Message); - } - } - - /// - /// Callback from AssetPostprocessor which is called after CSProj file(s) are generated. - /// - public static void OnGeneratedCSProjectFiles() - { - if (!UnityVSSupport.IsUnityVSEnabled()) - return; - - try - { - var projectDir = Directory.GetCurrentDirectory(); - var projectFiles = Directory.GetFiles(projectDir, string.Format("*{0}", SolutionSynchronizer.GetProjectExtension(ScriptingLanguage.CSharp)), SearchOption.TopDirectoryOnly); - foreach (string projectFile in projectFiles) - { - var file = projectFile.Substring(projectDir.Length + 1); - ReplacePathsInProjectFile(file, projectDir); - } - } - catch (Exception e) - { - UnityEngine.Debug.LogWarning("Post processing of CS project files failed, reason: " + e.Message); - } - } - } public static class SolutionGuidGenerator { diff --git a/README.md b/README.md index 96217bd6ac..211c5d9821 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0f1 C# reference source code +## Unity 2018.2.0f2 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/Export/Gradient.bindings.cs b/Runtime/Export/Gradient.bindings.cs index 969ff3e52e..5e425300a9 100644 --- a/Runtime/Export/Gradient.bindings.cs +++ b/Runtime/Export/Gradient.bindings.cs @@ -54,7 +54,6 @@ public enum GradientMode // Gradient used for animating colors [StructLayout(LayoutKind.Sequential)] - [ThreadAndSerializationSafe()] [RequiredByNativeCode] [NativeHeader("Runtime/Export/Gradient.bindings.h")] public class Gradient @@ -79,19 +78,19 @@ public Gradient() } // Calculate color at a given time - [FreeFunction(Name = "Gradient_Bindings::Evaluate", HasExplicitThis = true)] + [FreeFunction(Name = "Gradient_Bindings::Evaluate", IsThreadSafe = true, HasExplicitThis = true)] extern public Color Evaluate(float time); extern public GradientColorKey[] colorKeys { - [FreeFunction("Gradient_Bindings::GetColorKeys", HasExplicitThis = true)] get; - [FreeFunction("Gradient_Bindings::SetColorKeys", HasExplicitThis = true)] set; + [FreeFunction("Gradient_Bindings::GetColorKeys", IsThreadSafe = true, HasExplicitThis = true)] get; + [FreeFunction("Gradient_Bindings::SetColorKeys", IsThreadSafe = true, HasExplicitThis = true)] set; } extern public GradientAlphaKey[] alphaKeys { - [FreeFunction("Gradient_Bindings::GetAlphaKeys", HasExplicitThis = true)] get; - [FreeFunction("Gradient_Bindings::SetAlphaKeys", HasExplicitThis = true)] set; + [FreeFunction("Gradient_Bindings::GetAlphaKeys", IsThreadSafe = true, HasExplicitThis = true)] get; + [FreeFunction("Gradient_Bindings::SetAlphaKeys", IsThreadSafe = true, HasExplicitThis = true)] set; } @@ -100,7 +99,7 @@ extern public GradientAlphaKey[] alphaKeys extern internal Color constantColor { get; set; } // Setup Gradient with an array of color keys and alpha keys - [FreeFunction(Name = "Gradient_Bindings::SetKeys", HasExplicitThis = true)] + [FreeFunction(Name = "Gradient_Bindings::SetKeys", IsThreadSafe = true, HasExplicitThis = true)] extern public void SetKeys(GradientColorKey[] colorKeys, GradientAlphaKey[] alphaKeys); } } // end of UnityEngine From 3225c111b9a3e0b37160b9892fd493e1c11edf7d Mon Sep 17 00:00:00 2001 From: Unity Technologies Date: Thu, 26 Jul 2018 10:43:51 +0000 Subject: [PATCH 13/13] Unity 2018.2.1f1 C# reference source code --- .../AssetPipeline/TextureImporter.bindings.cs | 4 ++++ .../TextureImporterInspector.cs | 22 +++++++++++++++++++ Editor/Mono/Inspector/LightEditor.cs | 16 +++++++++++++- Editor/Mono/PackageUtility.bindings.cs | 2 ++ .../ScriptCompilation/EditorCompilation.cs | 2 +- .../Mono/SpriteEditor/SpriteEditorWindow.cs | 17 +++++++++----- README.md | 2 +- .../ScriptBindings/SpriteAtlas.bindings.cs | 10 +++++++++ 8 files changed, 67 insertions(+), 8 deletions(-) diff --git a/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs b/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs index 48cdb6f962..c91a9f56a6 100644 --- a/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs +++ b/Editor/Mono/AssetPipeline/TextureImporter.bindings.cs @@ -358,5 +358,9 @@ public void SetTextureSettings(TextureImporterSettings src) // Read texture import instructions into [[TextureImportInstructions]] class. public extern void ReadTextureImportInstructions(BuildTarget target, out TextureFormat desiredFormat, out ColorSpace colorSpace, out int compressionQuality); + + // This is pure backward compatibility codepath. It can be removed when we decide that the time has come + internal extern bool ShouldShowRemoveMatteOption(); + internal extern bool removeMatte { get; set; } } } diff --git a/Editor/Mono/ImportSettings/TextureImporterInspector.cs b/Editor/Mono/ImportSettings/TextureImporterInspector.cs index 6f44890b06..97013ce698 100644 --- a/Editor/Mono/ImportSettings/TextureImporterInspector.cs +++ b/Editor/Mono/ImportSettings/TextureImporterInspector.cs @@ -561,6 +561,11 @@ internal class Styles public readonly GUIContent showAdvanced = EditorGUIUtility.TrTextContent("Advanced", "Show advanced settings."); + public readonly GUIContent psdRemoveMatte = EditorGUIUtility.TrTextContent("Remove Matte (PSD)", "Enable special processing for PSD that has transparency, as color pixels will be tweaked (blended with white color)."); + public readonly GUIContent psdRemoveMatteWarning = EditorGUIUtility.TrTextContent("If you have PSD with transparency, colors will be tweaked by blending them with white color. Matte removal refers to our attempts to undo that, and this is deprecated."); + public readonly GUIContent psdRemoveMatteURLButton = EditorGUIUtility.TrTextContent("How to handle PSD with alpha"); + public readonly string psdRemoveMatteURL = "https://docs.unity3d.com/Manual/HOWTO-alphamaps.html"; + public Styles() { // This is far from ideal, but it's better than having tons of logic in the GUI code itself. @@ -641,6 +646,7 @@ void EnumPopup(SerializedProperty property, System.Type type, GUIContent label) SerializedProperty m_SpriteGenerateFallbackPhysicsShape; SerializedProperty m_AlphaIsTransparency; + SerializedProperty m_PSDRemoveMatte; SerializedProperty m_TextureShape; @@ -702,6 +708,7 @@ void CacheSerializedProperties() m_SpriteGenerateFallbackPhysicsShape = serializedObject.FindProperty("m_SpriteGenerateFallbackPhysicsShape"); m_AlphaIsTransparency = serializedObject.FindProperty("m_AlphaIsTransparency"); + m_PSDRemoveMatte = serializedObject.FindProperty("m_PSDRemoveMatte"); m_TextureType = serializedObject.FindProperty("m_TextureType"); m_TextureShape = serializedObject.FindProperty("m_TextureShape"); @@ -1110,6 +1117,21 @@ void AlphaHandlingGUI(TextureInspectorGUIElement guiElements) ToggleFromInt(m_AlphaIsTransparency, s_Styles.alphaIsTransparency); } } + + // This is pure backward compatibility codepath. It can be removed when we decide that the time has come + TextureImporter importer = target as TextureImporter; + if (importer.ShouldShowRemoveMatteOption()) + { + EditorGUILayout.PropertyField(m_PSDRemoveMatte, s_Styles.psdRemoveMatte); + if (m_PSDRemoveMatte.boolValue) + { + GUILayout.BeginVertical(); + EditorGUILayout.HelpBox(s_Styles.psdRemoveMatteWarning.text, MessageType.Warning, true); + if (EditorGUILayout.LinkLabel(s_Styles.psdRemoveMatteURLButton)) + Application.OpenURL(s_Styles.psdRemoveMatteURL); + GUILayout.EndVertical(); + } + } } private bool ShouldShowSpriteMeshTypeOption() diff --git a/Editor/Mono/Inspector/LightEditor.cs b/Editor/Mono/Inspector/LightEditor.cs index 2b6f45c392..c6036c2ad9 100644 --- a/Editor/Mono/Inspector/LightEditor.cs +++ b/Editor/Mono/Inspector/LightEditor.cs @@ -68,6 +68,7 @@ class Styles public readonly GUIContent LightmappingMode = EditorGUIUtility.TrTextContent("Mode", "Specifies the light mode used to determine if and how a light will be baked. Possible modes are Baked, Mixed, and Realtime."); public readonly GUIContent LightBounceIntensity = EditorGUIUtility.TrTextContent("Indirect Multiplier", "Controls the intensity of indirect light being contributed to the scene. A value of 0 will cause Realtime lights to be removed from realtime global illumination and Baked and Mixed lights to no longer emit indirect lighting. Has no effect when both Realtime and Baked Global Illumination are disabled."); public readonly GUIContent ShadowType = EditorGUIUtility.TrTextContent("Shadow Type", "Specifies whether Hard Shadows, Soft Shadows, or No Shadows will be cast by the light."); + public readonly GUIContent CastShadows = EditorGUIUtility.TrTextContent("Cast Shadows", "Specifies whether Soft Shadows or No Shadows will be cast by the light."); //realtime public readonly GUIContent ShadowRealtimeSettings = EditorGUIUtility.TrTextContent("Realtime Shadows", "Settings for realtime direct shadows."); public readonly GUIContent ShadowStrength = EditorGUIUtility.TrTextContent("Strength", "Controls how dark the shadows cast by the light will be."); @@ -376,7 +377,20 @@ public void ApplyModifiedProperties() public void DrawShadowsType() { EditorGUILayout.Space(); - EditorGUILayout.PropertyField(shadowsType, s_Styles.ShadowType); + if (light.type == LightType.Area) + { + EditorGUI.BeginChangeCheck(); + bool shadows = EditorGUILayout.Toggle(s_Styles.CastShadows, shadowsType.intValue != (int)LightShadows.None); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(light, "Adjust Shadow Type"); + shadowsType.intValue = shadows ? (int)LightShadows.Soft : (int)LightShadows.None; + } + } + else + { + EditorGUILayout.PropertyField(shadowsType, s_Styles.ShadowType); + } } public void DrawBakedShadowRadius() diff --git a/Editor/Mono/PackageUtility.bindings.cs b/Editor/Mono/PackageUtility.bindings.cs index ae732e0e95..ddc81d4910 100644 --- a/Editor/Mono/PackageUtility.bindings.cs +++ b/Editor/Mono/PackageUtility.bindings.cs @@ -60,6 +60,8 @@ internal class PackageUtility public static extern ExportPackageItem[] BuildExportPackageItemsList(string[] guids, bool dependencies); [NativeThrows] public static extern void ExportPackage(string[] guids, string fileName); + [NativeThrows] + public static extern void ExportPackageAndPackageManagerManifest(string[] guids, string fileName); public static extern ImportPackageItem[] ExtractAndPrepareAssetList(string packagePath, out string packageIconPath, out bool canPerformReInstall); [FreeFunction("DelayedImportPackageAssets")] diff --git a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs index 428b47d49f..344072a2f4 100644 --- a/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs +++ b/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs @@ -879,7 +879,7 @@ internal bool CompileScriptAssemblies(ScriptAssembly[] scriptAssemblies, ScriptA // Copy from tempBuildDirectory to assembly output directory if (!CopyAssembly(AssetPath.Combine(tempBuildDirectory, assembly.Filename), assembly.FullPath)) { - messages.Add(new CompilerMessage { message = string.Format("Copying assembly from directory {0} to {1} failed", tempBuildDirectory, assembly.OutputDirectory), type = CompilerMessageType.Error, file = assembly.FullPath, line = -1, column = -1 }); + messages.Add(new CompilerMessage { message = string.Format("Copying assembly from '{0}' to '{1}' failed", AssetPath.Combine(tempBuildDirectory, assembly.Filename), assembly.FullPath), type = CompilerMessageType.Error, file = assembly.FullPath, line = -1, column = -1 }); StopCompilationTask(); InvokeAssemblyCompilationFinished(assemblyOutputPath, messages); return; diff --git a/Editor/Mono/SpriteEditor/SpriteEditorWindow.cs b/Editor/Mono/SpriteEditor/SpriteEditorWindow.cs index be12dcce05..05570e9ac9 100644 --- a/Editor/Mono/SpriteEditor/SpriteEditorWindow.cs +++ b/Editor/Mono/SpriteEditor/SpriteEditorWindow.cs @@ -68,6 +68,7 @@ private class SpriteEditorWindowStyles private IMGUIContainer m_ToolbarIMGUIElement; private IMGUIContainer m_MainViewIMGUIElement; + private VisualElement m_ModuleViewElement; private VisualElement m_MainViewElement; [SerializeField] @@ -244,7 +245,13 @@ private void SetupVisualElements() { name = "spriteEditorWindowMainView", }; + m_ModuleViewElement = new VisualElement() + { + name = "moduleViewElement", + pickingMode = PickingMode.Ignore + }; m_MainViewElement.Add(m_MainViewIMGUIElement); + m_MainViewElement.Add(m_ModuleViewElement); var root = this.GetRootVisualContainer(); root.AddStyleSheetPath("StyleSheets/SpriteEditor/SpriteEditor.uss"); root.Add(m_ToolbarIMGUIElement); @@ -637,7 +644,7 @@ void SetupModule(int newModuleIndex) if (s_Instance == null) return; - m_MainViewIMGUIElement.Clear(); + m_ModuleViewElement.Clear(); if (m_RegisteredModules.Count > newModuleIndex) { m_CurrentModuleIndex = newModuleIndex; @@ -652,8 +659,8 @@ void SetupModule(int newModuleIndex) } if (m_MainViewElement != null) m_MainViewElement.Dirty(ChangeType.Repaint); - if (m_MainViewIMGUIElement != null) - m_MainViewIMGUIElement.Dirty(ChangeType.Repaint); + if (m_ModuleViewElement != null) + m_ModuleViewElement.Dirty(ChangeType.Repaint); } void UpdateAvailableModules() @@ -804,7 +811,7 @@ public SpriteRect selectedSpriteRect m_MainViewElement.Dirty(ChangeType.Repaint); using (var e = SpriteSelectionChangeEvent.GetPooled()) { - e.target = m_MainViewIMGUIElement; + e.target = m_ModuleViewElement; UIElementsUtility.eventDispatcher.DispatchEvent(e, m_MainViewElement.panel); } } @@ -893,7 +900,7 @@ public T GetDataProvider() where T : class public VisualElement GetMainVisualContainer() { - return m_MainViewIMGUIElement; + return m_ModuleViewElement; } static internal void OnTextureReimport(string path) diff --git a/README.md b/README.md index 211c5d9821..b5d95fd392 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Unity 2018.2.0f2 C# reference source code +## Unity 2018.2.1f1 C# reference source code The C# part of the Unity engine and editor source code. May be used for reference purposes only. diff --git a/Runtime/2D/SpriteAtlas/ScriptBindings/SpriteAtlas.bindings.cs b/Runtime/2D/SpriteAtlas/ScriptBindings/SpriteAtlas.bindings.cs index 7d5e251a7b..26daed40bc 100644 --- a/Runtime/2D/SpriteAtlas/ScriptBindings/SpriteAtlas.bindings.cs +++ b/Runtime/2D/SpriteAtlas/ScriptBindings/SpriteAtlas.bindings.cs @@ -28,6 +28,14 @@ private static bool RequestAtlas(string tag) return false; } + public static event Action atlasRegistered = null; + + [RequiredByNativeCode] + private static void PostRegisteredAtlas(SpriteAtlas spriteAtlas) + { + atlasRegistered?.Invoke(spriteAtlas); + } + extern internal static void Register(SpriteAtlas spriteAtlas); } @@ -42,6 +50,8 @@ public class SpriteAtlas : UnityEngine.Object extern public string tag { get; } extern public int spriteCount { get; } + extern public bool CanBindTo(Sprite sprite); + extern public Sprite GetSprite(string name); public int GetSprites(Sprite[] sprites) { return GetSpritesScripting(sprites); } public int GetSprites(Sprite[] sprites, string name) { return GetSpritesWithNameScripting(sprites, name); }