Skip to content

Commit c5523a8

Browse files
author
Unity Technologies
committed
Unity 2020.1.0a24 C# reference source code
1 parent 27ca1bd commit c5523a8

File tree

94 files changed

+830
-598
lines changed

Some content is hidden

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

94 files changed

+830
-598
lines changed

Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ private static void CreateApplicationData(BuildPostProcessArgs args)
373373

374374
protected bool CopyPlayerFilter(string path, BuildPostProcessArgs args)
375375
{
376+
// Don't copy assemblies that are being overridden by a User assembly.
377+
var fileName = Path.GetFileName(path);
378+
for (int i = 0; i < args.report.files.Length; ++i)
379+
if (Path.GetFileName(args.report.files[i].path) == fileName && args.report.files[i].isOverridingUnityAssembly)
380+
return false;
381+
376382
// Don't copy UnityEngine mdb/pdb files
377383
return (Path.GetExtension(path) != ".mdb" && Path.GetExtension(path) != ".pdb") || !Path.GetFileName(path).StartsWith("UnityEngine.");
378384
}

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Object = UnityEngine.Object;
2020
using TargetAttributes = UnityEditor.BuildTargetDiscovery.TargetAttributes;
2121
using UnityEditor.Connect;
22+
using UnityEditor.Utils;
2223

2324
namespace UnityEditor
2425
{
@@ -110,8 +111,17 @@ static bool BuildLocationIsValid(string path)
110111
static void BuildPlayerAndRun()
111112
{
112113
var buildTarget = EditorUserBuildSettingsUtils.CalculateSelectedBuildTarget();
113-
var buildLocation = EditorUserBuildSettings.GetBuildLocation(buildTarget);
114-
BuildPlayerAndRun(!BuildLocationIsValid(buildLocation));
114+
var lastBuildLocation = EditorUserBuildSettings.GetBuildLocation(buildTarget);
115+
bool buildLocationIsValid = BuildLocationIsValid(lastBuildLocation);
116+
117+
if (buildLocationIsValid && (buildTarget == BuildTarget.StandaloneWindows || buildTarget == BuildTarget.StandaloneWindows64))
118+
{
119+
// Case 1208041: Windows Standalone .exe name depends on productName player setting
120+
var newBuildLocation = Path.Combine(Path.GetDirectoryName(lastBuildLocation), Paths.MakeValidFileName(PlayerSettings.productName) + ".exe").Replace(Path.DirectorySeparatorChar, '/');
121+
EditorUserBuildSettings.SetBuildLocation(buildTarget, newBuildLocation);
122+
}
123+
124+
BuildPlayerAndRun(!buildLocationIsValid);
115125
}
116126

117127
// This overload is used by the default player window, to always prompt for build location

Editor/Mono/Commands/GOCreationCommands.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,7 @@ static void CreateParticleSystem(MenuCommand menuCommand)
247247

248248
go.GetComponent<Transform>().SetLocalEulerAngles(new Vector3(-90, 0, 0), RotationOrder.OrderZXY);
249249
var renderer = go.GetComponent<ParticleSystemRenderer>();
250-
renderer.materials = new Material[]
251-
{
252-
Material.GetDefaultParticleMaterial(),
253-
null
254-
};
250+
renderer.material = Material.GetDefaultParticleMaterial();
255251
Place(go, parent);
256252
}
257253

Editor/Mono/EditorApplication.cs

Lines changed: 54 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public sealed partial class EditorApplication
6969

7070
static void Internal_ProjectWasLoaded()
7171
{
72-
if (projectWasLoaded != null)
73-
projectWasLoaded();
72+
projectWasLoaded?.Invoke();
7473
}
7574

7675
[RequiredByNativeCode]
@@ -115,11 +114,8 @@ static bool Internal_EditorApplicationWantsToQuit()
115114

116115
static void Internal_EditorApplicationQuit()
117116
{
118-
if (quitting != null)
119-
quitting();
120-
121-
if (editorApplicationQuit != null)
122-
editorApplicationQuit();
117+
quitting?.Invoke();
118+
editorApplicationQuit?.Invoke();
123119
}
124120

125121
// Delegate to be called for every visible list item in the ProjectWindow on every OnGUI event.
@@ -154,17 +150,15 @@ public static void RepaintAnimationWindow()
154150
// Can be used to ensure repaint of the HierarchyWindow.
155151
public static void RepaintHierarchyWindow()
156152
{
157-
if (refreshHierarchy != null)
158-
refreshHierarchy();
153+
refreshHierarchy?.Invoke();
159154
}
160155

161156
// Delegate for dirtying hierarchy sorting.
162157
internal static CallbackFunction dirtyHierarchySorting;
163158

164159
public static void DirtyHierarchyWindowSorting()
165160
{
166-
if (dirtyHierarchySorting != null)
167-
dirtyHierarchySorting();
161+
dirtyHierarchySorting?.Invoke();
168162
}
169163

170164
// Delegate to be called from [[EditorApplication]] callbacks.
@@ -182,6 +176,22 @@ public static void DirtyHierarchyWindowSorting()
182176

183177
public static CallbackFunction delayCall;
184178

179+
internal static void CallDelayed(CallbackFunction action, double delaySeconds = 0.0f)
180+
{
181+
var startTime = DateTime.Now;
182+
CallbackFunction delayedHandler = null;
183+
delayedHandler = new CallbackFunction(() =>
184+
{
185+
if ((DateTime.Now - startTime).TotalSeconds < delaySeconds)
186+
return;
187+
update -= delayedHandler;
188+
action();
189+
});
190+
update += delayedHandler;
191+
if (delaySeconds == 0f)
192+
SignalTick();
193+
}
194+
185195
// Each time an object is (or a group of objects are) created, renamed, parented, unparented or destroyed this callback is raised.
186196
public static event Action hierarchyChanged;
187197

@@ -306,40 +316,39 @@ internal static string BuildMainWindowTitle()
306316
static int m_UpdateHash;
307317
static Delegate[] m_UpdateInvocationList;
308318

319+
[RequiredByNativeCode]
309320
static void Internal_CallUpdateFunctions()
310321
{
311-
if (update != null)
322+
if (update == null)
323+
return;
324+
if (Profiler.enabled && !ProfilerDriver.deepProfiling)
312325
{
313-
if (Profiler.enabled && !ProfilerDriver.deepProfiling)
326+
var currentUpdateHash = update.GetHashCode();
327+
if (currentUpdateHash != m_UpdateHash)
314328
{
315-
var currentUpdateHash = update.GetHashCode();
316-
if (currentUpdateHash != m_UpdateHash)
317-
{
318-
m_UpdateInvocationList = update.GetInvocationList();
319-
m_UpdateHash = currentUpdateHash;
320-
}
321-
foreach (var cb in m_UpdateInvocationList)
322-
{
323-
var marker = new ProfilerMarker(cb.Method.Name);
324-
marker.Begin();
325-
cb.DynamicInvoke(null);
326-
marker.End();
327-
}
329+
m_UpdateInvocationList = update.GetInvocationList();
330+
m_UpdateHash = currentUpdateHash;
328331
}
329-
else
332+
foreach (var cb in m_UpdateInvocationList)
330333
{
331-
update.Invoke();
334+
var marker = new ProfilerMarker(cb.Method.Name);
335+
marker.Begin();
336+
cb.DynamicInvoke(null);
337+
marker.End();
332338
}
333339
}
340+
else
341+
{
342+
update.Invoke();
343+
}
334344
}
335345

346+
[RequiredByNativeCode]
336347
static void Internal_CallDelayFunctions()
337348
{
338349
CallbackFunction delay = delayCall;
339350
delayCall = null;
340-
341-
if (delay != null)
342-
delay();
351+
delay?.Invoke();
343352
}
344353

345354
static void Internal_SwitchSkin()
@@ -356,95 +365,62 @@ internal static void RequestRepaintAllViews()
356365
static void Internal_CallHierarchyHasChanged()
357366
{
358367
#pragma warning disable 618
359-
if (hierarchyWindowChanged != null)
360-
hierarchyWindowChanged();
368+
hierarchyWindowChanged?.Invoke();
361369
#pragma warning restore 618
362370

363-
if (hierarchyChanged != null)
364-
hierarchyChanged();
371+
hierarchyChanged?.Invoke();
365372
}
366373

367374
static void Internal_CallProjectHasChanged()
368375
{
369376
#pragma warning disable 618
370-
if (projectWindowChanged != null)
371-
projectWindowChanged();
377+
projectWindowChanged?.Invoke();
372378
#pragma warning restore 618
373379

374-
if (projectChanged != null)
375-
projectChanged();
380+
projectChanged?.Invoke();
376381
}
377382

378383
internal static void Internal_CallSearchHasChanged()
379384
{
380-
if (searchChanged != null)
381-
searchChanged();
385+
searchChanged?.Invoke();
382386
}
383387

384388
internal static void Internal_CallAssetLabelsHaveChanged()
385389
{
386-
if (assetLabelsChanged != null)
387-
assetLabelsChanged();
390+
assetLabelsChanged?.Invoke();
388391
}
389392

390393
internal static void Internal_CallAssetBundleNameChanged()
391394
{
392-
if (assetBundleNameChanged != null)
393-
assetBundleNameChanged();
394-
}
395-
396-
// Single use case for now ONLY!
397-
internal static void CallDelayed(CallbackFunction function, float timeFromNow)
398-
{
399-
delayedCallback = function;
400-
s_DelayedCallbackTime = Time.realtimeSinceStartup + timeFromNow;
401-
update += CheckCallDelayed;
402-
}
403-
404-
static CallbackFunction delayedCallback;
405-
static float s_DelayedCallbackTime = 0.0f;
406-
407-
static void CheckCallDelayed()
408-
{
409-
if (Time.realtimeSinceStartup > s_DelayedCallbackTime)
410-
{
411-
update -= CheckCallDelayed;
412-
delayedCallback();
413-
}
395+
assetBundleNameChanged?.Invoke();
414396
}
415397

416398
static void Internal_PauseStateChanged(PauseState state)
417399
{
418400
#pragma warning disable 618
419-
if (playmodeStateChanged != null)
420-
playmodeStateChanged();
401+
playmodeStateChanged?.Invoke();
421402
#pragma warning restore 618
422403

423-
if (pauseStateChanged != null)
424-
pauseStateChanged(state);
404+
pauseStateChanged?.Invoke(state);
425405
}
426406

427407
static void Internal_PlayModeStateChanged(PlayModeStateChange state)
428408
{
429409
#pragma warning disable 618
430-
if (playmodeStateChanged != null)
431-
playmodeStateChanged();
410+
playmodeStateChanged?.Invoke();
432411
#pragma warning restore 618
433412

434-
if (playModeStateChanged != null)
435-
playModeStateChanged(state);
413+
playModeStateChanged?.Invoke(state);
436414
}
437415

438416
static void Internal_CallKeyboardModifiersChanged()
439417
{
440-
if (modifierKeysChanged != null)
441-
modifierKeysChanged();
418+
modifierKeysChanged?.Invoke();
442419
}
443420

444421
static void Internal_CallWindowsReordered()
445422
{
446-
if (windowsReordered != null)
447-
windowsReordered();
423+
windowsReordered?.Invoke();
448424
}
449425

450426
[RequiredByNativeCode]
@@ -458,8 +434,7 @@ static bool DoPressedKeysTriggerAnyShortcutHandler()
458434
[RequiredByNativeCode]
459435
static void Internal_CallGlobalEventHandler()
460436
{
461-
if (globalEventHandler != null)
462-
globalEventHandler();
437+
globalEventHandler?.Invoke();
463438

464439
// Ensure this is called last in order to make sure no null current events are passed to other handlers
465440
WindowLayout.MaximizeGestureHandler();

Editor/Mono/EditorGUI.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6298,8 +6298,6 @@ internal static void StreamTexture(Texture texture, Material mat, float mipLevel
62986298
{
62996299
VirtualTexturing.System.RequestRegion(mat, stackNameId, new Rect(0, 0, 1, 1), (int)mipLevel, 1);
63006300
}
6301-
6302-
VirtualTexturing.System.Update();
63036301
}
63046302
}
63056303

Editor/Mono/EditorHandles/BoneHandle.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ internal static void DoBoneHandle(Transform target, Dictionary<Transform, bool>
312312
switch (evt.GetTypeForControl(id))
313313
{
314314
case EventType.Layout:
315+
case EventType.MouseMove:
315316
{
316317
// TODO : This is slow and should be revisited prior to exposing bone handles
317318
Vector3[] vertices = BoneRenderer.GetBoneWireVertices(basePoint, endPoint);
@@ -320,10 +321,6 @@ internal static void DoBoneHandle(Transform target, Dictionary<Transform, bool>
320321

321322
break;
322323
}
323-
case EventType.MouseMove:
324-
if (id == HandleUtility.nearestControl)
325-
HandleUtility.Repaint();
326-
break;
327324
case EventType.MouseDown:
328325
{
329326
// am I closest to the thingy?

Editor/Mono/EditorHandles/Disc.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static Quaternion Do(int id, Quaternion rotation, Vector3 position, Vecto
3737
switch (evt.GetTypeForControl(id))
3838
{
3939
case EventType.Layout:
40+
case EventType.MouseMove:
4041
{
4142
float d;
4243
if (cutoffPlane)
@@ -118,11 +119,6 @@ public static Quaternion Do(int id, Quaternion rotation, Vector3 position, Vecto
118119
}
119120
break;
120121

121-
case EventType.MouseMove:
122-
if (id == HandleUtility.nearestControl)
123-
HandleUtility.Repaint();
124-
break;
125-
126122
case EventType.KeyDown:
127123
if (evt.keyCode == KeyCode.Escape && GUIUtility.hotControl == id)
128124
{

Editor/Mono/EditorHandles/FreeMove.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static Vector3 Do(int id, Vector3 position, Quaternion rotation, float si
2929
switch (evt.GetTypeForControl(id))
3030
{
3131
case EventType.Layout:
32+
case EventType.MouseMove:
3233
// We only want the position to be affected by the Handles.matrix.
3334
Handles.matrix = Matrix4x4.identity;
3435
HandleUtility.AddControl(id, HandleUtility.DistanceToCircle(worldPosition, size * 1.2f));
@@ -120,11 +121,6 @@ public static Vector3 Do(int id, Vector3 position, Quaternion rotation, float si
120121
}
121122
break;
122123

123-
case EventType.MouseMove:
124-
if (id == HandleUtility.nearestControl)
125-
HandleUtility.Repaint();
126-
break;
127-
128124
case EventType.Repaint:
129125
Color temp = Color.white;
130126

Editor/Mono/EditorHandles/FreeRotate.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ internal static Quaternion Do(int id, Quaternion rotation, Vector3 position, flo
2626
switch (evt.GetTypeForControl(id))
2727
{
2828
case EventType.Layout:
29+
case EventType.MouseMove:
2930
// We only want the position to be affected by the Handles.matrix.
3031
Handles.matrix = Matrix4x4.identity;
3132
HandleUtility.AddControl(id, HandleUtility.DistanceToCircle(worldPosition, size) + HandleUtility.kPickDistance);
@@ -89,10 +90,6 @@ internal static Quaternion Do(int id, Quaternion rotation, Vector3 position, flo
8990
EditorGUIUtility.SetWantsMouseJumping(0);
9091
}
9192
break;
92-
case EventType.MouseMove:
93-
if (id == HandleUtility.nearestControl)
94-
HandleUtility.Repaint();
95-
break;
9693
case EventType.KeyDown:
9794
if (evt.keyCode == KeyCode.Escape && GUIUtility.hotControl == id)
9895
{

0 commit comments

Comments
 (0)