Skip to content

Commit 616cef5

Browse files
author
Unity Technologies
committed
Unity 2019.2.0a8 C# reference source code
1 parent befef62 commit 616cef5

File tree

90 files changed

+1133
-844
lines changed

Some content is hidden

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

90 files changed

+1133
-844
lines changed

Editor/Mono/AssemblyValidation.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ public static bool PluginCompatibleWithEditor(string path)
144144
return pluginImporter.GetCompatibleWithEditor();
145145
}
146146

147+
public static bool ShouldValidateReferences(string path)
148+
{
149+
var pluginImporter = AssetImporter.GetAtPath(path) as PluginImporter;
150+
151+
if (pluginImporter == null)
152+
return true;
153+
154+
return pluginImporter.ValidateReferences;
155+
}
156+
147157
public static void PrintAssemblyDefinitions(AssemblyDefinition[] assemblyDefinitions)
148158
{
149159
foreach (var assemblyDefinition in assemblyDefinitions)
@@ -233,6 +243,13 @@ public static void CheckAssemblyReferences(string[] assemblyPaths,
233243
if (errors[i].HasFlag(ErrorFlags.IncompatibleWithEditor))
234244
continue;
235245

246+
var assemblyPath = assemblyPaths[i];
247+
248+
// Check if "Validate References" option is enabled
249+
// in the PluginImporter
250+
if (!ShouldValidateReferences(assemblyPath))
251+
continue;
252+
236253
ResolveAndSetupReferences(i,
237254
errors,
238255
assemblyDefinitions,
@@ -327,7 +344,7 @@ public static void ResolveAndSetupReferences(int index,
327344
catch (AssemblyResolutionException)
328345
{
329346
errors[index].Add(ErrorFlags.UnresolvableReference,
330-
string.Format("Unable to resolve reference '{0}'. Is the assembly missing or incompatible with the current platform?",
347+
string.Format("Unable to resolve reference '{0}'. Is the assembly missing or incompatible with the current platform?\nReference validation can be disabled in the Plugin Inspector.",
331348
reference.Name));
332349
}
333350
}

Editor/Mono/Audio/Mixer/GUI/AudioMixersTreeView.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ protected override void RenameEnded()
458458
ObjectNames.SetNameSmartWithInstanceID(instanceID, name);
459459
}
460460
}
461+
else if (isCreating)
462+
GetCreateAssetUtility().EndNewAssetCreationCanceled(name);
461463
}
462464

463465
override protected void ClearRenameAndNewItemState()

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,22 @@ internal static string[] GetBuilderDefinedDefines(IIl2CppPlatformProvider il2cpp
218218
return defines.ToArray();
219219
}
220220

221-
internal static string[] GetBuildingIL2CPPArguments(IIl2CppPlatformProvider il2cppPlatformProvider, BuildTargetGroup buildTargetGroup)
221+
internal static string[] GetDebuggerIL2CPPArguments(IIl2CppPlatformProvider il2cppPlatformProvider, BuildTargetGroup buildTargetGroup)
222222
{
223-
// When changing this function, don't forget to change GetBuilderDefinedDefines!
224223
var arguments = new List<string>();
225-
var apiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup);
226224

227225
if (EnableIL2CPPDebugger(il2cppPlatformProvider, buildTargetGroup))
228226
arguments.Add("--enable-debugger");
229227

228+
return arguments.ToArray();
229+
}
230+
231+
internal static string[] GetBuildingIL2CPPArguments(IIl2CppPlatformProvider il2cppPlatformProvider, BuildTargetGroup buildTargetGroup)
232+
{
233+
// When changing this function, don't forget to change GetBuilderDefinedDefines!
234+
var arguments = new List<string>();
235+
var apiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup);
236+
230237
if (BuildPipeline.IsFeatureSupported("ENABLE_SCRIPTING_GC_WBARRIERS", il2cppPlatformProvider.target))
231238
{
232239
var hasGCBarrierValidation = PlayerSettings.gcWBarrierValidation;
@@ -415,6 +422,14 @@ private void ConvertPlayerDlltoCpp(string inputDirectory, string outputDirectory
415422
if (m_BuildForMonoRuntime)
416423
arguments.Add("--mono-runtime");
417424

425+
// Working around gcc bug 41091
426+
if (m_PlatformProvider.target == BuildTarget.StandaloneLinux ||
427+
m_PlatformProvider.target == BuildTarget.StandaloneLinux64 ||
428+
m_PlatformProvider.target == BuildTarget.StandaloneLinuxUniversal)
429+
{
430+
arguments.Add("--disable-aggressive-inlining");
431+
}
432+
418433
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
419434
var apiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup);
420435
arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(apiCompatibilityLevel)));
@@ -428,6 +443,7 @@ private void ConvertPlayerDlltoCpp(string inputDirectory, string outputDirectory
428443
arguments.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration));
429444
}
430445

446+
arguments.AddRange(IL2CPPUtils.GetDebuggerIL2CPPArguments(m_PlatformProvider, buildTargetGroup));
431447
arguments.AddRange(IL2CPPUtils.GetBuildingIL2CPPArguments(m_PlatformProvider, buildTargetGroup));
432448
arguments.Add($"--map-file-parser={CommandLineFormatter.PrepareFileName(GetMapFileParserPath())}");
433449

Editor/Mono/BuildTargetGroup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public enum BuildTargetGroup
1515
// Unknown target.
1616
Unknown = 0,
1717

18-
// Mac/PC standalone target.
18+
// PC, Mac & Linux standalone target.
1919
Standalone = 1,
2020

2121
//*undocumented*

Editor/Mono/EditorApplication.bindings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,7 @@ internal static extern string windowTitle
239239
}
240240

241241
internal static extern void CloseAndRelaunch(string[] arguments);
242+
243+
internal static extern void RequestCloseAndRelaunchWithCurrentArguments();
242244
}
243245
}

Editor/Mono/EditorGUI.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,10 @@ public static void BeginChangeCheck()
353353
public static bool EndChangeCheck()
354354
{
355355
bool changed = GUI.changed;
356-
GUI.changed |= s_ChangedStack.Pop();
356+
if (s_ChangedStack.Count == 0)
357+
Debug.LogError("Change stack is empty, did you call BeginChangeCheck first?");
358+
else
359+
GUI.changed |= s_ChangedStack.Pop();
357360
return changed;
358361
}
359362

Editor/Mono/EditorWindow.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ internal void DrawNotification()
278278
if (Event.current.type != EventType.Repaint)
279279
return;
280280

281-
EditorStyles.notificationText.CalcMinMaxWidth(m_Notification, out m_NotificationSize.y, out m_NotificationSize.x);
282-
m_NotificationSize.y = EditorStyles.notificationText.CalcHeight(m_Notification, m_NotificationSize.x);
281+
m_NotificationSize = EditorStyles.notificationText.CalcSize(m_Notification);
283282

284283
Vector2 warningSize = m_NotificationSize;
285284
float targetWidth = position.width - EditorStyles.notificationText.margin.horizontal;
@@ -290,26 +289,20 @@ internal void DrawNotification()
290289
if (targetWidth < m_NotificationSize.x)
291290
{
292291
float scale = targetWidth / m_NotificationSize.x;
293-
warningSize.x *= scale;
294-
warningSize.y = EditorStyles.notificationText.CalcHeight(m_Notification, warningSize.x);
295292

296293
scaledNotificationText = new GUIStyle(EditorStyles.notificationText);
297294
scaledNotificationText.fontSize = Mathf.FloorToInt(scaledNotificationText.font.fontSize * scale);
295+
296+
warningSize = scaledNotificationText.CalcSize(m_Notification);
298297
}
299298

299+
warningSize.x += 1; //we'll give the text a little room to breathe to avoid word-wrapping issues with drop shadows
300+
300301
if (warningSize.y > targetHeight)
301302
warningSize.y = targetHeight;
302303

303304
Rect r = new Rect((position.width - warningSize.x) * .5f, 20 + (position.height - 20 - warningSize.y) * .7f, warningSize.x, warningSize.y);
304305

305-
// Round notification coordinate & with to integers, so that text
306-
// shadow rendering(which is offset from base text) gets exactly
307-
// the same floating point results for text wrapping. Without this,
308-
// it can lead to tiny differences that make shadow be word - wrapped
309-
// differently from foreground text.
310-
r.x = Mathf.FloorToInt(r.x);
311-
r.width = Mathf.FloorToInt(r.width);
312-
313306
double time = EditorApplication.timeSinceStartup;
314307
if (time > m_FadeoutTime)
315308
GUI.color = new Color(1, 1, 1, 1 - (float)((time - m_FadeoutTime) / kWarningFadeoutTime));

Editor/Mono/GUI/AssetPopupBackend.cs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,34 @@ internal class AssetPopupBackend
3838
AssetPopup<T>(serializedProperty, label, fileExtension, "Default");
3939
}
4040

41-
// private
41+
private class DoCreateNewAsset : ProjectWindowCallback.EndNameEditAction
42+
{
43+
private SerializedProperty m_Property;
44+
45+
public void SetProperty(SerializedProperty property)
46+
{
47+
var so = new SerializedObject(property.serializedObject.targetObject);
48+
m_Property = so.FindProperty(property.propertyPath);
49+
}
50+
51+
public override void Action(int instanceId, string pathName, string resourceFile)
52+
{
53+
var obj = EditorUtility.InstanceIDToObject(instanceId);
54+
AssetDatabase.CreateAsset(obj, AssetDatabase.GenerateUniqueAssetPath(pathName));
55+
ProjectWindowUtil.FrameObjectInProjectWindow(instanceId);
56+
m_Property.objectReferenceValue = obj;
57+
m_Property.serializedObject.ApplyModifiedProperties();
58+
m_Property.serializedObject.Dispose();
59+
m_Property.Dispose();
60+
}
61+
62+
public override void Cancelled(int instanceId, string pathName, string resourceFile)
63+
{
64+
Selection.activeObject = m_Property.serializedObject.targetObject;
65+
m_Property.serializedObject.Dispose();
66+
m_Property.Dispose();
67+
}
68+
}
4269

4370
static void ShowAssetsPopupMenu<T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension, string defaultFieldName) where T : Object, new()
4471
{
@@ -94,9 +121,9 @@ internal class AssetPopupBackend
94121
gm.AddItem(EditorGUIUtility.TrTextContent("Create New..."), false, delegate
95122
{
96123
var newAsset = Activator.CreateInstance<T>();
97-
ProjectWindowUtil.CreateAsset(newAsset, "New " + typeName + "." + fileExtension);
98-
serializedProperty.objectReferenceValue = newAsset;
99-
serializedProperty.m_SerializedObject.ApplyModifiedProperties();
124+
var doCreate = ScriptableObject.CreateInstance<DoCreateNewAsset>();
125+
doCreate.SetProperty(serializedProperty);
126+
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(newAsset.GetInstanceID(), doCreate, "New " + typeName + "." + fileExtension, AssetPreview.GetMiniThumbnail(newAsset), null);
100127
});
101128

102129
gm.DropDown(buttonRect);

Editor/Mono/GUI/CreateAssetUtility.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,13 @@ public void EndNewAssetCreation(string name)
119119
string resourceFile = m_ResourceFile;
120120
Clear(); // Ensure clear if anything goes bad in EndNameEditAction and gui is exited.
121121

122-
ProjectWindowUtil.EndNameEditAction(endAction, instanceID, path, resourceFile);
122+
ProjectWindowUtil.EndNameEditAction(endAction, instanceID, path, resourceFile, true);
123+
}
124+
125+
public void EndNewAssetCreationCanceled(string name)
126+
{
127+
string path = folder + "/" + name + extension;
128+
ProjectWindowUtil.EndNameEditAction(m_EndAction, m_InstanceID, path, m_ResourceFile, false);
123129
}
124130

125131
public bool IsCreatingNewAsset()

Editor/Mono/GUI/FoldoutHeader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static bool BeginFoldoutHeaderGroup(Rect position, bool foldout, GUIConte
4545
// Removing the default margin for inspectors
4646
if (EditorGUIUtility.hierarchyMode)
4747
{
48-
position.xMin -= EditorStyles.inspectorDefaultMargins.padding.left;
48+
position.xMin -= EditorStyles.inspectorDefaultMargins.padding.left - EditorStyles.inspectorDefaultMargins.padding.right;
4949
}
5050

5151
if (style == null)

0 commit comments

Comments
 (0)