Skip to content

Commit 7a37dcd

Browse files
author
Unity Technologies
committed
Unity 2019.1.0a11 C# reference source code
1 parent 1e41657 commit 7a37dcd

File tree

215 files changed

+11890
-1723
lines changed

Some content is hidden

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

215 files changed

+11890
-1723
lines changed

Editor/Mono/2D/Common/TexturePlatformSettingsController.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using UnityEditor.U2D.Interface;
77
using UnityEngine;
88
using UnityEngine.Assertions;
9+
using TargetAttributes = UnityEditor.BuildTargetDiscovery.TargetAttributes;
910

1011
namespace UnityEditor.U2D.Common
1112
{
@@ -144,11 +145,7 @@ public bool HandlePlatformSettings(BuildTarget buildTarget, List<TextureImporter
144145

145146
if (!mixedFormat && formatHelper.TextureFormatRequireCompressionQualityInput(allFormat))
146147
{
147-
bool showAsEnum =
148-
buildTarget == BuildTarget.iOS ||
149-
buildTarget == BuildTarget.tvOS ||
150-
buildTarget == BuildTarget.Android
151-
;
148+
bool showAsEnum = BuildTargetDiscovery.PlatformHasFlag(buildTarget, TargetAttributes.HasIntegratedGPU);
152149

153150
if (showAsEnum)
154151
{

Editor/Mono/Animation/AnimationWindow/AnimationWindowUtility.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public static void SaveCurve(AnimationClip clip, AnimationWindowCurve curve)
3939

4040
if (animationCurve.keys.Length == 0)
4141
animationCurve = null;
42+
else
43+
AnimationUtility.UpdateTangentsFromMode(animationCurve);
4244

4345
AnimationUtility.SetEditorCurve(clip, curve.binding, animationCurve);
4446
}
@@ -66,6 +68,8 @@ public static void SaveCurves(AnimationClip clip, IEnumerable<AnimationWindowCur
6668

6769
if (animationCurve.keys.Length == 0)
6870
animationCurve = null;
71+
else
72+
AnimationUtility.UpdateTangentsFromMode(animationCurve);
6973

7074
AnimationUtility.SetEditorCurveNoSync(clip, curve.binding, animationCurve);
7175
}

Editor/Mono/Annotation/AnnotationUtility.bindings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal sealed partial class AnnotationUtility
2828
[StaticAccessor("GetAnnotationManager()", StaticAccessorType.Dot)]
2929
extern internal static string GetNameOfCurrentSetup();
3030

31-
extern internal static void SetGizmoEnabled(int classID, string scriptClass, int gizmoEnabled);
31+
extern internal static void SetGizmoEnabled(int classID, string scriptClass, int gizmoEnabled, bool addToMostRecentChanged);
3232

3333
extern internal static void SetIconEnabled(int classID, string scriptClass, int iconEnabled);
3434

Editor/Mono/Annotation/AnnotationWindow.cs

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ internal class AnnotationWindow : EditorWindow
1313
class Styles
1414
{
1515
public GUIStyle toggle = "OL Toggle";
16+
public GUIStyle toggleMixed = "OL ToggleMixed";
1617
public GUIStyle listEvenBg = "ObjectPickerResultsOdd";//"ObjectPickerResultsEven";//
1718
public GUIStyle listOddBg = "ObjectPickerResultsEven";//"ObjectPickerResultsEven";//
1819
public GUIStyle background = "grey_border";
@@ -22,6 +23,8 @@ class Styles
2223
public GUIStyle listHeaderStyle;
2324
public GUIStyle texelWorldSizeStyle;
2425
public GUIStyle columnHeaderStyle;
26+
public const float k_ToggleSize = 17f;
27+
2528
public Styles()
2629
{
2730
listTextStyle = new GUIStyle(EditorStyles.label);
@@ -40,6 +43,15 @@ public Styles()
4043
columnHeaderStyle = EditorStyles.miniLabel;
4144
}
4245
}
46+
47+
private enum EnabledState
48+
{
49+
NotSet = -1,
50+
None = 0,
51+
All = 1,
52+
Mixed = 2
53+
};
54+
4355
const float kWindowWidth = 270;
4456
const float scrollBarWidth = 14;
4557
const float listElementHeight = 18;
@@ -425,7 +437,7 @@ float DrawListSection(float y, string sectionHeader, List<AInfo> listElements, b
425437
if (doDraw)
426438
{
427439
// Header text
428-
DrawListHeader(sectionHeader, new Rect(3, curY, listElementWidth, headerHeight), ref headerDrawn);
440+
DrawListHeader(sectionHeader, listElements, new Rect(3, curY, listElementWidth, headerHeight), ref headerDrawn);
429441
}
430442
curY += headerHeight;
431443

@@ -458,10 +470,55 @@ float DrawListSection(float y, string sectionHeader, List<AInfo> listElements, b
458470
return curY;
459471
}
460472

461-
void DrawListHeader(string header, Rect rect, ref bool headerDrawn)
473+
void DrawListHeader(string header, List<AInfo> elements, Rect rect, ref bool headerDrawn)
462474
{
463475
GUI.Label(rect, GUIContent.Temp(header), m_Styles.listHeaderStyle);
464476

477+
float toggleSize = Styles.k_ToggleSize;
478+
EnabledState enabledState = EnabledState.NotSet;
479+
480+
for (int i = 0; i < elements.Count; i++)
481+
{
482+
var element = elements[i];
483+
484+
if (element.HasGizmo())
485+
{
486+
if (enabledState == EnabledState.NotSet)
487+
{
488+
enabledState = element.m_GizmoEnabled ? EnabledState.All : EnabledState.None;
489+
}
490+
else if ((enabledState == EnabledState.All) != element.m_GizmoEnabled)
491+
{
492+
enabledState = EnabledState.Mixed;
493+
break;
494+
}
495+
}
496+
}
497+
498+
GUIStyle style = m_Styles.toggle;
499+
bool enabled = enabledState > EnabledState.None;
500+
501+
bool setMixed = enabledState == EnabledState.Mixed;
502+
if (setMixed)
503+
style = m_Styles.toggleMixed;
504+
505+
Rect toggleRect = new Rect(rect.width - gizmoRightAlign - 2, rect.y + (rect.height - toggleSize) * 0.5f, toggleSize, toggleSize);
506+
507+
bool newEnabled = GUI.Toggle(toggleRect, enabled, GUIContent.none, style);
508+
509+
if (newEnabled != enabled)
510+
{
511+
for (int i = 0; i < elements.Count; i++)
512+
{
513+
var element = elements[i];
514+
515+
if (element.m_GizmoEnabled != newEnabled)
516+
{
517+
element.m_GizmoEnabled = newEnabled;
518+
SetGizmoState(element, false);
519+
}
520+
}
521+
}
465522

466523
if (headerDrawn == false)
467524
{
@@ -490,7 +547,7 @@ void DrawListElement(Rect rect, bool even, AInfo ainfo)
490547
}
491548

492549
string tooltip;
493-
float togglerSize = 17;
550+
float togglerSize = Styles.k_ToggleSize;
494551
float disabledAlpha = 0.3f;
495552

496553
// We maintain our own gui.changed
@@ -612,9 +669,9 @@ void SetIconState(AInfo ainfo)
612669
SceneView.RepaintAll();
613670
}
614671

615-
void SetGizmoState(AInfo ainfo)
672+
void SetGizmoState(AInfo ainfo, bool addToMostRecentChanged = true)
616673
{
617-
AnnotationUtility.SetGizmoEnabled(ainfo.m_ClassID, ainfo.m_ScriptClass, ainfo.m_GizmoEnabled ? 1 : 0);
674+
AnnotationUtility.SetGizmoEnabled(ainfo.m_ClassID, ainfo.m_ScriptClass, ainfo.m_GizmoEnabled ? 1 : 0, addToMostRecentChanged);
618675
SceneView.RepaintAll();
619676
}
620677
}

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@
2424
[assembly: InternalsVisibleTo("Unity.IntegrationTests")]
2525
[assembly: InternalsVisibleTo("Unity.DeploymentTests.Services")]
2626
[assembly: InternalsVisibleTo("Unity.IntegrationTests.UnityAnalytics")]
27+
[assembly: InternalsVisibleTo("Unity.Timeline.Editor")]
28+
29+
[assembly: InternalsVisibleTo("Unity.Timeline.EditorTests")]
2730
[assembly: InternalsVisibleTo("UnityEditor.Graphs")]
28-
[assembly: InternalsVisibleTo("UnityEditor.WSA.Extensions")]
31+
[assembly: InternalsVisibleTo("UnityEditor.UWP.Extensions")]
2932
[assembly: InternalsVisibleTo("UnityEditor.iOS.Extensions.Common")]
3033
[assembly: InternalsVisibleTo("UnityEditor.iOS.Extensions")]
3134
[assembly: InternalsVisibleTo("UnityEditor.AppleTV.Extensions")]
@@ -48,8 +51,6 @@
4851
[assembly: InternalsVisibleTo("UnityEditor.EditorTestsRunner")]
4952
[assembly: InternalsVisibleTo("UnityEditor.TestRunner")]
5053
[assembly: InternalsVisibleTo("UnityEngine.TestRunner")]
51-
[assembly: InternalsVisibleTo("UnityEditor.Timeline")]
52-
[assembly: InternalsVisibleTo("Unity.Timeline.EditorTests")]
5354
[assembly: InternalsVisibleTo("UnityEditor.VR")]
5455
[assembly: InternalsVisibleTo("Unity.RuntimeTests")]
5556
[assembly: InternalsVisibleTo("Unity.RuntimeTests.Framework")]

Editor/Mono/BuildPipeline.bindings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ internal static string GetBuildTargetGroupName(BuildTarget target)
537537
internal static extern string GetBuildTargetGroupName(BuildTargetGroup buildTargetGroup);
538538

539539
[FreeFunction]
540-
internal static extern bool IsUnityScriptEvalSupported(BuildTarget target);
540+
internal static extern bool SupportsReflectionEmit(BuildTarget target);
541541

542542
internal static string[] GetReferencingPlayerAssembliesForDLL(string dllPath)
543543
{

Editor/Mono/BuildPipeline/AssemblyStripper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ private static bool StripAssembliesTo(string[] assemblies, string[] searchDirs,
7171

7272
var args = new List<string>
7373
{
74-
"-out=\"" + outputFolder + "\"",
75-
"-x=\"" + GetModuleWhitelist("Core", platformProvider.moduleStrippingInformationFolder) + "\"",
74+
$"-out={CommandLineFormatter.PrepareFileName(outputFolder)}",
75+
$"-x={CommandLineFormatter.PrepareFileName(GetModuleWhitelist("Core", platformProvider.moduleStrippingInformationFolder))}",
7676
};
77-
args.AddRange(additionalBlacklist.Select(path => "-x \"" + path + "\""));
77+
args.AddRange(additionalBlacklist.Select(path => $"-x={CommandLineFormatter.PrepareFileName(path)}"));
7878

79-
args.AddRange(searchDirs.Select(d => "-d \"" + d + "\""));
80-
args.AddRange(assemblies.Select(assembly => "--include-unity-root-assembly=\"" + Path.GetFullPath(assembly) + "\""));
79+
args.AddRange(searchDirs.Select(d => $"-d={CommandLineFormatter.PrepareFileName(d)}"));
80+
args.AddRange(assemblies.Select(assembly => $"--include-unity-root-assembly={CommandLineFormatter.PrepareFileName(Path.GetFullPath(assembly))}"));
8181
args.Add($"--dotnetruntime={GetRuntimeArgumentValueForLinker(buildTargetGroup)}");
8282
args.Add($"--dotnetprofile={GetProfileArgumentValueForLinker(buildTargetGroup)}");
8383
args.Add("--use-editor-options");
@@ -136,7 +136,7 @@ private static bool StripAssembliesTo(string[] assemblies, string[] searchDirs,
136136

137137
var modulesAssetPath = Path.Combine(platformProvider.moduleStrippingInformationFolder, "../modules.asset");
138138
if (File.Exists(modulesAssetPath))
139-
args.Add($"--engine-modules-asset-file=\"{modulesAssetPath}\"");
139+
args.Add($"--engine-modules-asset-file={CommandLineFormatter.PrepareFileName(modulesAssetPath)}");
140140
}
141141

142142
var additionalArgs = System.Environment.GetEnvironmentVariable("UNITYLINKER_ADDITIONAL_ARGS");

Editor/Mono/BuildPipeline/BuildPlatform.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ internal BuildPlatforms()
7373
{
7474
if (!target.HasFlag(TargetAttributes.IsStandalonePlatform))
7575
{
76-
BuildTargetGroup btg = BuildPipeline.GetBuildTargetGroup(target.buildTgtPlatformVal);
76+
BuildTargetGroup btg = BuildPipeline.GetBuildTargetGroup(target.buildTargetPlatformVal);
7777
buildPlatformsList.Add(new BuildPlatform(
7878
BuildPipeline.GetBuildTargetGroupDisplayName(btg),
7979
target.iconName,
8080
btg,
81-
target.buildTgtPlatformVal,
81+
target.buildTargetPlatformVal,
8282
!target.HasFlag(TargetAttributes.HideInUI)));
8383
}
8484
}

Editor/Mono/BuildPipeline/DesktopStandaloneBuildWindowExtension.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ private void SetupStandaloneSubtargets()
3232
List<BuildTarget> standaloneSubtargetsList = new List<BuildTarget>();
3333
List<GUIContent> standaloneSubtargetStringsList = new List<GUIContent>();
3434

35-
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneWindows)))
35+
if (ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneWindows))
3636
{
3737
standaloneSubtargetsList.Add(BuildTarget.StandaloneWindows);
3838
standaloneSubtargetStringsList.Add(EditorGUIUtility.TrTextContent("Windows"));
3939
}
40-
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneOSX)))
40+
if (ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneOSX))
4141
{
4242
standaloneSubtargetsList.Add(BuildTarget.StandaloneOSX);
4343
standaloneSubtargetStringsList.Add(EditorGUIUtility.TrTextContent("Mac OS X"));
4444
}
45-
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneLinux)))
45+
if (ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneLinux))
4646
{
4747
standaloneSubtargetsList.Add(BuildTarget.StandaloneLinux);
4848
standaloneSubtargetStringsList.Add(EditorGUIUtility.TrTextContent("Linux"));
@@ -54,15 +54,15 @@ private void SetupStandaloneSubtargets()
5454

5555
internal static BuildTarget GetBestStandaloneTarget(BuildTarget selectedTarget)
5656
{
57-
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(selectedTarget)))
57+
if (ModuleManager.IsPlatformSupportLoadedByBuildTarget(selectedTarget))
5858
return selectedTarget;
59-
if (RuntimePlatform.WindowsEditor == Application.platform && ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneWindows)))
59+
if (RuntimePlatform.WindowsEditor == Application.platform && ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneWindows))
6060
return BuildTarget.StandaloneWindows;
61-
if (RuntimePlatform.OSXEditor == Application.platform && ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneOSX)))
61+
if (RuntimePlatform.OSXEditor == Application.platform && ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneOSX))
6262
return BuildTarget.StandaloneOSX;
63-
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneOSX)))
63+
if (ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneOSX))
6464
return BuildTarget.StandaloneOSX;
65-
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneLinux)))
65+
if (ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneLinux))
6666
return BuildTarget.StandaloneLinux;
6767
return BuildTarget.StandaloneWindows;
6868
}

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ public void RunCompileAndLink()
356356
var compilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
357357
var arguments = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration).ToList();
358358

359-
arguments.Add(string.Format("--map-file-parser=\"{0}\"", GetMapFileParserPath()));
360-
arguments.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(GetCppOutputDirectoryInStagingArea())));
359+
arguments.Add($"--map-file-parser={CommandLineFormatter.PrepareFileName(GetMapFileParserPath())}");
360+
arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(Path.GetFullPath(GetCppOutputDirectoryInStagingArea()))}");
361361
arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup))));
362362
Action<ProcessStartInfo> setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo;
363363
var managedDir = Path.GetFullPath(Path.Combine(m_StagingAreaData, "Managed"));
@@ -427,15 +427,15 @@ private void ConvertPlayerDlltoCpp(string inputDirectory, string outputDirectory
427427
}
428428

429429
arguments.AddRange(IL2CPPUtils.GetBuildingIL2CPPArguments(m_PlatformProvider, buildTargetGroup));
430-
arguments.Add(string.Format("--map-file-parser=\"{0}\"", GetMapFileParserPath()));
430+
arguments.Add($"--map-file-parser={CommandLineFormatter.PrepareFileName(GetMapFileParserPath())}");
431431

432432
var additionalArgs = IL2CPPUtils.GetAdditionalArguments();
433433
if (!string.IsNullOrEmpty(additionalArgs))
434434
arguments.Add(additionalArgs);
435435

436-
arguments.Add("--directory=\"" + Path.GetFullPath(inputDirectory) + "\"");
436+
arguments.Add($"--directory={CommandLineFormatter.PrepareFileName(Path.GetFullPath(inputDirectory))}");
437437

438-
arguments.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(outputDirectory)));
438+
arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(Path.GetFullPath(outputDirectory))}");
439439

440440
// NOTE: any arguments added here that affect how generated code is built need
441441
// to also be added to PlatformDependent\Win\Extensions\Managed\VisualStudioProjectHelpers.cs
@@ -465,7 +465,7 @@ private void ConvertPlayerDlltoCpp(string inputDirectory, string outputDirectory
465465

466466
var tempFile = Path.GetFullPath(Path.Combine(m_TempFolder, "extra-types.txt"));
467467
File.WriteAllLines(tempFile, extraTypes.ToArray());
468-
arguments.Add(string.Format("--extra-types-file=\"{0}\"", tempFile));
468+
arguments.Add($"--extra-types-file={CommandLineFormatter.PrepareFileName(tempFile)}");
469469
}
470470

471471
RunIl2CppWithArguments(arguments, setupStartInfo, workingDirectory);

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ static void RepairSelectedBuildTargetGroup()
387387

388388
static bool IsAnyStandaloneModuleLoaded()
389389
{
390-
return ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneLinux)) ||
391-
ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneOSX)) ||
392-
ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneWindows));
390+
return ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneLinux) ||
391+
ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneOSX) ||
392+
ModuleManager.IsPlatformSupportLoadedByBuildTarget(BuildTarget.StandaloneWindows);
393393
}
394394

395395
static bool IsColorSpaceValid(BuildPlatform platform)

0 commit comments

Comments
 (0)