Skip to content

Commit fbd4f2b

Browse files
author
Unity Technologies
committed
Unity 2020.1.0a22 C# reference source code
1 parent 9832fc8 commit fbd4f2b

File tree

93 files changed

+1055
-443
lines changed

Some content is hidden

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

93 files changed

+1055
-443
lines changed

Editor/Mono/ActiveEditorTracker.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public override int GetHashCode()
5656
static extern Array Internal_GetActiveEditors(ActiveEditorTracker self);
5757
public Editor[] activeEditors { get { return (Editor[])Internal_GetActiveEditors(this); } }
5858

59+
[FreeFunction]
60+
internal static extern void Internal_GetActiveEditorsNonAlloc(ActiveEditorTracker self, Editor[] editors);
61+
5962
// List<T> version
6063
internal void GetObjectsLockedByThisTracker(List<UnityObject> lockedObjects)
6164
{

Editor/Mono/Animation/AnimationUtility.bindings.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,24 @@ public static void SetObjectReferenceCurve(AnimationClip clip, EditorCurveBindin
203203
Internal_InvokeOnCurveWasModified(clip, binding, keyframes != null ? CurveModifiedType.CurveModified : CurveModifiedType.CurveDeleted);
204204
}
205205

206+
public static void SetObjectReferenceCurves(AnimationClip clip, EditorCurveBinding[] bindings, ObjectReferenceKeyframe[][] keyframes)
207+
{
208+
if (bindings == null)
209+
throw new ArgumentNullException(nameof(bindings), $"{nameof(bindings)} must be non-null");
210+
if (keyframes == null)
211+
throw new ArgumentNullException(nameof(keyframes), $"{nameof(keyframes)} must be non-null");
212+
if (bindings.Length != keyframes.Length)
213+
throw new InvalidOperationException($"{nameof(bindings)} and {nameof(keyframes)} must be of equal length");
214+
215+
int length = bindings.Length;
216+
for (int i = 0; i < length; i++)
217+
{
218+
SetObjectReferenceCurveNoSync(clip, bindings[i], keyframes[i]);
219+
}
220+
SyncEditorCurves(clip);
221+
Internal_InvokeOnCurveWasModified(clip, new EditorCurveBinding(), CurveModifiedType.ClipModified);
222+
}
223+
206224
internal static void SetObjectReferenceCurveNoSync(AnimationClip clip, EditorCurveBinding binding, ObjectReferenceKeyframe[] keyframes)
207225
{
208226
Internal_SetObjectReferenceCurve(clip, binding, keyframes, false);
@@ -220,6 +238,25 @@ public static void SetEditorCurve(AnimationClip clip, EditorCurveBinding binding
220238
Internal_InvokeOnCurveWasModified(clip, binding, curve != null ? CurveModifiedType.CurveModified : CurveModifiedType.CurveDeleted);
221239
}
222240

241+
public static void SetEditorCurves(AnimationClip clip, EditorCurveBinding[] bindings, AnimationCurve[] curves)
242+
{
243+
if (bindings == null)
244+
throw new ArgumentNullException(nameof(bindings), $"{nameof(bindings)} must be non-null");
245+
if (curves == null)
246+
throw new ArgumentNullException(nameof(curves), $"{nameof(curves)} must be non-null");
247+
if (bindings.Length != curves.Length)
248+
throw new InvalidOperationException($"{nameof(bindings)} and {nameof(curves)} must be of equal length");
249+
250+
int length = bindings.Length;
251+
for (int i = 0; i < length; i++)
252+
{
253+
SetEditorCurveNoSync(clip, bindings[i], curves[i]);
254+
}
255+
SyncEditorCurves(clip);
256+
257+
Internal_InvokeOnCurveWasModified(clip, new EditorCurveBinding(), AnimationUtility.CurveModifiedType.ClipModified);
258+
}
259+
223260
internal static void SetEditorCurveNoSync(AnimationClip clip, EditorCurveBinding binding, AnimationCurve curve)
224261
{
225262
Internal_SetEditorCurve(clip, binding, curve, false);

Editor/Mono/Collab/Collab.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ public static extern int GetRevisionsData(
130130
[FreeFunction(HasExplicitThis = true, ThrowsException = true)]
131131
public extern void RevertFile(string path, bool forceOverwrite);
132132

133+
[FreeFunction(HasExplicitThis = true, ThrowsException = true)]
134+
public extern void RevertFiles(ChangeItem[] changeItems, bool forceOverwrite);
135+
133136
[FreeFunction(HasExplicitThis = true, ThrowsException = true)]
134137
public extern void LaunchConflictExternalMerge(string path);
135138

Editor/Mono/Collab/Collab.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace UnityEditor.Collaboration
2121
internal delegate bool ShowToolbarAtPositionDelegate(Rect screenRect);
2222
internal delegate bool IsToolbarVisibleDelegate();
2323
internal delegate void ShowHistoryWindowDelegate();
24+
internal delegate void ShowChangesWindowDelegate();
2425
internal delegate void CloseToolbarDelegate();
2526
internal delegate void ChangesChangedDelegate(Change[] changes, bool isFiltered);
2627
internal delegate void ChangeItemsChangedDelegate(ChangeItem[] changes, bool isFiltered);
@@ -62,8 +63,9 @@ internal partial class Collab
6263
public static IsToolbarVisibleDelegate IsToolbarVisible = null;
6364
public static CloseToolbarDelegate CloseToolbar = null;
6465

65-
// History delegates
66+
// Preferences link delegates
6667
public static ShowHistoryWindowDelegate ShowHistoryWindow = null;
68+
public static ShowChangesWindowDelegate ShowChangesWindow = null;
6769

6870
private static Collab s_Instance;
6971
private static bool s_IsFirstStateChange = true;

Editor/Mono/ContainerWindow.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Runtime.InteropServices;
88
using System.Collections.Generic;
99
using System;
10+
using System.Linq;
1011

1112
namespace UnityEditor
1213
{
@@ -198,8 +199,6 @@ internal void InternalCloseWindow()
198199
Save();
199200
if (m_RootView)
200201
{
201-
if (m_RootView is GUIView)
202-
((GUIView)m_RootView).RemoveFromAuxWindowList();
203202
DestroyImmediate(m_RootView, true);
204203
m_RootView = null;
205204
}
@@ -241,8 +240,14 @@ internal string GetWindowID()
241240
return rootView.GetType().ToString();
242241

243242
if (rootView.children.Length > 0)
244-
return (m_ShowMode == (int)ShowMode.Utility || m_ShowMode == (int)ShowMode.AuxWindow) ? v.actualView.GetType().ToString()
245-
: ((DockArea)rootView.children[0]).m_Panes[0].GetType().ToString();
243+
{
244+
var dockArea = rootView.children.FirstOrDefault(c => c is DockArea) as DockArea;
245+
if (dockArea && dockArea.m_Panes.Count > 0)
246+
{
247+
return (m_ShowMode == (int)ShowMode.Utility || m_ShowMode == (int)ShowMode.AuxWindow) ? v.actualView.GetType().ToString()
248+
: dockArea.m_Panes[0].GetType().ToString();
249+
}
250+
}
246251

247252
return v.actualView.GetType().ToString();
248253
}

Editor/Mono/EditorResources.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,18 @@ internal static void BuildCatalog()
303303
using (new EditorPerformanceTracker(nameof(BuildCatalog)))
304304
{
305305
s_StyleCatalog = new StyleCatalog();
306-
s_RefreshGlobalStyleCatalog = false;
307306

308307
var paths = GetDefaultStyleCatalogPaths();
309308
foreach (var editorUssPath in AssetDatabase.FindAssets("t:StyleSheet").Select(AssetDatabase.GUIDToAssetPath).Where(IsEditorStyleSheet))
310309
paths.Add(editorUssPath);
311310

311+
var forceRebuild = s_RefreshGlobalStyleCatalog;
312+
s_RefreshGlobalStyleCatalog = false;
313+
312314
bool rebuildCatalog = true;
313315
string catalogHash = ComputeCatalogHash(paths);
314316
const string k_GlobalStyleCatalogCacheFilePath = "Library/Style.catalog";
315-
if (File.Exists(k_GlobalStyleCatalogCacheFilePath))
317+
if (!forceRebuild && File.Exists(k_GlobalStyleCatalogCacheFilePath))
316318
{
317319
using (var cacheCatalogStream = new FileStream(k_GlobalStyleCatalogCacheFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
318320
{

Editor/Mono/EditorSettings.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ internal static extern string Internal_ProjectGenerationUserExtensions
214214
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
215215
public static extern bool useLegacyProbeSampleCount { get; set; }
216216

217+
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
218+
public static extern bool disableCookiesInLightmapper { get; set; }
219+
217220
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
218221
public static extern bool enterPlayModeOptionsEnabled { get; set; }
219222

Editor/Mono/EditorUserBuildSettings.bindings.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -591,15 +591,6 @@ public static extern iOSBuildType iOSBuildConfigType
591591
set;
592592
}
593593

594-
// Instead of creating a ROM file, create a buildable Visual Studio 2015 solution.
595-
public static extern bool switchCreateSolutionFile
596-
{
597-
[NativeMethod("GetCreateSolutionFileForSwitch")]
598-
get;
599-
[NativeMethod("SetCreateSolutionFileForSwitch")]
600-
set;
601-
}
602-
603594

604595
// Create a .nsp ROM file out of the loose-files .nspd folder
605596
public static extern bool switchCreateRomFile

Editor/Mono/EnumDataUtility.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,45 @@ internal static EnumData GetCachedEnumData(Type enumType, bool excludeObsolete =
3434
return enumData;
3535
if (!excludeObsolete && s_EnumData.TryGetValue(enumType, out enumData))
3636
return enumData;
37-
enumData = new EnumData {underlyingType = Enum.GetUnderlyingType(enumType)};
37+
enumData = new EnumData { underlyingType = Enum.GetUnderlyingType(enumType) };
3838
enumData.unsigned =
3939
enumData.underlyingType == typeof(byte)
4040
|| enumData.underlyingType == typeof(ushort)
4141
|| enumData.underlyingType == typeof(uint)
4242
|| enumData.underlyingType == typeof(ulong);
43-
var enumFields = enumType.GetFields(BindingFlags.Static | BindingFlags.Public)
44-
.Where(f => CheckObsoleteAddition(f, excludeObsolete))
45-
.OrderBy(f => f.MetadataToken).ToList();
46-
enumData.displayNames = enumFields.Select(f => EnumNameFromEnumField(f)).ToArray();
43+
var enumFields = enumType.GetFields(BindingFlags.Static | BindingFlags.Public);
44+
List<FieldInfo> enumfieldlist = new List<FieldInfo>();
45+
int enumFieldslen = enumFields.Length;
46+
for (int j = 0; j < enumFieldslen; j++)
47+
{
48+
if (CheckObsoleteAddition(enumFields[j], excludeObsolete))
49+
enumfieldlist.Add(enumFields[j]);
50+
}
51+
52+
// For Empty List Scenario
53+
if (!enumfieldlist.Any())
54+
{
55+
string[] defaultstr = { "" };
56+
Enum[] defaultenum = {};
57+
int[] defaultarr = { 0 };
58+
enumData.values = defaultenum;
59+
enumData.flagValues = defaultarr;
60+
enumData.displayNames = defaultstr;
61+
enumData.tooltip = defaultstr;
62+
enumData.flags = true;
63+
enumData.serializable = true;
64+
return enumData;
65+
}
66+
enumfieldlist.OrderBy(f => f.MetadataToken);
67+
enumData.displayNames = enumfieldlist.Select(f => EnumNameFromEnumField(f)).ToArray();
4768
if (enumData.displayNames.Distinct().Count() != enumData.displayNames.Length)
4869
{
4970
Debug.LogWarning(
5071
$"Enum {enumType.Name} has multiple entries with the same display name, this prevents selection in EnumPopup.");
5172
}
5273

53-
enumData.tooltip = enumFields.Select(f => EnumTooltipFromEnumField(f)).ToArray();
54-
enumData.values = enumFields.Select(f => (Enum)f.GetValue(null)).ToArray();
74+
enumData.tooltip = enumfieldlist.Select(f => EnumTooltipFromEnumField(f)).ToArray();
75+
enumData.values = enumfieldlist.Select(f => (Enum)f.GetValue(null)).ToArray();
5576
enumData.flagValues = enumData.unsigned
5677
? enumData.values.Select(v => unchecked((int)Convert.ToUInt64(v))).ToArray()
5778
: enumData.values.Select(v => unchecked((int)Convert.ToInt64(v))).ToArray();

Editor/Mono/GI/LightingSettings.bindings.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ public bool autoGenerate
111111
[NativeName("RealtimeEnvironmentLighting")]
112112
public extern bool realtimeEnvironmentLighting { get; set; }
113113

114-
[NativeName("MixedBakeMode")]
115-
public extern MixedLightingMode mixedBakeMode { get; set; }
116-
117114
[NativeName("AlbedoBoost")]
118115
public extern float albedoBoost { get; set; }
119116

117+
[NativeName("IndirectOutputScale")]
118+
public extern float indirectScale { get; set; }
119+
120120
[NativeName("BakeBackend")]
121121
public extern Lightmapper lightmapper { get; set; }
122122

@@ -156,6 +156,9 @@ public bool autoGenerate
156156
[NativeName("ExtractAO")]
157157
public extern bool extractAO { get; set; }
158158

159+
[NativeName("MixedBakeMode")]
160+
public extern MixedLightingMode mixedBakeMode { get; set; }
161+
159162
[NativeName("LightmapsBakeMode")]
160163
public extern LightmapsMode directionalityMode { get; set; }
161164

0 commit comments

Comments
 (0)