| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b9bc712 commit 7038d6c
165 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -146,6 +146,9 @@ internal static void StartAnimationRecording() | |||
| 146 | 146 | [NativeThrows] | |
| 147 | 147 | extern public static void AddPropertyModification(EditorCurveBinding binding, PropertyModification modification, bool keepPrefabOverride); | |
| 148 | 148 | ||
| 149 | + [NativeThrows] | ||
| 150 | + extern public static void AddEditorCurveBinding([NotNull] GameObject gameObject, EditorCurveBinding binding); | ||
| 151 | + | ||
| 149 | 152 | [NativeThrows] | |
| 150 | 153 | extern internal static void AddTransformTR([NotNull] GameObject root, string path); | |
| 151 | 154 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -143,8 +143,14 @@ internal static EditorCurveBinding[] GetAnimatableBindings(ScriptableObject scri | |||
| 143 | 143 | return Internal_GetScriptableObjectAnimatableBindings(scriptableObject); | |
| 144 | 144 | } | |
| 145 | 145 | ||
| 146 | + internal static EditorCurveBinding[] GetAdditionalAnimatorBindings(GameObject targetObject) | ||
| 147 | + { | ||
| 148 | + return Internal_GetAdditionalAnimatorBindings(targetObject); | ||
| 149 | + } | ||
| 150 | + | ||
| 146 | 151 | extern private static EditorCurveBinding[] Internal_GetGameObjectAnimatableBindings([NotNull] GameObject targetObject, [NotNull] GameObject root); | |
| 147 | 152 | extern private static EditorCurveBinding[] Internal_GetScriptableObjectAnimatableBindings([NotNull] ScriptableObject scriptableObject); | |
| 153 | + extern private static EditorCurveBinding[] Internal_GetAdditionalAnimatorBindings([NotNull] GameObject targetObject); | ||
| 148 | 154 | ||
| 149 | 155 | // Binds the property and returns the type of the bound value (Can be used to display special UI for it and to enforce correct drag and drop) | |
| 150 | 156 | // null if it can't be bound. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,23 +13,37 @@ namespace UnityEditorInternal | |||
| 13 | 13 | internal class AddCurvesPopup : EditorWindow | |
| 14 | 14 | { | |
| 15 | 15 | const float k_WindowPadding = 3; | |
| 16 | + const float k_SpaceForSlider = 16; | ||
| 17 | + | ||
| 18 | + const float k_WindowMaxWidth = 450; | ||
| 19 | + const float k_WindowMinWidth = 240; | ||
| 20 | + const float k_WindowFixedHeight = 250; | ||
| 16 | 21 | ||
| 17 | 22 | internal static AnimationWindowState s_State; | |
| 18 | 23 | ||
| 19 | 24 | private static AddCurvesPopup s_AddCurvesPopup; | |
| 20 | 25 | private static long s_LastClosedTime; | |
| 21 | 26 | private static AddCurvesPopupHierarchy s_Hierarchy; | |
| 22 | 27 | ||
| 23 | - private static Vector2 windowSize = new Vector2(240, 250); | ||
| 24 | - | ||
| 25 | 28 | public delegate void OnNewCurveAdded(AddCurvesPopupPropertyNode node); | |
| 26 | 29 | ||
| 27 | 30 | private static OnNewCurveAdded NewCurveAddedCallback; | |
| 28 | 31 | ||
| 32 | + Vector2 GetWindowSize() | ||
| 33 | + { | ||
| 34 | + float contentWidth = s_Hierarchy.GetContentWidth(); | ||
| 35 | + float width = Mathf.Clamp(contentWidth + k_SpaceForSlider + k_WindowPadding, k_WindowMinWidth, k_WindowMaxWidth); | ||
| 36 | + return new Vector2(width, k_WindowFixedHeight); | ||
| 37 | + } | ||
| 38 | + | ||
| 29 | 39 | void Init(Rect buttonRect) | |
| 30 | 40 | { | |
| 41 | + s_Hierarchy = new AddCurvesPopupHierarchy(); | ||
| 42 | + s_Hierarchy.InitIfNeeded(this, new Rect(0, 0, k_WindowMinWidth, k_WindowFixedHeight)); | ||
| 43 | + | ||
| 31 | 44 | buttonRect = GUIUtility.GUIToScreenRect(buttonRect); | |
| 32 | - ShowAsDropDown(buttonRect, windowSize, new[] { PopupLocation.Right }); | ||
| 45 | + | ||
| 46 | + ShowAsDropDown(buttonRect, GetWindowSize(), new[] { PopupLocation.Right }); | ||
| 33 | 47 | } | |
| 34 | 48 | ||
| 35 | 49 | void OnEnable() | |
@@ -77,8 +91,7 @@ internal void OnGUI() | |||
| 77 | 91 | if (Event.current.type == EventType.Layout) | |
| 78 | 92 | return; | |
| 79 | 93 | ||
| 80 | - if (s_Hierarchy == null) | ||
| 81 | - s_Hierarchy = new AddCurvesPopupHierarchy(); | ||
| 94 | + Vector2 windowSize = GetWindowSize(); | ||
| 82 | 95 | ||
| 83 | 96 | Rect rect = new Rect(1, 1, windowSize.x - k_WindowPadding, windowSize.y - k_WindowPadding); | |
| 84 | 97 | GUI.Box(new Rect(0, 0, windowSize.x, windowSize.y), GUIContent.none, "grey_border"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,9 +14,16 @@ internal class AddCurvesPopupHierarchy | |||
| 14 | 14 | private TreeViewState m_TreeViewState; | |
| 15 | 15 | private AddCurvesPopupHierarchyDataSource m_TreeViewDataSource; | |
| 16 | 16 | ||
| 17 | + private float m_ContentWidth = 0f; | ||
| 18 | + | ||
| 19 | + public float GetContentWidth() | ||
| 20 | + { | ||
| 21 | + return m_ContentWidth; | ||
| 22 | + } | ||
| 23 | + | ||
| 17 | 24 | public void OnGUI(Rect position, EditorWindow owner) | |
| 18 | 25 | { | |
| 19 | - InitIfNeeded(owner, position); | ||
| 26 | + m_TreeView.SetTotalRect(position); | ||
| 20 | 27 | m_TreeView.OnEvent(); | |
| 21 | 28 | m_TreeView.OnGUI(position, GUIUtility.GetControlID(FocusType.Keyboard)); | |
| 22 | 29 | } | |
@@ -33,7 +40,7 @@ public void InitIfNeeded(EditorWindow owner, Rect rect) | |||
| 33 | 40 | m_TreeView.deselectOnUnhandledMouseDown = true; | |
| 34 | 41 | ||
| 35 | 42 | m_TreeViewDataSource = new AddCurvesPopupHierarchyDataSource(m_TreeView); | |
| 36 | - TreeViewGUI gui = new AddCurvesPopupHierarchyGUI(m_TreeView, owner); | ||
| 43 | + AddCurvesPopupHierarchyGUI gui = new AddCurvesPopupHierarchyGUI(m_TreeView, owner); | ||
| 37 | 44 | ||
| 38 | 45 | m_TreeView.Init(rect, | |
| 39 | 46 | m_TreeViewDataSource, | |
@@ -42,6 +49,8 @@ public void InitIfNeeded(EditorWindow owner, Rect rect) | |||
| 42 | 49 | ); | |
| 43 | 50 | ||
| 44 | 51 | m_TreeViewDataSource.UpdateData(); | |
| 52 | + | ||
| 53 | + m_ContentWidth = gui.GetContentWidth(); | ||
| 45 | 54 | } | |
| 46 | 55 | ||
| 47 | 56 | internal virtual bool IsRenamingNodeAllowed(TreeViewItem node) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,7 @@ private void SetupRootNodeSettings() | |||
| 31 | 31 | ||
| 32 | 32 | public override void FetchData() | |
| 33 | 33 | { | |
| 34 | + m_RootItem = null; | ||
| 34 | 35 | if (AddCurvesPopup.s_State.selection.canAddCurves) | |
| 35 | 36 | { | |
| 36 | 37 | GameObject rootGameObject = AddCurvesPopup.s_State.activeRootGameObject; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | using UnityEditor; | |
| 6 | 6 | using UnityEditor.IMGUI.Controls; | |
| 7 | 7 | using UnityEngine; | |
| 8 | + using System.Collections.Generic; | ||
| 8 | 9 | ||
| 9 | 10 | namespace UnityEditorInternal | |
| 10 | 11 | { | |
@@ -14,6 +15,7 @@ internal class AddCurvesPopupHierarchyGUI : TreeViewGUI | |||
| 14 | 15 | public bool showPlusButton { get; set; } | |
| 15 | 16 | private GUIStyle plusButtonStyle = "OL Plus"; | |
| 16 | 17 | private GUIStyle plusButtonBackgroundStyle = "Tag MenuItem"; | |
| 18 | + private GUIContent addPropertiesContent = EditorGUIUtility.TrTextContent("Add Properties"); | ||
| 17 | 19 | private const float plusButtonWidth = 17; | |
| 18 | 20 | ||
| 19 | 21 | public AddCurvesPopupHierarchyGUI(TreeViewController treeView, EditorWindow owner) | |
@@ -25,7 +27,12 @@ public AddCurvesPopupHierarchyGUI(TreeViewController treeView, EditorWindow owne | |||
| 25 | 27 | public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused) | |
| 26 | 28 | { | |
| 27 | 29 | base.OnRowGUI(rowRect, node, row, selected, focused); | |
| 30 | + DoAddCurveButton(rowRect, node); | ||
| 31 | + HandleContextMenu(rowRect, node); | ||
| 32 | + } | ||
| 28 | 33 | ||
| 34 | + private void DoAddCurveButton(Rect rowRect, TreeViewItem node) | ||
| 35 | + { | ||
| 29 | 36 | // Is it propertynode. If not, then we don't need plusButton so quit here | |
| 30 | 37 | AddCurvesPopupPropertyNode hierarchyNode = node as AddCurvesPopupPropertyNode; | |
| 31 | 38 | if (hierarchyNode == null || hierarchyNode.curveBindings == null || hierarchyNode.curveBindings.Length == 0) | |
@@ -41,10 +48,85 @@ public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool sel | |||
| 41 | 48 | if (GUI.Button(buttonRect, GUIContent.none, plusButtonStyle)) | |
| 42 | 49 | { | |
| 43 | 50 | AddCurvesPopup.AddNewCurve(hierarchyNode); | |
| 44 | - owner.Close(); | ||
| 51 | + | ||
| 52 | + // Hold shift key to add new curves and keep window opened. | ||
| 53 | + if (Event.current.shift) | ||
| 54 | + m_TreeView.ReloadData(); | ||
| 55 | + else | ||
| 56 | + owner.Close(); | ||
| 45 | 57 | } | |
| 46 | 58 | } | |
| 47 | 59 | ||
| 60 | + private void HandleContextMenu(Rect rowRect, TreeViewItem node) | ||
| 61 | + { | ||
| 62 | + if (Event.current.type != EventType.ContextClick) | ||
| 63 | + return; | ||
| 64 | + | ||
| 65 | + if (rowRect.Contains(Event.current.mousePosition)) | ||
| 66 | + { | ||
| 67 | + // Add current node to selection | ||
| 68 | + var ids = new List<int>(m_TreeView.GetSelection()); | ||
| 69 | + ids.Add(node.id); | ||
| 70 | + m_TreeView.SetSelection(ids.ToArray(), false, false); | ||
| 71 | + | ||
| 72 | + GenerateMenu().ShowAsContext(); | ||
| 73 | + Event.current.Use(); | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + private GenericMenu GenerateMenu() | ||
| 78 | + { | ||
| 79 | + GenericMenu menu = new GenericMenu(); | ||
| 80 | + menu.AddItem(addPropertiesContent, false, AddPropertiesFromSelectedNodes); | ||
| 81 | + | ||
| 82 | + return menu; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + private void AddPropertiesFromSelectedNodes() | ||
| 86 | + { | ||
| 87 | + int[] ids = m_TreeView.GetSelection(); | ||
| 88 | + for (int i = 0; i < ids.Length; ++i) | ||
| 89 | + { | ||
| 90 | + var node = m_TreeView.FindItem(ids[i]); | ||
| 91 | + var propertyNode = node as AddCurvesPopupPropertyNode; | ||
| 92 | + | ||
| 93 | + if (propertyNode != null) | ||
| 94 | + { | ||
| 95 | + AddCurvesPopup.AddNewCurve(propertyNode); | ||
| 96 | + } | ||
| 97 | + else if (node.hasChildren) | ||
| 98 | + { | ||
| 99 | + foreach (var childNode in node.children) | ||
| 100 | + { | ||
| 101 | + var childPropertyNode = childNode as AddCurvesPopupPropertyNode; | ||
| 102 | + if (childPropertyNode != null) | ||
| 103 | + { | ||
| 104 | + AddCurvesPopup.AddNewCurve(childPropertyNode); | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + m_TreeView.ReloadData(); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public float GetContentWidth() | ||
| 114 | + { | ||
| 115 | + IList<TreeViewItem> rows = m_TreeView.data.GetRows(); | ||
| 116 | + List<TreeViewItem> allRows = new List<TreeViewItem>(); | ||
| 117 | + allRows.AddRange(rows); | ||
| 118 | + | ||
| 119 | + for (int i = 0; i < allRows.Count; ++i) | ||
| 120 | + { | ||
| 121 | + var row = allRows[i]; | ||
| 122 | + if (row.hasChildren) | ||
| 123 | + allRows.AddRange(row.children); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + float rowWidth = GetMaxWidth(allRows); | ||
| 127 | + return rowWidth + plusButtonWidth; | ||
| 128 | + } | ||
| 129 | + | ||
| 48 | 130 | override protected void SyncFakeItem() | |
| 49 | 131 | { | |
| 50 | 132 | //base.SyncFakeItem(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -377,29 +377,38 @@ public void SetShownHRange(float min, float max) | |||
| 377 | 377 | ||
| 378 | 378 | public void SetShownVRangeInsideMargins(float min, float max) | |
| 379 | 379 | { | |
| 380 | + float heightInsideMargins = drawRect.height - topmargin - bottommargin; | ||
| 381 | + if (heightInsideMargins < kMinHeight) heightInsideMargins = kMinHeight; | ||
| 382 | + | ||
| 383 | + float denum = max - min; | ||
| 384 | + if (denum < kMinHeight) denum = kMinHeight; | ||
| 385 | + | ||
| 380 | 386 | if (m_UpDirection == YDirection.Positive) | |
| 381 | 387 | { | |
| 382 | - m_Scale.y = -(drawRect.height - topmargin - bottommargin) / (max - min); | ||
| 388 | + m_Scale.y = -heightInsideMargins / denum; | ||
| 383 | 389 | m_Translation.y = drawRect.height - min * m_Scale.y - topmargin; | |
| 384 | 390 | } | |
| 385 | 391 | else | |
| 386 | 392 | { | |
| 387 | - m_Scale.y = (drawRect.height - topmargin - bottommargin) / (max - min); | ||
| 393 | + m_Scale.y = heightInsideMargins / denum; | ||
| 388 | 394 | m_Translation.y = -min * m_Scale.y - bottommargin; | |
| 389 | 395 | } | |
| 390 | 396 | EnforceScaleAndRange(); | |
| 391 | 397 | } | |
| 392 | 398 | ||
| 393 | 399 | public void SetShownVRange(float min, float max) | |
| 394 | 400 | { | |
| 401 | + float denum = max - min; | ||
| 402 | + if (denum < kMinHeight) denum = kMinHeight; | ||
| 403 | + | ||
| 395 | 404 | if (m_UpDirection == YDirection.Positive) | |
| 396 | 405 | { | |
| 397 | - m_Scale.y = -drawRect.height / (max - min); | ||
| 406 | + m_Scale.y = -drawRect.height / denum; | ||
| 398 | 407 | m_Translation.y = drawRect.height - min * m_Scale.y; | |
| 399 | 408 | } | |
| 400 | 409 | else | |
| 401 | 410 | { | |
| 402 | - m_Scale.y = drawRect.height / (max - min); | ||
| 411 | + m_Scale.y = drawRect.height / denum; | ||
| 403 | 412 | m_Translation.y = -min * m_Scale.y; | |
| 404 | 413 | } | |
| 405 | 414 | EnforceScaleAndRange(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,7 @@ | |||
| 19 | 19 | [assembly: InternalsVisibleTo("Unity.PackageManagerStandalone")] | |
| 20 | 20 | [assembly: InternalsVisibleTo("Unity.AndroidBuildPipeline")] | |
| 21 | 21 | [assembly: InternalsVisibleTo("Unity.Automation")] | |
| 22 | + [assembly: InternalsVisibleTo("UnityEngine.Common")] | ||
| 22 | 23 | [assembly: InternalsVisibleTo("Unity.PureCSharpTests")] | |
| 23 | 24 | [assembly: InternalsVisibleTo("Unity.IntegrationTests")] | |
| 24 | 25 | [assembly: InternalsVisibleTo("Unity.DeploymentTests.Services")] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,7 @@ | |||
| 12 | 12 | using System.Linq; | |
| 13 | 13 | using System.IO; | |
| 14 | 14 | using UnityEditor.Web; | |
| 15 | + using UnityEditor.Analytics; | ||
| 15 | 16 | ||
| 16 | 17 | namespace UnityEditor | |
| 17 | 18 | { | |
@@ -163,6 +164,15 @@ public void OpenBrowser(string url) | |||
| 163 | 164 | Application.OpenURL(url); | |
| 164 | 165 | } | |
| 165 | 166 | ||
| 167 | + [Serializable] | ||
| 168 | + public struct DownloadAssetInfo | ||
| 169 | + { | ||
| 170 | + public string package_id; | ||
| 171 | + public string package_name; | ||
| 172 | + public string publisher_name; | ||
| 173 | + public string category_name; | ||
| 174 | + } | ||
| 175 | + | ||
| 166 | 176 | public void Download(Package package, DownloadInfo downloadInfo) | |
| 167 | 177 | { | |
| 168 | 178 | Download( | |
@@ -205,6 +215,13 @@ public static void Download(string package_id, string url, string key, string pa | |||
| 205 | 215 | parameters["download"] = download; | |
| 206 | 216 | ||
| 207 | 217 | AssetStoreUtils.Download(package_id, url, dest, key, parameters.ToString(), resumeOK, doneCallback); | |
| 218 | + EditorAnalytics.SendAssetDownloadEvent(new DownloadAssetInfo() | ||
| 219 | + { | ||
| 220 | + package_id = package_id, | ||
| 221 | + package_name = package_name, | ||
| 222 | + publisher_name = publisher_name, | ||
| 223 | + category_name = category_name | ||
| 224 | + }); | ||
| 208 | 225 | } | |
| 209 | 226 | ||
| 210 | 227 | /// <summary> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,6 +106,10 @@ void DrawElement(Rect rect, int index, bool isActive, bool isFocused) | |||
| 106 | 106 | ||
| 107 | 107 | public Vector2 CalcSize() | |
| 108 | 108 | { | |
| 109 | + if (m_ReorderableListWithRenameAndScrollView.list.count != m_Controller.exposedParameters.Length) | ||
| 110 | + { | ||
| 111 | + RecreateListControl(); | ||
| 112 | + } | ||
| 109 | 113 | float maxWidth = 0; | |
| 110 | 114 | for (int index = 0; index < m_ReorderableListWithRenameAndScrollView.list.count; index++) | |
| 111 | 115 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments