FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Unity 2021.3.11f1 C# reference source code · hardcoded2/UnityCsReference@6d3b44c · GitHub

Commit 6d3b44c

Browse files
Unity Technologies
committed
Unity 2021.3.11f1 C# reference source code
1 parent d445ef7 commit 6d3b44c

21 files changed

Lines changed: 244 additions & 109 deletions

File tree

‎Editor/Mono/CodeEditor/CodeEditorAnalytics.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ static bool EnableAnalytics()
3131

3232
public static void SendCodeEditorUsage(IExternalCodeEditor codeEditor)
3333
{
34-
if (!UnityEngine.Analytics.Analytics.enabled)
35-
return;
36-
3734
if (!EnableAnalytics())
3835
return;
3936

‎Editor/Mono/EditorUserBuildSettings.bindings.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public enum PS4BuildSubtarget
5151
/// SA: EditorUserBuildSettings.ps4BuildSubtarget.
5252
Package = 1,
5353
Iso = 2,
54+
GP4Project = 3,
5455
}
5556

5657

‎Editor/Mono/GUI/Tools/EditorToolAttributes.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ protected ToolAttribute(string displayName, Type targetType = null, Type editorT
3131
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
3232
public sealed class EditorToolAttribute : ToolAttribute
3333
{
34-
public EditorToolAttribute(string displayName, Type componentToolTarget = null, Type editorToolContext = null)
34+
public EditorToolAttribute(string displayName, Type componentToolTarget = null)
35+
: base(displayName, componentToolTarget) {}
36+
public EditorToolAttribute(string displayName, Type componentToolTarget, Type editorToolContext)
3537
: base(displayName, componentToolTarget, editorToolContext) {}
3638
}
3739

‎Editor/Mono/HandleUtility.cs‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,14 +1061,19 @@ internal static GameObject FindSelectionBaseForPicking(GameObject go)
10611061
// alternatively a GameObject with the SelectionBaseAttribute assigned.
10621062
Transform tr = go.transform;
10631063
GameObject outerMostSelectableRoot = null;
1064+
GameObject prefabBaseGo = null;
10641065

10651066
while (tr != null)
10661067
{
10671068
if (!SceneVisibilityState.IsGameObjectPickingDisabled(tr.gameObject))
10681069
{
1069-
// If we come across the prefab base, no need to search further
1070-
if (tr == prefabBase)
1071-
return tr.gameObject;
1070+
// If we come across the prefab base, we still need to make sure there are no
1071+
// go with the SelectionBaseAttribute assigned before returning prefabBaseGo.
1072+
if (tr == prefabBase && prefabBaseGo == null)
1073+
{
1074+
prefabBaseGo = tr.gameObject;
1075+
continue;
1076+
}
10721077

10731078
// Only test again nested prefab if go is already part of a prefab to avoid selecting a
10741079
// parent prefab is the current go is only child of this prefab but does not belong to it
@@ -1081,14 +1086,18 @@ internal static GameObject FindSelectionBaseForPicking(GameObject go)
10811086
outerMostSelectableRoot = tr.gameObject;
10821087
}
10831088

1084-
// If a SelectionBaseAttribute is found, select the nearest to the picked GameObject
1089+
// If a SelectionBaseAttribute is found, select the nearest to the picked GameObject.
1090+
// GameObjects with the SelectionBaseAttribute should have priority over all others.
10851091
if (AttributeHelper.GameObjectContainsAttribute<SelectionBaseAttribute>(tr.gameObject))
10861092
return tr.gameObject;
10871093
}
10881094

10891095
tr = tr.parent;
10901096
}
10911097

1098+
if (prefabBaseGo != null)
1099+
return prefabBaseGo;
1100+
10921101
return outerMostSelectableRoot;
10931102
}
10941103

‎Editor/Mono/Inspector/EditorSettingsInspector.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ private void DoAssetPipelineSettings()
662662
{
663663
// Known issue with Docs redirect - versioned pages might not open offline docs
664664
var help = Help.FindHelpNamed("ParallelImport");
665-
Application.OpenURL(help);
665+
Help.BrowseURL(help);
666666
}
667667
GUILayout.EndHorizontal();
668668
}
@@ -738,7 +738,7 @@ private void DoCacheServerSettings()
738738
{
739739
// Known issue with Docs redirect - versioned pages might not open offline docs
740740
var help = Help.FindHelpNamed("UnityAccelerator");
741-
Application.OpenURL(help);
741+
Help.BrowseURL(help);
742742
}
743743
GUILayout.EndHorizontal();
744744

‎Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class SettingsContent
215215
public static readonly GUIContent lightmapStreamingPriority = EditorGUIUtility.TrTextContent("Streaming Priority", "Lightmap mipmap streaming priority when there's contention for resources. Positive numbers represent higher priority. Valid range is -128 to 127. This value is applied to the light map textures as they are generated.");
216216
public static readonly GUIContent lightmapQualityAndroidWarning = EditorGUIUtility.TrTextContent("The selected Lightmap Encoding requires OpenGL ES 3.0 or Vulkan. Please remove the OpenGL ES 2 API.");
217217
public static readonly GUIContent legacyClampBlendShapeWeights = EditorGUIUtility.TrTextContent("Clamp BlendShapes (Deprecated)*", "If set, the range of BlendShape weights in SkinnedMeshRenderers will be clamped.");
218-
public static readonly GUIContent virtualTexturingSupportEnabled = EditorGUIUtility.TrTextContent("Virtual Texturing*", "Enable support for Virtual Texturing. Changing this value requires an Editor restart.");
218+
public static readonly GUIContent virtualTexturingSupportEnabled = EditorGUIUtility.TrTextContent("Virtual Texturing (Experimental)*", "Enable Virtual Texturing. This feature is experimental and not ready for production use. Changing this value requires an Editor restart.");
219219
public static readonly GUIContent virtualTexturingUnsupportedPlatformWarning = EditorGUIUtility.TrTextContent("The current target platform does not support Virtual Texturing. To build for this platform, uncheck Enable Virtual Texturing.");
220220
public static readonly GUIContent virtualTexturingUnsupportedAPI = EditorGUIUtility.TrTextContent("The target graphics API does not support Virtual Texturing. To target compatible graphics APIs, uncheck 'Auto Graphics API', and remove OpenGL ES 2/3 and OpenGLCore.");
221221
public static readonly GUIContent virtualTexturingUnsupportedAPIWin = EditorGUIUtility.TrTextContent("The target Windows graphics API does not support Virtual Texturing. To target compatible graphics APIs, uncheck 'Auto Graphics API for Windows', and remove OpenGL ES 2/3 and OpenGLCore.");

‎Editor/Mono/Networking/PlayerConnection/ConnectionDropDown.cs‎

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -105,40 +105,65 @@ public static string GetPort(int connectionId)
105105

106106
public static GUIContent GetIcon(string name)
107107
{
108-
// *begin-nonstandard-formatting*
109-
var content = name switch
108+
var content = GetBuildTargetIcon(name);
109+
if (content == null)
110110
{
111-
"Editor" => EditorGUIUtility.IconContent("d_SceneAsset Icon"),
112-
"WindowsEditor" => EditorGUIUtility.IconContent("d_SceneAsset Icon"),
113-
"WindowsPlayer" => EditorGUIUtility.IconContent("BuildSettings.Metro.Small"),
114-
"Android" => EditorGUIUtility.IconContent("BuildSettings.Android.Small"),
115-
"OSXPlayer" => EditorGUIUtility.IconContent("BuildSettings.Standalone.Small"),
116-
"IPhonePlayer" => EditorGUIUtility.IconContent("BuildSettings.iPhone.Small"),
117-
"WebGLPlayer" => EditorGUIUtility.IconContent("BuildSettings.WebGL.Small"),
118-
"tvOS" => EditorGUIUtility.IconContent("BuildSettings.tvOS.Small"),
119-
"Lumin" => EditorGUIUtility.IconContent("BuildSettings.Lumin.small"),
120-
"LinuxPlayer" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
121-
"WSAPlayerX86" => EditorGUIUtility.IconContent("BuildSettings.Metro.Small"),
122-
"WSAPlayerX64" => EditorGUIUtility.IconContent("BuildSettings.Metro.Small"),
123-
"WSAPlayerARM" => EditorGUIUtility.IconContent("BuildSettings.Metro.Small"),
124-
"Switch" => EditorGUIUtility.IconContent("BuildSettings.Switch.Small"),
125-
"Stadia" => EditorGUIUtility.IconContent("BuildSettings.Stadia.small"),
126-
"GameCoreScarlett" => EditorGUIUtility.IconContent("BuildSettings.GameCoreScarlett.Small"),
127-
"GameCoreXboxOne" => EditorGUIUtility.IconContent("BuildSettings.GameCoreXboxOne.Small"),
128-
"XboxOne" => EditorGUIUtility.IconContent("BuildSettings.GameCoreXboxOne.Small"),
129-
"EmbeddedLinuxArm64" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
130-
"EmbeddedLinuxArm32" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
131-
"EmbeddedLinuxX64" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
132-
"EmbeddedLinuxX86" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
133-
"PS4" => EditorGUIUtility.IconContent("BuildSettings.PS4.Small"),
134-
"PS5" => EditorGUIUtility.IconContent("BuildSettings.PS5.Small"),
135-
"Devices" => EditorGUIUtility.IconContent("BuildSettings.Standalone.Small"),
136-
"<unknown>" => EditorGUIUtility.IconContent("BuildSettings.Broadcom"),
137-
_ => EditorGUIUtility.IconContent("BuildSettings.Broadcom")
138-
};
139-
// *end-nonstandard-formatting*
111+
// *begin-nonstandard-formatting*
112+
content = name switch
113+
{
114+
"Editor" => EditorGUIUtility.IconContent("d_SceneAsset Icon"),
115+
"WindowsEditor" => EditorGUIUtility.IconContent("d_SceneAsset Icon"),
116+
"WindowsPlayer" => EditorGUIUtility.IconContent("BuildSettings.Metro.Small"),
117+
"Android" => EditorGUIUtility.IconContent("BuildSettings.Android.Small"),
118+
"OSXPlayer" => EditorGUIUtility.IconContent("BuildSettings.Standalone.Small"),
119+
"IPhonePlayer" => EditorGUIUtility.IconContent("BuildSettings.iPhone.Small"),
120+
"WebGLPlayer" => EditorGUIUtility.IconContent("BuildSettings.WebGL.Small"),
121+
"tvOS" => EditorGUIUtility.IconContent("BuildSettings.tvOS.Small"),
122+
"Lumin" => EditorGUIUtility.IconContent("BuildSettings.Lumin.small"),
123+
"LinuxPlayer" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
124+
"WSAPlayerX86" => EditorGUIUtility.IconContent("BuildSettings.Metro.Small"),
125+
"WSAPlayerX64" => EditorGUIUtility.IconContent("BuildSettings.Metro.Small"),
126+
"WSAPlayerARM" => EditorGUIUtility.IconContent("BuildSettings.Metro.Small"),
127+
"Switch" => EditorGUIUtility.IconContent("BuildSettings.Switch.Small"),
128+
"Stadia" => EditorGUIUtility.IconContent("BuildSettings.Stadia.small"),
129+
"EmbeddedLinuxArm64" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
130+
"EmbeddedLinuxArm32" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
131+
"EmbeddedLinuxX64" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
132+
"EmbeddedLinuxX86" => EditorGUIUtility.IconContent("BuildSettings.EmbeddedLinux.Small"),
133+
"PS4" => EditorGUIUtility.IconContent("BuildSettings.PS4.Small"),
134+
"PS5" => EditorGUIUtility.IconContent("BuildSettings.PS5.Small"),
135+
"Devices" => EditorGUIUtility.IconContent("BuildSettings.Standalone.Small"),
136+
"<unknown>" => EditorGUIUtility.IconContent("BuildSettings.Broadcom"),
137+
_ => EditorGUIUtility.IconContent("BuildSettings.Broadcom")
138+
};
139+
// *end-nonstandard-formatting*
140+
}
141+
140142
return content;
141143
}
144+
145+
private static GUIContent GetBuildTargetIcon(string name)
146+
{
147+
var target = BuildPipeline.GetBuildTargetByName(name);
148+
if (target == BuildTarget.NoTarget)
149+
{
150+
return null;
151+
}
152+
153+
var namedBuildTarget = Build.NamedBuildTarget.FromActiveSettings(target);
154+
if (namedBuildTarget == null)
155+
{
156+
return null;
157+
}
158+
159+
var buildPlatform = Build.BuildPlatforms.instance.BuildPlatformFromNamedBuildTarget(namedBuildTarget);
160+
if (buildPlatform == null || buildPlatform.smallIcon == null)
161+
{
162+
return null;
163+
}
164+
165+
return new GUIContent(buildPlatform.smallIcon);
166+
}
142167
}
143168

144169
internal class ConnectionDropDownItem : TreeViewItem
@@ -703,7 +728,7 @@ public override void OnGUI(Rect rect)
703728
if (EditorGUI.Button(rect, Content.TroubleShoot, ConnectionDropDownStyles.sConnectionTrouble))
704729
{
705730
var help = Help.FindHelpNamed("profiler-profiling-applications");
706-
Application.OpenURL(help);
731+
Help.BrowseURL(help);
707732
}
708733

709734
if (Event.current.type == EventType.MouseMove)

‎Editor/Mono/PreferencesWindow/AssetPipelinePreferences.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void ShowGUI()
249249
{
250250
// Known issue with Docs redirect - versioned pages might not open offline docs
251251
var help = Help.FindHelpNamed("UnityAccelerator");
252-
Application.OpenURL(help);
252+
Help.BrowseURL(help);
253253
}
254254
GUILayout.EndHorizontal();
255255
EditorGUI.BeginChangeCheck();
@@ -328,7 +328,7 @@ void DoImportWorkerCount()
328328
{
329329
// Known issue with Docs redirect - versioned pages might not open offline docs
330330
var help = Help.FindHelpNamed("ParallelImport");
331-
Application.OpenURL(help);
331+
Help.BrowseURL(help);
332332
}
333333

334334
GUILayout.EndHorizontal();

‎Editor/Mono/PreferencesWindow/PreferencesSettingsProviders.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ private void WritePreferences()
10941094
EditorPrefs.SetBool("GraphSnapping", m_GraphSnapping);
10951095

10961096
EditorPrefs.SetBool("EnableConstrainProportionsTransformScale", m_EnableConstrainProportionsScalingForNewObjects);
1097+
EditorPrefs.SetBool("UseInspectorExpandedState", AnnotationUtility.useInspectorExpandedState);
10971098
}
10981099

10991100
private int CurrentEditorScalingValue
@@ -1184,6 +1185,7 @@ private void ReadPreferences()
11841185
m_GpuDevice = EditorPrefs.GetString("GpuDeviceName");
11851186

11861187
m_EnableConstrainProportionsScalingForNewObjects = EditorPrefs.GetBool("EnableConstrainProportionsTransformScale", false);
1188+
AnnotationUtility.useInspectorExpandedState = EditorPrefs.GetBool("UseInspectorExpandedState", false);
11871189

11881190
if (EditorPrefs.HasKey(kContentScalePrefKey))
11891191
{

‎Editor/Mono/SceneView/SceneView.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3268,7 +3268,8 @@ internal void HandleDragging(Event evt)
32683268
if (DragAndDrop.HasHandler(DragAndDropWindowTarget.sceneView))
32693269
{
32703270
PickObject(ref pickedObject, ref parentTransform);
3271-
DragAndDrop.visualMode = DragAndDrop.Drop(DragAndDropWindowTarget.sceneView, pickedObject, pivot, Event.current.mousePosition, parentTransform, isPerform);
3271+
Vector3 worldPosition = HandleUtility.PlaceObject(Event.current.mousePosition, out Vector3 placedPosition, out _) ? placedPosition : pivot;
3272+
DragAndDrop.visualMode = DragAndDrop.Drop(DragAndDropWindowTarget.sceneView, pickedObject, worldPosition, Event.current.mousePosition, parentTransform, isPerform);
32723273
dropHandled = DragAndDrop.visualMode != DragAndDropVisualMode.None;
32733274
}
32743275

@@ -3287,7 +3288,9 @@ internal void HandleDragging(Event evt)
32873288
{
32883289
if (pickedObject == null || parentTransform == null)
32893290
PickObject(ref pickedObject, ref parentTransform);
3290-
DragAndDrop.visualMode = InternalEditorUtility.SceneViewDrag(pickedObject, pivot, Event.current.mousePosition, parentTransform, isPerform);
3291+
3292+
Vector3 worldPosition = HandleUtility.PlaceObject(Event.current.mousePosition, out Vector3 placedPosition, out _) ? placedPosition : pivot;
3293+
DragAndDrop.visualMode = InternalEditorUtility.SceneViewDrag(pickedObject, worldPosition, Event.current.mousePosition, parentTransform, isPerform);
32913294
}
32923295

32933296
evt.Use();

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL