Skip to content

Commit ff4741e

Browse files
author
Unity Technologies
committed
Unity 2018.1.3f1 C# reference source code
1 parent 8b716b9 commit ff4741e

10 files changed

Lines changed: 100 additions & 38 deletions

File tree

‎Editor/Mono/EditorGUI.cs‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public sealed partial class EditorGUI
9797
internal const int kInspTitlebarIconWidth = 16;
9898
internal const int kWindowToolbarHeight = 17;
9999
private static string kEnabledPropertyName = "m_Enabled";
100+
private const string k_MultiEditValueString = "<multi>";
100101

101102
private static float[] s_Vector2Floats = {0, 0};
102103
private static int[] s_Vector2Ints = { 0, 0 };
@@ -476,7 +477,10 @@ public string OnGUI(int id, string value, out bool changed)
476477
m_CommitCommandSentOnLostFocus = false;
477478
// Only set changed to true if the value has actually changed. Otherwise EditorGUI.EndChangeCheck will report false positives,
478479
// which could for example cause unwanted undo's to be registered (in the case of e.g. editing terrain resolution, this can cause several seconds of delay)
479-
changed = value != controlThatHadFocusValue;
480+
if (!showMixedValue || controlThatHadFocusValue != k_MultiEditValueString)
481+
changed = value != controlThatHadFocusValue;
482+
else
483+
changed = false;
480484
evt.Use();
481485
messageControl = 0;
482486
return controlThatHadFocusValue;
@@ -665,7 +669,7 @@ internal static string DoTextField(RecycledTextEditor editor, int id, Rect posit
665669

666670
if (showMixedValue)
667671
{
668-
text = string.Empty;
672+
text = k_MultiEditValueString;
669673
}
670674

671675
// If we have keyboard control and our window have focus, we need to sync up the editor.
@@ -1004,7 +1008,10 @@ internal static string DoTextField(RecycledTextEditor editor, int id, Rect posit
10041008
string drawText;
10051009
if (editor.IsEditingControl(id))
10061010
{
1007-
drawText = passwordField ? "".PadRight(editor.text.Length, '*') : editor.text;
1011+
if (showMixedValue && editor.text == k_MultiEditValueString)
1012+
drawText = string.Empty;
1013+
else
1014+
drawText = passwordField ? "".PadRight(editor.text.Length, '*') : editor.text;
10081015
}
10091016
else if (showMixedValue)
10101017
{

‎Editor/Mono/Inspector/CanvasEditor.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ void OnDisable()
124124

125125
private void AllRootCanvases()
126126
{
127+
if (PlayerSettings.virtualRealitySupported && (m_RenderMode.enumValueIndex == (int)RenderMode.ScreenSpaceOverlay))
128+
{
129+
EditorGUILayout.HelpBox("Using a render mode of ScreenSpaceOverlay while VR is enabled is not recommended for an optimal VR experience", MessageType.Warning);
130+
}
131+
127132
EditorGUILayout.PropertyField(m_RenderMode);
128133

129134
m_OverlayMode.target = m_RenderMode.intValue == 0;

‎Editor/Mono/Scripting/ScriptCompilation/CompilationPipeline.cs‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Assembly
4040
public string outputPath { get; private set; }
4141
public string[] sourceFiles { get; private set; }
4242
public string[] defines { get; private set; }
43-
public Assembly[] assemblyReferences { get; private set; }
43+
public Assembly[] assemblyReferences { get; internal set; }
4444
public string[] compiledAssemblyReferences { get; private set; }
4545
public AssemblyFlags flags { get; private set; }
4646
public ScriptCompilerOptions compilerOptions { get; private set; }
@@ -208,11 +208,6 @@ internal static Assembly[] ToAssemblies(ScriptAssembly[] scriptAssemblies)
208208
{
209209
var assemblies = new Assembly[scriptAssemblies.Length];
210210

211-
var scriptAssemblyToAssembly = new Dictionary<ScriptAssembly, Assembly>();
212-
213-
for (int i = 0; i < scriptAssemblies.Length; ++i)
214-
scriptAssemblyToAssembly.Add(scriptAssemblies[i], assemblies[i]);
215-
216211
for (int i = 0; i < scriptAssemblies.Length; ++i)
217212
{
218213
var scriptAssembly = scriptAssemblies[i];
@@ -222,7 +217,6 @@ internal static Assembly[] ToAssemblies(ScriptAssembly[] scriptAssemblies)
222217
var sourceFiles = scriptAssembly.Files;
223218
var defines = scriptAssembly.Defines;
224219
var compiledAssemblyReferences = scriptAssembly.References;
225-
var assemblyReferences = scriptAssembly.ScriptAssemblyReferences.Select(a => scriptAssemblyToAssembly[a]).ToArray();
226220

227221
var flags = AssemblyFlags.None;
228222

@@ -235,12 +229,26 @@ internal static Assembly[] ToAssemblies(ScriptAssembly[] scriptAssemblies)
235229
outputPath,
236230
sourceFiles,
237231
defines,
238-
assemblyReferences,
232+
null,
239233
compiledAssemblyReferences,
240234
flags,
241235
compilerOptions);
242236
}
243237

238+
var scriptAssemblyToAssembly = new Dictionary<ScriptAssembly, Assembly>();
239+
240+
for (int i = 0; i < scriptAssemblies.Length; ++i)
241+
scriptAssemblyToAssembly.Add(scriptAssemblies[i], assemblies[i]);
242+
243+
for (int i = 0; i < scriptAssemblies.Length; ++i)
244+
{
245+
var scriptAssembly = scriptAssemblies[i];
246+
var assemblyReferences = scriptAssembly.ScriptAssemblyReferences.Select(a => scriptAssemblyToAssembly[a]).ToArray();
247+
248+
assemblies[i].assemblyReferences = assemblyReferences;
249+
}
250+
251+
244252
return assemblies;
245253
}
246254

‎Editor/Mono/Scripting/ScriptCompilation/CompilationTask.cs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ public CompilationTask(ScriptAssembly[] scriptAssemblies, string buildOutputDire
4646
this.maxConcurrentCompilers = maxConcurrentCompilers;
4747
}
4848

49-
~CompilationTask()
50-
{
51-
Stop();
52-
}
53-
5449
public bool IsCompiling
5550
{
5651
get { return pendingAssemblies.Count > 0 || compilerTasks.Count > 0; }

‎Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs‎

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,13 @@ void UpdateCustomTargetAssemblies()
397397
}
398398
}
399399

400-
foreach (var reference in assembly.References)
400+
if (assembly.References != null)
401401
{
402-
if (!allCustomScriptAssemblies.Any(a => a.Name == reference))
403-
throw new Compilation.AssemblyDefinitionException(string.Format("Assembly has reference to non-existent assembly '{0}'", reference), assembly.FilePath);
402+
foreach (var reference in assembly.References)
403+
{
404+
if (!allCustomScriptAssemblies.Any(a => a.Name == reference))
405+
throw new Compilation.AssemblyDefinitionException(string.Format("Assembly has reference to non-existent assembly '{0}'", reference), assembly.FilePath);
406+
}
404407
}
405408
}
406409
catch (Exception e)
@@ -414,9 +417,10 @@ void UpdateCustomTargetAssemblies()
414417
ClearCompilationSetupErrorFlags(CompilationSetupErrorFlags.cyclicReferences);
415418
}
416419

417-
public void SetAllCustomScriptAssemblyJsons(string[] paths)
420+
public Exception[] SetAllCustomScriptAssemblyJsons(string[] paths)
418421
{
419422
var assemblies = new List<CustomScriptAssembly>();
423+
var exceptions = new List<Exception>();
420424

421425
ClearCompilationSetupErrorFlags(CompilationSetupErrorFlags.loadError);
422426

@@ -453,20 +457,37 @@ public void SetAllCustomScriptAssemblyJsons(string[] paths)
453457
loadedCustomScriptAssembly.References = new string[0];
454458

455459
if (loadedCustomScriptAssembly.References.Length != loadedCustomScriptAssembly.References.Distinct().Count())
456-
throw new Compilation.AssemblyDefinitionException("Assembly has duplicate references", loadedCustomScriptAssembly.FilePath);
460+
{
461+
var duplicateRefs = loadedCustomScriptAssembly.References.GroupBy(r => r).Where(g => g.Count() > 0).Select(g => g.Key).ToArray();
462+
var duplicateRefsString = string.Join(",", duplicateRefs);
463+
464+
throw new Compilation.AssemblyDefinitionException(string.Format("Assembly has duplicate references: {0}",
465+
duplicateRefsString),
466+
loadedCustomScriptAssembly.FilePath);
467+
}
457468
}
458469
catch (Exception e)
459470
{
460471
SetCompilationSetupErrorFlags(CompilationSetupErrorFlags.loadError);
461-
throw e;
472+
exceptions.Add(e);
462473
}
463474

464-
assemblies.Add(loadedCustomScriptAssembly);
475+
if (loadedCustomScriptAssembly != null && !assemblies.Any(a => a.Name.Equals(loadedCustomScriptAssembly.Name, StringComparison.OrdinalIgnoreCase)))
476+
assemblies.Add(loadedCustomScriptAssembly);
465477
}
466478

467479
customScriptAssemblies = assemblies.ToArray();
468480

469-
UpdateCustomTargetAssemblies();
481+
try
482+
{
483+
UpdateCustomTargetAssemblies();
484+
}
485+
catch (Exception e)
486+
{
487+
exceptions.Add(e);
488+
}
489+
490+
return exceptions.ToArray();
470491
}
471492

472493
public void SetAllPackageAssemblies(PackageAssembly[] packageAssemblies)

‎Editor/Mono/Scripting/ScriptCompilation/EditorCompilationInterface.cs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ static void EmitExceptionAsError(Action action)
7373
}
7474
}
7575

76+
static void EmitExceptionsAsErrors(Exception[] exceptions)
77+
{
78+
if (exceptions == null || exceptions.Length == 0)
79+
return;
80+
81+
foreach (var exception in exceptions)
82+
LogException(exception);
83+
}
84+
7685
static T EmitExceptionAsError<T>(Func<T> func, T returnValue)
7786
{
7887
try
@@ -167,7 +176,7 @@ public static string GetCompileScriptsOutputDirectory()
167176
[RequiredByNativeCode]
168177
public static void SetAllCustomScriptAssemblyJsons(string[] allAssemblyJsons)
169178
{
170-
EmitExceptionAsError(() => Instance.SetAllCustomScriptAssemblyJsons(allAssemblyJsons));
179+
EmitExceptionsAsErrors(Instance.SetAllCustomScriptAssemblyJsons(allAssemblyJsons));
171180
}
172181

173182
[RequiredByNativeCode]

‎Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ private string ProjectHeader(MonoIsland island,
483483

484484
if (PlayerSettingsEditor.IsLatestApiCompatibility(island._api_compatibility_level))
485485
{
486-
targetframeworkversion = "v4.6";
486+
targetframeworkversion = "v4.7.1";
487487
targetLanguageVersion = "6";
488488
}
489489
else if (ScriptEditorUtility.GetScriptEditorFromPreferences() == ScriptEditorUtility.ScriptEditor.Rider)

‎Modules/UnityWebRequest/Public/WebRequestUtils.cs‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,14 +549,14 @@ internal static string MakeUriString(Uri targetUri, string targetUrl, bool prepe
549549
// for file://protocol pass in unescaped string so we can pass it to VFS
550550
if (targetUrl.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
551551
{
552-
if (targetUrl.Contains("%"))
553-
{
554-
var urlBytes = Encoding.UTF8.GetBytes(targetUrl);
555-
var decodedBytes = UnityEngine.WWWTranscoder.URLDecode(urlBytes);
556-
return Encoding.UTF8.GetString(decodedBytes);
557-
}
558-
else
559-
return targetUrl;
552+
if (!targetUri.IsLoopback)
553+
return targetUri.OriginalString;
554+
string path = targetUri.AbsolutePath;
555+
if (path.Contains("%"))
556+
path = URLDecode(path);
557+
if (path.Length > 0 && path[0] != '/')
558+
path = '/' + path;
559+
return "file://" + path;
560560
}
561561

562562
// if URL contains '%', assume it is properly escaped, otherwise '%2f' gets unescaped as '/' (which may not be correct)
@@ -573,12 +573,29 @@ internal static string MakeUriString(Uri targetUri, string targetUrl, bool prepe
573573
{
574574
StringBuilder sb = new StringBuilder(scheme, targetUrl.Length);
575575
sb.Append(':');
576-
sb.Append(targetUri.PathAndQuery); // for these spec URIs path also has the part of URI to right of colon
576+
// for these spec URIs path also has the part of URI to right of colon
577+
// jar:file URIs should be treated like file URIs (unescaped and stripped of query&fragment)
578+
if (scheme == "jar")
579+
{
580+
string path = targetUri.AbsolutePath;
581+
if (path.Contains("%"))
582+
path = URLDecode(path);
583+
sb.Append(path);
584+
return sb.ToString();
585+
}
586+
sb.Append(targetUri.PathAndQuery);
577587
sb.Append(targetUri.Fragment);
578588
return sb.ToString();
579589
}
580590

581591
return targetUri.AbsoluteUri;
582592
}
593+
594+
static string URLDecode(string encoded)
595+
{
596+
var urlBytes = Encoding.UTF8.GetBytes(encoded);
597+
var decodedBytes = UnityEngine.WWWTranscoder.URLDecode(urlBytes);
598+
return Encoding.UTF8.GetString(decodedBytes);
599+
}
583600
}
584601
}

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Unity 2018.1.2f1 C# reference source code
1+
## Unity 2018.1.3f1 C# reference source code
22

33
The C# part of the Unity engine and editor source code.
44
May be used for reference purposes only.

‎artifacts/generated/bindings_old/common/Core/RectTransformBindings.gen.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ public void GetWorldCorners(Vector3[] fourCornersArray)
257257
}
258258

259259
GetLocalCorners(fourCornersArray);
260-
Transform wt = transform;
261260

261+
Matrix4x4 mat = transform.localToWorldMatrix;
262262
for (int i = 0; i < 4; i++)
263-
fourCornersArray[i] = wt.TransformPoint(fourCornersArray[i]);
263+
fourCornersArray[i] = mat.MultiplyPoint(fourCornersArray[i]);
264264
}
265265

266266

0 commit comments

Comments
 (0)