Skip to content

Commit 8f0f22c

Browse files
author
Unity Technologies
committed
Unity 2020.1.0a20 C# reference source code
1 parent e5f4317 commit 8f0f22c

File tree

102 files changed

+2532
-756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2532
-756
lines changed

Editor/Mono/Animation/AnimatorController.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,29 @@ public void RemoveLayer(int index)
106106
layers = layerVector;
107107
}
108108

109+
internal bool IsStateInLayer(AnimatorState state, int layerIndex)
110+
{
111+
if (layerIndex >= layers.Length)
112+
{
113+
return false;
114+
}
115+
116+
return layers[layerIndex].stateMachine.HasState(state);
117+
}
118+
119+
internal int GetStateLayer(AnimatorState state)
120+
{
121+
for (int i = 0; i < layers.Length; ++i)
122+
{
123+
if (layers[i].stateMachine.HasState(state))
124+
{
125+
return i;
126+
}
127+
}
128+
129+
return -1;
130+
}
131+
109132
public void AddParameter(string name, AnimatorControllerParameterType type)
110133
{
111134
AnimatorControllerParameter newParameter = new AnimatorControllerParameter();

Editor/Mono/BuildPipeline/BuildUtils.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,27 @@ internal static void RunManagedProgram(string exe, string args, string workingDi
7777

7878
internal static void RunNetCoreProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser, Action<ProcessStartInfo> setupStartInfo)
7979
{
80-
var p = new NetCoreProgram(exe, args, setupStartInfo);
80+
Program p;
81+
82+
if (Path.GetExtension(exe).Equals(".dll", StringComparison.OrdinalIgnoreCase))
83+
{
84+
p = new NetCoreProgram(exe, args, setupStartInfo);
85+
}
86+
else
87+
{
88+
var startInfo = new ProcessStartInfo()
89+
{
90+
Arguments = args,
91+
CreateNoWindow = true,
92+
FileName = exe
93+
};
94+
95+
if (setupStartInfo != null)
96+
setupStartInfo(startInfo);
97+
98+
p = new Program(startInfo);
99+
}
100+
81101
RunProgram(p, exe, args, workingDirectory, parser);
82102
}
83103

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,13 @@ private void RunIl2CppWithArguments(List<string> arguments, Action<ProcessStartI
527527
il2cppOutputParser = new Il2CppOutputParser();
528528

529529
if (useNetCore)
530+
{
530531
Runner.RunNetCoreProgram(il2CppPath, args, workingDirectory, il2cppOutputParser, setupStartInfo);
532+
}
531533
else
534+
{
532535
Runner.RunManagedProgram(il2CppPath, args, workingDirectory, il2cppOutputParser, setupStartInfo);
536+
}
533537
}
534538

535539
private string GetIl2CppExe()
@@ -539,7 +543,7 @@ private string GetIl2CppExe()
539543

540544
private string GetIl2CppCoreExe()
541545
{
542-
return IL2CPPUtils.GetIl2CppFolder() + "/build/deploy/netcoreapp2.1/publish/il2cppcore.dll";
546+
return IL2CPPUtils.GetIl2CppFolder() + "/build/deploy/netcoreapp3.0/il2cpp" + (Application.platform == RuntimePlatform.WindowsEditor ? ".exe" : "");
543547
}
544548

545549
private bool ShouldUseIl2CppCore()
@@ -555,25 +559,20 @@ private bool ShouldUseIl2CppCore()
555559
if (disableIl2CppCoreDiag)
556560
return false;
557561

558-
bool shouldUse = false;
559562
if (Application.platform == RuntimePlatform.OSXEditor)
560563
{
561-
// .Net Core 2.1 is only supported on MacOSX versions 10.12 and later
564+
// .Net Core 3.0 is only supported on MacOSX versions 10.13 and later
562565
if (SystemInfo.operatingSystem.StartsWith("Mac OS X 10."))
563566
{
564567
var versionText = SystemInfo.operatingSystem.Substring(9);
565568
var version = new Version(versionText);
566569

567-
if (version >= new Version(10, 12))
568-
shouldUse = true;
569-
}
570-
else
571-
{
572-
shouldUse = true;
570+
if (version >= new Version(10, 13))
571+
return false;
573572
}
574573
}
575574

576-
return shouldUse && NetCoreProgram.IsNetCoreAvailable();
575+
return true;
577576
}
578577
}
579578

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,19 @@ static public string GetPlaybackEngineDownloadURL(string moduleName)
497497
folder = "MacEditorTargetInstaller";
498498
extension = ".pkg";
499499
}
500+
else if (Application.platform == RuntimePlatform.LinuxEditor)
501+
{
502+
if (moduleName == "Android" || moduleName == "Mac" || moduleName == "Windows")
503+
{
504+
folder = "MacEditorTargetInstaller";
505+
extension = ".pkg";
506+
}
507+
else
508+
{
509+
folder = "LinuxEditorTargetInstaller";
510+
extension = ".tar.xz";
511+
}
512+
}
500513

501514
return string.Format("http://{0}.unity3d.com/{1}/{2}/{3}/UnitySetup-{4}-Support-for-Editor-{5}{6}", prefix, suffix, revision, folder, moduleName, shortVersion, extension);
502515
}

Editor/Mono/Camera/SceneStateHash.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ public override bool Equals(object obj)
4848
public override int GetHashCode()
4949
{
5050
var h = new Hash128();
51-
HashUtilities.AppendHash(ref m_SceneObjectsHash, ref h);
52-
HashUtilities.AppendHash(ref m_SkySettingsHash, ref h);
53-
HashUtilities.AppendHash(ref m_AmbientProbeHash, ref h);
51+
unsafe
52+
{
53+
fixed(Hash128* ptr = &m_SceneObjectsHash) h.Append(ptr, (ulong)sizeof(Hash128));
54+
fixed(Hash128* ptr = &m_SkySettingsHash) h.Append(ptr, (ulong)sizeof(Hash128));
55+
fixed(Hash128* ptr = &m_AmbientProbeHash) h.Append(ptr, (ulong)sizeof(Hash128));
56+
}
5457
return h.GetHashCode();
5558
}
5659
}

Editor/Mono/ConsoleWindow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ internal void OnEnable()
300300
if (m_ConsoleAttachToPlayerState == null)
301301
m_ConsoleAttachToPlayerState = new ConsoleAttachToPlayerState(this);
302302

303-
SetFilter(null);
303+
// Update the filter on enable for DomainReload(keep current filter) and window opening(reset filter because m_searchText is null)
304+
SetFilter(LogEntries.GetFilteringText());
304305

305306
titleContent = GetLocalizedTitleContent();
306307
ms_ConsoleWindow = this;

Editor/Mono/EditorGUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,7 @@ static bool HasKeyboardFocus(int controlID)
20892089
// Every EditorWindow has its own keyboardControl state so we also need to
20902090
// check if the current OS view has focus to determine if the control has actual key focus (gets the input)
20912091
// and not just being a focused control in an unfocused window.
2092-
return (GUIUtility.keyboardControl == controlID && GUIView.current.hasFocus);
2092+
return (GUIUtility.keyboardControl == controlID && EditorGUIUtility.HasCurrentWindowKeyFocus());
20932093
}
20942094

20952095
internal static void DoNumberField(RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, bool isDouble, ref double doubleVal, ref long longVal, string formatString, GUIStyle style, bool draggable, double dragSensitivity)
@@ -7800,7 +7800,7 @@ internal static GUIContent[] GetEnumTypeLocalizedGUIContents(Type enumType, Enum
78007800
else
78017801
{
78027802
// Build localized data and add to cache
7803-
using (new Localization.Editor.LocalizationGroup(enumType))
7803+
using (new LocalizationGroup(enumType))
78047804
{
78057805
result = EditorGUIUtility.TrTempContent(enumData.displayNames, enumData.tooltip);
78067806
s_EnumTypeLocalizedGUIContents[enumType] = result;

Editor/Mono/FileUtil.bindings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static void ReplaceDirectory(string src, string dst)
146146
}
147147

148148
// transform path to absolute, resolving mount points
149-
[FreeFunction]
149+
[FreeFunction("PathToAbsolutePathFromScript")]
150150
extern internal static string PathToAbsolutePath(string path);
151151
}
152152
}

Editor/Mono/GradientPreviewCache.bindings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Copyright (c) Unity Technologies. For terms of use, see
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

5-
using System;
65
using UnityEngine;
76
using UnityEngine.Bindings;
87
using UnityEditor;

Editor/Mono/Handles.cs

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Runtime.InteropServices;
77
using UnityEngine;
88
using UnityEngine.Internal;
9+
using UnityEngine.Rendering;
910

1011
namespace UnityEditor
1112
{
@@ -107,7 +108,7 @@ public void Dispose()
107108
}
108109
}
109110

110-
static Mesh cubeMesh
111+
internal static Mesh cubeMesh
111112
{
112113
get
113114
{
@@ -117,7 +118,7 @@ static Mesh cubeMesh
117118
}
118119
}
119120

120-
static Mesh coneMesh
121+
internal static Mesh coneMesh
121122
{
122123
get
123124
{
@@ -127,7 +128,7 @@ static Mesh coneMesh
127128
}
128129
}
129130

130-
static Mesh cylinderMesh
131+
internal static Mesh cylinderMesh
131132
{
132133
get
133134
{
@@ -137,7 +138,7 @@ static Mesh cylinderMesh
137138
}
138139
}
139140

140-
static Mesh sphereMesh
141+
internal static Mesh sphereMesh
141142
{
142143
get
143144
{
@@ -147,6 +148,16 @@ static Mesh sphereMesh
147148
}
148149
}
149150

151+
internal static Mesh quadMesh
152+
{
153+
get
154+
{
155+
if (s_QuadMesh == null)
156+
Init();
157+
return s_QuadMesh;
158+
}
159+
}
160+
150161
internal static int s_xRotateHandleHash = "xRotateHandleHash".GetHashCode();
151162
internal static int s_yRotateHandleHash = "yRotateHandleHash".GetHashCode();
152163
internal static int s_zRotateHandleHash = "zRotateHandleHash".GetHashCode();
@@ -1408,9 +1419,14 @@ public static void DrawCamera(Rect position, Camera camera)
14081419
}
14091420

14101421
public static void DrawCamera(Rect position, Camera camera, [DefaultValue("UnityEditor.DrawCameraMode.Normal")] DrawCameraMode drawMode)
1422+
{
1423+
DrawCamera(position, camera, drawMode, true);
1424+
}
1425+
1426+
public static void DrawCamera(Rect position, Camera camera, [DefaultValue("UnityEditor.DrawCameraMode.Normal")] DrawCameraMode drawMode, bool drawGizmos)
14111427
{
14121428
DrawGridParameters nullGridParam = new DrawGridParameters();
1413-
DrawCameraImpl(position, camera, drawMode, false, nullGridParam, true);
1429+
DrawCameraImpl(position, camera, drawMode, false, nullGridParam, true, drawGizmos);
14141430
}
14151431

14161432
internal enum CameraFilterMode
@@ -1491,5 +1507,41 @@ public static Vector3[] MakeBezierPoints(Vector3 startPosition, Vector3 endPosit
14911507
throw new ArgumentOutOfRangeException("division", "Must be greater than zero");
14921508
return Internal_MakeBezierPoints(startPosition, endPosition, startTangent, endTangent, division);
14931509
}
1510+
1511+
public static void DrawTexture3DSDF(Texture texture,
1512+
[DefaultValue("1.0f")] float stepScale = 1.0f,
1513+
[DefaultValue("0.0f")] float surfaceOffset = 0.0f,
1514+
[DefaultValue("null")] Gradient customColorRamp = null)
1515+
{
1516+
Vector3 localScale = new Vector3(matrix.GetColumn(0).magnitude, matrix.GetColumn(1).magnitude, matrix.GetColumn(2).magnitude);
1517+
Texture3DInspector.PrepareSDFPreview(Texture3DInspector.Materials.SDF, texture, localScale, stepScale, surfaceOffset, customColorRamp);
1518+
Texture3DInspector.Materials.SDF.SetPass(0);
1519+
Graphics.DrawMeshNow(cubeMesh, matrix);
1520+
}
1521+
1522+
public static void DrawTexture3DSlice(Texture texture, Vector3 slicePositions,
1523+
[DefaultValue("FilterMode.Bilinear")] FilterMode filterMode = FilterMode.Bilinear,
1524+
[DefaultValue("false")] bool useColorRamp = false,
1525+
[DefaultValue("null")] Gradient customColorRamp = null)
1526+
{
1527+
Vector3 localScale = new Vector3(matrix.GetColumn(0).magnitude, matrix.GetColumn(1).magnitude, matrix.GetColumn(2).magnitude);
1528+
Texture3DInspector.PrepareSlicePreview(Texture3DInspector.Materials.Slice, texture, slicePositions, filterMode, useColorRamp, customColorRamp);
1529+
Texture3DInspector.Materials.Slice.SetPass(0);
1530+
Graphics.DrawMeshNow(cubeMesh, matrix);
1531+
}
1532+
1533+
public static void DrawTexture3DVolume(Texture texture,
1534+
[DefaultValue("1.0f")] float opacity = 1.0f,
1535+
[DefaultValue("1.0f")] float qualityModifier = 1.0f,
1536+
[DefaultValue("FilterMode.Bilinear")] FilterMode filterMode = FilterMode.Bilinear,
1537+
[DefaultValue("false")] bool useColorRamp = false,
1538+
[DefaultValue("null")] Gradient customColorRamp = null)
1539+
{
1540+
Vector3 localScale = new Vector3(matrix.GetColumn(0).magnitude, matrix.GetColumn(1).magnitude, matrix.GetColumn(2).magnitude);
1541+
int sampleCount = Texture3DInspector.PrepareVolumePreview(Texture3DInspector.Materials.Volume, texture, localScale, opacity,
1542+
filterMode, useColorRamp, customColorRamp, Camera.current, matrix, qualityModifier);
1543+
Texture3DInspector.Materials.Volume.SetPass(0);
1544+
Graphics.DrawProceduralNow(MeshTopology.Quads, 4, sampleCount);
1545+
}
14941546
}
14951547
}

0 commit comments

Comments
 (0)