Skip to content

Commit 9405cad

Browse files
author
Unity Technologies
committed
Unity 2020.1.0a12 C# reference source code
1 parent 4fc5eb0 commit 9405cad

File tree

129 files changed

+3518
-1622
lines changed

Some content is hidden

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

129 files changed

+3518
-1622
lines changed

Editor/Mono/Animation/AnimationUtility.bindings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ internal static void SetObjectReferenceCurveNoSync(AnimationClip clip, EditorCur
209209
Internal_InvokeOnCurveWasModified(clip, binding, keyframes != null ? CurveModifiedType.CurveModified : CurveModifiedType.CurveDeleted);
210210
}
211211

212+
[NativeThrows]
212213
extern private static void Internal_SetObjectReferenceCurve([NotNull] AnimationClip clip, EditorCurveBinding binding, ObjectReferenceKeyframe[] keyframes, bool updateMuscleClip);
213214

214215
extern public static AnimationCurve GetEditorCurve([NotNull] AnimationClip clip, EditorCurveBinding binding);
@@ -225,6 +226,7 @@ internal static void SetEditorCurveNoSync(AnimationClip clip, EditorCurveBinding
225226
Internal_InvokeOnCurveWasModified(clip, binding, curve != null ? CurveModifiedType.CurveModified : CurveModifiedType.CurveDeleted);
226227
}
227228

229+
[NativeThrows]
228230
extern private static void Internal_SetEditorCurve([NotNull] AnimationClip clip, EditorCurveBinding binding, AnimationCurve curve, bool syncEditorCurves);
229231

230232
extern internal static void SyncEditorCurves([NotNull] AnimationClip clip);

Editor/Mono/Animation/AnimationWindow/AnimationWindowUtility.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -826,24 +826,27 @@ public static string GetPropertyGroupName(string propertyName)
826826

827827
public static float GetNextKeyframeTime(AnimationWindowCurve[] curves, float currentTime, float frameRate)
828828
{
829-
float candidate = float.MaxValue;
829+
AnimationKeyTime candidateKeyTime = AnimationKeyTime.Frame(int.MaxValue, frameRate);
830830
AnimationKeyTime time = AnimationKeyTime.Time(currentTime, frameRate);
831831
AnimationKeyTime nextTime = AnimationKeyTime.Frame(time.frame + 1, frameRate);
832-
833832
bool found = false;
834833

835834
foreach (AnimationWindowCurve curve in curves)
836835
{
837836
foreach (AnimationWindowKeyframe keyframe in curve.m_Keyframes)
838837
{
839-
if (keyframe.time < candidate && keyframe.time >= nextTime.time)
838+
AnimationKeyTime keyTime = AnimationKeyTime.Time(keyframe.time, frameRate);
839+
if (keyTime.frame <= candidateKeyTime.frame && keyTime.frame >= nextTime.frame)
840840
{
841-
candidate = keyframe.time;
842-
found = true;
841+
if (keyframe.time <= candidateKeyTime.time)
842+
{
843+
candidateKeyTime = keyTime;
844+
found = true;
845+
}
843846
}
844847
}
845848
}
846-
return found ? candidate : time.time;
849+
return found ? candidateKeyTime.time : time.time;
847850
}
848851

849852
public static float GetPreviousKeyframeTime(AnimationWindowCurve[] curves, float currentTime, float frameRate)

Editor/Mono/Animation/AnimationWindow/CurveEditor.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,16 @@ public CurveWrapper[] animationCurves
240240
for (int i = 0; i < m_AnimationCurves.Length; ++i)
241241
{
242242
m_AnimationCurves[i].listIndex = i;
243-
curveIDToIndexMap.Add(m_AnimationCurves[i].id, i);
243+
244+
if (!curveIDToIndexMap.ContainsKey(m_AnimationCurves[i].id))
245+
{
246+
curveIDToIndexMap.Add(m_AnimationCurves[i].id, i);
247+
}
248+
else
249+
{
250+
var binding = m_AnimationCurves[i].binding;
251+
Debug.LogWarning("Mismatching curve: '" + (string.IsNullOrEmpty(binding.path) ? "" : binding.path + " : ") + binding.propertyName + "'");
252+
}
244253
m_EnableCurveGroups = m_EnableCurveGroups || (m_AnimationCurves[i].groupId != -1);
245254
}
246255
SyncDrawOrder();

Editor/Mono/Animation/GameObjectRecorder.bindings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public struct CurveFilterOptions
1818
public float scaleError;
1919
public float floatError;
2020
public bool keyframeReduction;
21+
public bool unrollRotation;
2122
}
2223

2324
[NativeHeader("Editor/Src/Animation/EditorCurveBinding.bindings.h")]
@@ -28,6 +29,7 @@ public class GameObjectRecorder : Object
2829
{
2930
readonly static CurveFilterOptions k_DefaultCurveFilterOptions = new CurveFilterOptions()
3031
{
32+
unrollRotation = true,
3133
keyframeReduction = true,
3234
positionError = 0.5f,
3335
rotationError = 0.5f,

Editor/Mono/Animation/ZoomableArea.cs

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,20 @@ private Rect shownAreaInsideMarginsInternal
518518
}
519519
}
520520

521+
float GetWidthInsideMargins(float widthWithMargins, bool substractSliderWidth = false)
522+
{
523+
float width = (widthWithMargins < kMinWidth) ? kMinWidth : widthWithMargins;
524+
float widthInsideMargins = width - leftmargin - rightmargin - (substractSliderWidth ? (m_VSlider ? styles.visualSliderWidth : 0) : 0);
525+
return Mathf.Max(widthInsideMargins, kMinWidth);
526+
}
527+
528+
float GetHeightInsideMargins(float heightWithMargins, bool substractSliderHeight = false)
529+
{
530+
float height = (heightWithMargins < kMinHeight) ? kMinHeight : heightWithMargins;
531+
float heightInsideMargins = height - topmargin - bottommargin - (substractSliderHeight ? (m_HSlider ? styles.visualSliderWidth : 0) : 0);
532+
return Mathf.Max(heightInsideMargins, kMinHeight);
533+
}
534+
521535
public virtual Bounds drawingBounds
522536
{
523537
get
@@ -920,45 +934,38 @@ public void EnforceScaleAndRange()
920934
return;
921935

922936
float epsilon = 0.00001f;
937+
float minChange = 0.01f;
923938

924-
if (newArea.width < oldArea.width - epsilon)
925-
{
926-
float xLerp = Mathf.InverseLerp(oldArea.width, newArea.width, rect.width / m_HScaleMax);
927-
newArea = new Rect(
928-
Mathf.Lerp(oldArea.x, newArea.x, xLerp),
929-
newArea.y,
930-
Mathf.Lerp(oldArea.width, newArea.width, xLerp),
931-
newArea.height
932-
);
933-
}
934-
if (newArea.height < oldArea.height - epsilon)
935-
{
936-
float yLerp = Mathf.InverseLerp(oldArea.height, newArea.height, rect.height / m_VScaleMax);
937-
newArea = new Rect(
938-
newArea.x,
939-
Mathf.Lerp(oldArea.y, newArea.y, yLerp),
940-
newArea.width,
941-
Mathf.Lerp(oldArea.height, newArea.height, yLerp)
942-
);
943-
}
944-
if (newArea.width > oldArea.width + epsilon)
939+
if (!Mathf.Approximately(newArea.width, oldArea.width))
945940
{
946-
float xLerp = Mathf.InverseLerp(oldArea.width, newArea.width, constrainedHScaleMin);
941+
float constrainedValue = newArea.width < oldArea.width - epsilon ? rect.width / m_HScaleMax : constrainedHScaleMin;
942+
constrainedValue = GetWidthInsideMargins(constrainedValue, true);
943+
float xLerp = Mathf.InverseLerp(oldArea.width, newArea.width, constrainedValue);
944+
float newWidth = Mathf.Lerp(oldArea.width, newArea.width, xLerp);
945+
float widthChange = Mathf.Abs(newWidth - newArea.width);
947946
newArea = new Rect(
948-
Mathf.Lerp(oldArea.x, newArea.x, xLerp),
947+
// only affect the position if there was any significant change in width (the unit is in pixels so technically anything under 0.05f would already be impossible to see)
948+
// this fixes an issue where if width was only different due to rounding issues, position changes are ignored as xLerp comes back 0 (or very nearly 0)
949+
widthChange > minChange ? Mathf.Lerp(oldArea.x, newArea.x, xLerp) : newArea.x,
949950
newArea.y,
950-
Mathf.Lerp(oldArea.width, newArea.width, xLerp),
951+
newWidth,
951952
newArea.height
952953
);
953954
}
954-
if (newArea.height > oldArea.height + epsilon)
955+
if (!Mathf.Approximately(newArea.height, oldArea.height))
955956
{
956-
float yLerp = Mathf.InverseLerp(oldArea.height, newArea.height, constrainedVScaleMin);
957+
float constrainedValue = newArea.height < oldArea.height - epsilon ? rect.height / m_VScaleMax : constrainedVScaleMin;
958+
constrainedValue = GetHeightInsideMargins(constrainedValue, true);
959+
float yLerp = Mathf.InverseLerp(oldArea.height, newArea.height, constrainedValue);
960+
float newHeight = Mathf.Lerp(oldArea.height, newArea.height, yLerp);
961+
float heightChange = Mathf.Abs(newHeight - newArea.height);
957962
newArea = new Rect(
958963
newArea.x,
959-
Mathf.Lerp(oldArea.y, newArea.y, yLerp),
964+
// only affect the position if there was any significant change in height (the unit is in pixels so technically anything under 0.05f would already be impossible to see)
965+
// this fixes an issue where if height was only different due to rounding issues, position changes are ignored as yLerp comes back 0 (or very nearly 0)
966+
heightChange > minChange ? Mathf.Lerp(oldArea.y, newArea.y, yLerp) : newArea.y,
960967
newArea.width,
961-
Mathf.Lerp(oldArea.height, newArea.height, yLerp)
968+
newHeight
962969
);
963970
}
964971

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,6 @@
109109
[assembly: InternalsVisibleTo("Unity.2D.Tilemap.Editor")]
110110
[assembly: InternalsVisibleTo("Unity.2D.Tilemap.EditorTests")]
111111
[assembly: InternalsVisibleTo("Unity.PackageCleanConsoleTest.Editor")]
112+
[assembly: InternalsVisibleTo("Unity.SceneTemplate.Editor")]
112113

113114
[assembly: AssemblyIsEditorAssembly]

Editor/Mono/AssetDatabase/AssetMoveInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace UnityEditor.Experimental
88
{
9-
internal struct AssetMoveInfo : IEquatable<AssetMoveInfo>
9+
public struct AssetMoveInfo : IEquatable<AssetMoveInfo>
1010
{
1111
public AssetMoveInfo(string sourceAssetPath, string destinationAssetPath)
1212
{

Editor/Mono/AssetDatabase/AssetsModifiedProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace UnityEditor.Experimental
99
{
10-
internal abstract class AssetsModifiedProcessor
10+
public abstract class AssetsModifiedProcessor
1111
{
12-
internal HashSet<string> assetsReportedChanged { get; set; }
12+
public HashSet<string> assetsReportedChanged { get; set; }
1313

1414
protected void ReportAssetChanged(string assetChanged)
1515
{

Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ private static void CreateApplicationData(BuildPostProcessArgs args)
386386

387387
protected bool CopyPlayerFilter(string path, BuildPostProcessArgs args)
388388
{
389-
// Don't copy UnityEngine mdb files
390-
return Path.GetExtension(path) != ".mdb" || !Path.GetFileName(path).StartsWith("UnityEngine.");
389+
// Don't copy UnityEngine mdb/pdb files
390+
return (Path.GetExtension(path) != ".mdb" && Path.GetExtension(path) != ".pdb") || !Path.GetFileName(path).StartsWith("UnityEngine.");
391391
}
392392

393393
private static uint StringToFourCC(string literal)
@@ -409,21 +409,6 @@ protected string GetVariationFolder(BuildPostProcessArgs args) =>
409409

410410
protected static void RecordCommonFiles(BuildPostProcessArgs args, string variationSourceFolder, string monoFolderRoot)
411411
{
412-
// Mark all the managed DLLs in Data/Managed as engine API assemblies
413-
// Data/Managed may already contain managed DLLs in the UnityEngine.*.dll naming scheme from the extensions
414-
// So we find the files in the source Variations directory and mark the corresponding files in the output
415-
var path = Path.Combine(variationSourceFolder, "Data/Managed");
416-
foreach (var file in Directory.GetFiles(path, "*.dll")
417-
.Concat(Directory.GetFiles(path, "*.pdb")))
418-
{
419-
var filename = Path.GetFileName(file);
420-
if (!filename.StartsWith("UnityEngine"))
421-
continue;
422-
423-
var targetFilePath = Path.Combine(args.stagingArea, "Data/Managed/" + filename);
424-
args.report.RecordFileAdded(targetFilePath, CommonRoles.managedEngineApi);
425-
}
426-
427412
// Mark the default resources file
428413
args.report.RecordFileAdded(Path.Combine(args.stagingArea, "Data/Resources/unity default resources"),
429414
CommonRoles.builtInResources);

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ public void RunCompileAndLink()
368368
var compilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
369369
var arguments = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration).ToList();
370370

371+
var additionalArgs = IL2CPPUtils.GetAdditionalArguments();
372+
if (!string.IsNullOrEmpty(additionalArgs))
373+
arguments.Add(additionalArgs);
374+
371375
arguments.Add($"--map-file-parser={CommandLineFormatter.PrepareFileName(GetMapFileParserPath())}");
372376
arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(Path.GetFullPath(GetCppOutputDirectoryInStagingArea()))}");
373377
arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup))));

0 commit comments

Comments
 (0)