Skip to content

Commit 24b451c

Browse files
author
Unity Technologies
committed
Unity 2018.1.0a1 C# reference source code
1 parent 1cc688b commit 24b451c

File tree

483 files changed

+13756
-9506
lines changed

Some content is hidden

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

483 files changed

+13756
-9506
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public void AcquireTextureFormatValuesAndStrings(BuildTarget buildTarget, out in
3636
formatValues = TextureImportPlatformSettings.kTextureFormatsValueWiiU;
3737
formatStrings = TextureImporterInspector.s_TextureFormatStringsWiiU;
3838
}
39+
else if (buildTarget == BuildTarget.Switch)
40+
{
41+
formatValues = TextureImportPlatformSettings.kTextureFormatsValueSwitch;
42+
formatStrings = TextureImporterInspector.s_TextureFormatStringsSwitch;
43+
}
3944
else
4045
{
4146
formatValues = TextureImportPlatformSettings.kTextureFormatsValueDefault;

Editor/Mono/Animation/AnimationWindow/AnimationWindowControl.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ public void OnDisable()
108108
{
109109
StopPreview();
110110
StopPlayback();
111-
112-
if (AnimationMode.InAnimationMode(GetAnimationModeDriver()))
113-
AnimationMode.StopAnimationMode(GetAnimationModeDriver());
114111
}
115112

116113
public override void OnSelectionChanged()

Editor/Mono/Animation/AnimationWindow/AnimationWindowUtility.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ public static PropertyModification[] SerializedPropertyToPropertyModifications(S
519519
else if (isEnum)
520520
value = singleProperty.enumValueIndex.ToString();
521521
else // if (isBool)
522-
value = singleProperty.boolValue.ToString();
522+
value = singleProperty.boolValue ? "1" : "0";
523523

524524
var modification = new PropertyModification();
525525

@@ -543,7 +543,7 @@ public static PropertyModification[] SerializedPropertyToPropertyModifications(S
543543
else if (isInt)
544544
value = propertyIter.intValue.ToString();
545545
else // if (isBool)
546-
value = propertyIter.boolValue.ToString();
546+
value = propertyIter.boolValue ? "1" : "0";
547547

548548
for (int j = 0; j < targetObjects.Length; ++j)
549549
{

Editor/Mono/Animation/AnimationWindow/CurveEditorWindow.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ enum NormalizationMode
3636
CurveEditor m_CurveEditor;
3737

3838
AnimationCurve m_Curve;
39-
SerializedProperty m_Property;
4039
Color m_Color;
4140

4241
CurvePresetsContentsForPopupWindow m_CurvePresets;
@@ -74,7 +73,6 @@ public static AnimationCurve curve
7473
get { return visible ? CurveEditorWindow.instance.m_Curve : null; }
7574
set
7675
{
77-
CurveEditorWindow.instance.m_Property = null;
7876
if (value == null)
7977
{
8078
CurveEditorWindow.instance.m_Curve = null;
@@ -87,28 +85,6 @@ public static AnimationCurve curve
8785
}
8886
}
8987

90-
public static SerializedProperty property
91-
{
92-
get
93-
{
94-
return visible ? CurveEditorWindow.instance.m_Property : null;
95-
}
96-
set
97-
{
98-
if (value == null)
99-
{
100-
CurveEditorWindow.instance.m_Property = null;
101-
CurveEditorWindow.instance.m_Curve = null;
102-
}
103-
else
104-
{
105-
CurveEditorWindow.instance.m_Property = value.Copy();
106-
CurveEditorWindow.instance.m_Curve = value.hasMultipleDifferentValues ? new AnimationCurve() : value.animationCurveValue;
107-
CurveEditorWindow.instance.RefreshShownCurves();
108-
}
109-
}
110-
}
111-
11288
public static Color color
11389
{
11490
get { return CurveEditorWindow.instance.m_Color; }
@@ -489,7 +465,6 @@ void OnGUI()
489465
m_Curve.postWrapMode = animCurve.postWrapMode;
490466
m_Curve.preWrapMode = animCurve.preWrapMode;
491467
m_CurveEditor.SelectNone();
492-
RefreshShownCurves();
493468
SendEvent("CurveChanged", true);
494469
}
495470
if (Event.current.type == EventType.Repaint)

Editor/Mono/Animation/AnimatorController.cs

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

1010
namespace UnityEditor.Animations
1111
{
12+
[NativeClass(null)]
1213
public sealed partial class AnimatorController : RuntimeAnimatorController
1314
{
1415
internal System.Action OnAnimatorControllerDirty;
@@ -31,6 +32,7 @@ internal string GetDefaultBlendTreeParameter()
3132
return "Blend";
3233
}
3334

35+
[RequiredByNativeCode]
3436
internal static void OnInvalidateAnimatorController(AnimatorController controller)
3537
{
3638
if (controller.OnAnimatorControllerDirty != null)

Editor/Mono/Animation/TickHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public void SetTickModulos(float[] tickModulos)
3030

3131
public void SetTickModulosForFrameRate(float frameRate)
3232
{
33-
if (frameRate != Mathf.Round(frameRate))
33+
// Make frames multiples of 5 and 10, if frameRate is too high (avoid overflow) or not an even number
34+
if (frameRate > int.MaxValue / 2.0f || frameRate != Mathf.Round(frameRate))
3435
{
35-
// If framerate if not even number, just make frames multiples of 5 and 10
3636
SetTickModulos(new float[] {
3737
1f / frameRate, 5f / frameRate, 10f / frameRate, 50f / frameRate,
3838
100f / frameRate, 500f / frameRate, 1000f / frameRate, 5000f / frameRate,

Editor/Mono/Animation/TransitionPreview.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void Set(AnimatorStateTransition transition, AnimatorState srcState, Anim
112112
m_DstState = dstState;
113113
m_TransitionDuration = transition.duration;
114114
m_TransitionOffset = transition.offset;
115-
m_ExitTime = 0.5f;
115+
m_ExitTime = transition.exitTime;
116116
}
117117
else
118118
{
@@ -596,6 +596,7 @@ private void Init(Animator scenePreviewObject, Motion motion)
596596
m_AvatarPreview = new AvatarPreview(scenePreviewObject, motion);
597597
m_AvatarPreview.OnAvatarChangeFunc = OnPreviewAvatarChanged;
598598
m_AvatarPreview.ShowIKOnFeetButton = false;
599+
m_AvatarPreview.ResetPreviewFocus();
599600
}
600601

601602
if (m_Timeline == null)

Editor/Mono/Animation/ZoomableArea.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,6 @@ public void SetTickMarkerRanges()
938938

939939
public void DrawMajorTicks(Rect position, float frameRate)
940940
{
941-
Color backupCol = Handles.color;
942941
GUI.BeginGroup(position);
943942
if (Event.current.type != EventType.Repaint)
944943
{
@@ -947,12 +946,19 @@ public void DrawMajorTicks(Rect position, float frameRate)
947946
}
948947
InitStyles();
949948

949+
HandleUtility.ApplyWireMaterial();
950+
950951
SetTickMarkerRanges();
951952
hTicks.SetTickStrengths(kTickRulerDistMin, kTickRulerDistFull, true);
952953

953954
Color tickColor = styles.timelineTick.normal.textColor;
954955
tickColor.a = 0.1f;
955-
Handles.color = tickColor;
956+
957+
if (Application.platform == RuntimePlatform.WindowsEditor)
958+
GL.Begin(GL.QUADS);
959+
else
960+
GL.Begin(GL.LINES);
961+
956962
// Draw tick markers of various sizes
957963
Rect theShowArea = shownArea;
958964
for (int l = 0; l < hTicks.tickLevels; l++)
@@ -967,12 +973,13 @@ public void DrawMajorTicks(Rect position, float frameRate)
967973
int frame = Mathf.RoundToInt(ticks[i] * frameRate);
968974
float x = FrameToPixel(frame, frameRate, position, theShowArea);
969975
// Draw line
970-
Handles.DrawLine(new Vector3(x, 0, 0), new Vector3(x, position.height, 0));
976+
DrawVerticalLineFast(x, 0.0f, position.height, tickColor);
971977
}
972978
}
973979
}
980+
981+
GL.End();
974982
GUI.EndGroup();
975-
Handles.color = backupCol;
976983
}
977984

978985
public void TimeRuler(Rect position, float frameRate)
@@ -1325,7 +1332,7 @@ public string FormatTime(float time, float frameRate, TimeFormat timeFormat)
13251332

13261333
if (timeFormat == TimeFormat.TimeFrame)
13271334
{
1328-
int frameDigits = ((int)frameRate).ToString().Length;
1335+
int frameDigits = frameRate != 0 ? ((int)frameRate - 1).ToString().Length : 1;
13291336
string sign = string.Empty;
13301337
if (frame < 0)
13311338
{

Editor/Mono/AssemblyHelper.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,11 @@ private static bool IsTypeAUserExtendedScript(AssemblyDefinition assembly, TypeR
259259
return false;
260260
}
261261

262-
public static void ExtractAllClassesThatAreUserExtendedScripts(string path, out string[] classNamesArray, out string[] classNameSpacesArray)
262+
public static void ExtractAllClassesThatAreUserExtendedScripts(string path, out string[] classNamesArray, out string[] classNameSpacesArray, out string[] originalClassNameSpacesArray)
263263
{
264264
List<string> classNames = new List<string>();
265265
List<string> nameSpaces = new List<string>();
266+
List<string> originalNamespaces = new List<string>();
266267
var readerParameters = new ReaderParameters();
267268

268269
// this will resolve any types in assemblies within the same directory as the type's assembly
@@ -295,6 +296,16 @@ public static void ExtractAllClassesThatAreUserExtendedScripts(string path, out
295296
{
296297
classNames.Add(type.Name);
297298
nameSpaces.Add(type.Namespace);
299+
300+
var originalNamespace = string.Empty;
301+
var attribute = type.CustomAttributes.SingleOrDefault(a => a.AttributeType.FullName == typeof(UnityEngine.Scripting.APIUpdating.MovedFromAttribute).FullName);
302+
303+
if (attribute != null)
304+
{
305+
originalNamespace = (string)attribute.ConstructorArguments[0].Value;
306+
}
307+
308+
originalNamespaces.Add(originalNamespace);
298309
}
299310
}
300311
catch (Exception)
@@ -306,6 +317,7 @@ public static void ExtractAllClassesThatAreUserExtendedScripts(string path, out
306317

307318
classNamesArray = classNames.ToArray();
308319
classNameSpacesArray = nameSpaces.ToArray();
320+
originalClassNameSpacesArray = originalNamespaces.ToArray();
309321
}
310322

311323
/// Extract information about all types in the specified assembly, searchDirs might be used to resolve dependencies.

Editor/Mono/AssetPipeline/AssemblyDefinitionImporter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ public sealed partial class AssemblyDefinitionImporter : AssetImporter
1313

1414
public sealed partial class AssemblyDefinitionAsset : TextAsset
1515
{
16+
private AssemblyDefinitionAsset() {}
17+
18+
private AssemblyDefinitionAsset(string text) {}
1619
}
1720
}

0 commit comments

Comments
 (0)