Skip to content

Commit f50ab75

Browse files
author
Unity Technologies
committed
Unity 2019.3.0a10 C# reference source code
1 parent 9034442 commit f50ab75

File tree

593 files changed

+23496
-8900
lines changed

Some content is hidden

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

593 files changed

+23496
-8900
lines changed

Editor/Mono/2D/Common/ScriptBindings/SpriteEditorExtension.bindings.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

55
using UnityEngine;
6-
using UnityEditor;
76
using UnityEngine.Bindings;
87
using UnityEngine.U2D;
98

10-
namespace UnityEditor.Experimental.U2D
9+
namespace UnityEditor.U2D
1110
{
1211
[NativeHeader("Editor/Src/2D/SpriteEditorExtension.h")]
1312
public static class SpriteEditorExtension

Editor/Mono/Animation/AnimationMode.bindings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ internal static void StartAnimationRecording()
181181
[NativeThrows]
182182
extern internal static void RevertPropertyModificationsForObject([NotNull] Object target);
183183

184+
// Returns editor curve bindings for animation clip and animator hierarchy that need to be snapshot for animation mode.
185+
extern internal static EditorCurveBinding[] GetAllBindings([NotNull] GameObject root, [NotNull] AnimationClip clip);
186+
187+
// Returns editor curve bindings for animation clip that need to be snapshot for animation mode.
188+
extern internal static EditorCurveBinding[] GetCurveBindings([NotNull] AnimationClip clip);
189+
190+
// Return editor curve bindings for animator hierarhcy that need to be snapshot for animation mode.
191+
extern internal static EditorCurveBinding[] GetAnimatorBindings([NotNull] GameObject root);
192+
184193
extern private static bool Internal_InAnimationMode(Object driver);
185194

186195
extern private static bool Internal_InAnimationModeNoDriver();

Editor/Mono/Animation/AnimationUtility.bindings.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,13 @@ internal static EditorCurveBinding[] GetAnimatableBindings(ScriptableObject scri
143143
return Internal_GetScriptableObjectAnimatableBindings(scriptableObject);
144144
}
145145

146-
internal static EditorCurveBinding[] GetAdditionalAnimatorBindings(GameObject targetObject)
147-
{
148-
return Internal_GetAdditionalAnimatorBindings(targetObject);
149-
}
150-
151146
internal static EditorCurveBinding[] GetAnimationStreamBindings(GameObject root)
152147
{
153148
return Internal_GetAnimationStreamBindings(root);
154149
}
155150

156151
extern private static EditorCurveBinding[] Internal_GetGameObjectAnimatableBindings([NotNull] GameObject targetObject, [NotNull] GameObject root);
157152
extern private static EditorCurveBinding[] Internal_GetScriptableObjectAnimatableBindings([NotNull] ScriptableObject scriptableObject);
158-
extern private static EditorCurveBinding[] Internal_GetAdditionalAnimatorBindings([NotNull] GameObject targetObject);
159153
extern private static EditorCurveBinding[] Internal_GetAnimationStreamBindings([NotNull] GameObject root);
160154

161155
// Binds the property and returns the type of the bound value (Can be used to display special UI for it and to enforce correct drag and drop)

Editor/Mono/Animation/AnimationWindow/AnimationWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,6 @@ static bool OnOpenAsset(int instanceID, int line)
179179

180180
public bool EditGameObject(GameObject gameObject)
181181
{
182-
if (state.linkedWithSequencer == true)
183-
return false;
184-
185182
return EditGameObjectInternal(gameObject, (IAnimationWindowControl)null);
186183
}
187184

@@ -268,6 +265,9 @@ private bool ShouldUpdateGameObjectSelection(GameObjectSelectionItem selectedIte
268265
if (m_LockTracker.isLocked)
269266
return false;
270267

268+
if (state.linkedWithSequencer)
269+
return false;
270+
271271
// Selected game object with no animation player.
272272
if (selectedItem.rootGameObject == null)
273273
return true;

Editor/Mono/Animation/AnimationWindow/AnimationWindowHierarchyGUI.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,6 @@ private string GetGameObjectName(GameObject rootGameObject, string path)
304304
return splits[splits.Length - 1];
305305
}
306306

307-
private string GetPathWithoutChildmostGameObject(string path)
308-
{
309-
if (string.IsNullOrEmpty(path))
310-
return "";
311-
312-
int lastIndex = path.LastIndexOf('/');
313-
return path.Substring(0, lastIndex + 1);
314-
}
315-
316307
private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row)
317308
{
318309
bool curvesChanged = false;

Editor/Mono/Animation/AnimationWindow/AnimationWindowState.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -900,15 +900,6 @@ public void SelectKey(AnimationWindowKeyframe keyframe)
900900
m_SelectionBoundsCache = null;
901901
}
902902

903-
public void SelectKeysFromDopeline(DopeLine dopeline)
904-
{
905-
if (dopeline == null)
906-
return;
907-
908-
foreach (var key in dopeline.keys)
909-
SelectKey(key);
910-
}
911-
912903
public void UnselectKey(AnimationWindowKeyframe keyframe)
913904
{
914905
int hash = keyframe.GetHash();
@@ -919,15 +910,6 @@ public void UnselectKey(AnimationWindowKeyframe keyframe)
919910
m_SelectionBoundsCache = null;
920911
}
921912

922-
public void UnselectKeysFromDopeline(DopeLine dopeline)
923-
{
924-
if (dopeline == null)
925-
return;
926-
927-
foreach (var key in dopeline.keys)
928-
UnselectKey(key);
929-
}
930-
931913
public void DeleteSelectedKeys()
932914
{
933915
if (selectedKeys.Count == 0)
@@ -1546,18 +1528,6 @@ public HashSet<int> GetAffectedHierarchyIDs(List<AnimationWindowKeyframe> keyfra
15461528
return hierarchyIDs;
15471529
}
15481530

1549-
public List<DopeLine> GetAffectedDopelines(List<AnimationWindowKeyframe> keyframes)
1550-
{
1551-
List<DopeLine> affectedDopelines = new List<DopeLine>();
1552-
1553-
foreach (AnimationWindowCurve curve in GetAffectedCurves(keyframes))
1554-
foreach (DopeLine dopeline in dopelines)
1555-
if (!affectedDopelines.Contains(dopeline) && dopeline.curves.Contains(curve))
1556-
affectedDopelines.Add(dopeline);
1557-
1558-
return affectedDopelines;
1559-
}
1560-
15611531
public List<AnimationWindowCurve> GetAffectedCurves(List<AnimationWindowKeyframe> keyframes)
15621532
{
15631533
List<AnimationWindowCurve> affectedCurves = new List<AnimationWindowCurve>();

Editor/Mono/Animation/AnimationWindow/AnimationWindowStyles.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class AnimationWindowStyles
2222
public static GUIContent addKeyframeContent = EditorGUIUtility.TrIconContent("Animation.AddKeyframe", "Add keyframe.");
2323
public static GUIContent addEventContent = EditorGUIUtility.TrIconContent("Animation.AddEvent", "Add event.");
2424
public static GUIContent filterBySelectionContent = EditorGUIUtility.TrIconContent("Animation.FilterBySelection", "Filter by selection.");
25-
public static GUIContent sequencerLinkContent = EditorGUIUtility.TrIconContent("Animation.SequencerLink", "Animation Window is linked to Sequence Editor. Press to Unlink.");
25+
public static GUIContent sequencerLinkContent = EditorGUIUtility.TrIconContent("Animation.SequencerLink", "Animation Window is linked to Timeline Editor. Press to Unlink.");
2626

2727
public static GUIContent noAnimatableObjectSelectedText = EditorGUIUtility.TrTextContent("No animatable object selected.");
2828
public static GUIContent formatIsMissing = EditorGUIUtility.TrTextContent("To begin animating {0}, create {1}.");

Editor/Mono/Animation/AnimationWindow/CurveEditor.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,21 +1326,6 @@ void DragTangents()
13261326
}
13271327
}
13281328

1329-
struct KeyFrameCopy
1330-
{
1331-
public float time, value, inTangent, outTangent;
1332-
public int idx, selectionIdx;
1333-
public KeyFrameCopy(int idx, int selectionIdx, Keyframe source)
1334-
{
1335-
this.idx = idx;
1336-
this.selectionIdx = selectionIdx;
1337-
time = source.time;
1338-
value = source.value;
1339-
inTangent = source.inTangent;
1340-
outTangent = source.outTangent;
1341-
}
1342-
}
1343-
13441329
internal void DeleteSelectedKeys()
13451330
{
13461331
string undoLabel;
@@ -2882,7 +2867,7 @@ public Vector2 MovePoints()
28822867
}
28832868

28842869
// Curve dragging. Moving keys has highest priority, therefore we check curve/region dragging AFTER key dragging above
2885-
if (settings.allowDraggingCurvesAndRegions && m_DraggingKey == null)
2870+
if (evt.shift && settings.allowDraggingCurvesAndRegions && m_DraggingKey == null)
28862871
{
28872872
// We use the logic as for moving keys when we drag entire curves or regions: We just
28882873
// select all keyFrames in a curve or region before dragging and ensure to hide tangents when drawing.

Editor/Mono/Animation/AnimationWindow/DopeSheetEditor.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,6 @@ private void RectangleToolGUI()
394394
m_RectangleTool.OnGUI();
395395
}
396396

397-
private void DrawGrid(Rect position)
398-
{
399-
TimeRuler(position, state.frameRate, false, true, 0.2f);
400-
}
401-
402397
public void DrawMasterDopelineBackground(Rect position)
403398
{
404399
if (Event.current.type != EventType.Repaint)

Editor/Mono/Animation/AnimationWindow/DopeSheetEditorRectangleTool.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

55
using UnityEngine;
6-
using UnityEditor;
76
using UnityEditorInternal;
8-
using System.Collections;
97
using System.Collections.Generic;
10-
using System.Linq;
118

129
namespace UnityEditor
1310
{
1411
internal class DopeSheetEditorRectangleTool : RectangleTool
1512
{
16-
const float kDefaultFrameRate = 60f;
17-
1813
const int kScaleLeftWidth = 17;
1914
const int kScaleLeftMarginHorizontal = 0;
2015
const float kScaleLeftMarginVertical = 4;
@@ -382,14 +377,6 @@ private void OnScaleTime(float time)
382377
TransformKeys(transform, flipX, false);
383378
}
384379

385-
private void OnScaleValue(float val)
386-
{
387-
Matrix4x4 transform;
388-
bool flipY;
389-
if (CalculateScaleValueMatrix(m_Previous.y, val, m_MouseOffset.y, m_Pivot.y, out transform, out flipY))
390-
TransformKeys(transform, false, flipY);
391-
}
392-
393380
private void OnEndScale()
394381
{
395382
m_State.EndLiveEdit();

Editor/Mono/Animation/AnimationWindow/RotationCurveInterpolation.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ public static State GetCurveState(AnimationClip clip, EditorCurveBinding[] selec
6161
return state;
6262
}
6363

64-
public static int GetCurveIndexFromName(string name)
65-
{
66-
return ExtractComponentCharacter(name) - 'x';
67-
}
68-
6964
public static char ExtractComponentCharacter(string name)
7065
{
7166
return name[name.Length - 1];

Editor/Mono/Animation/GameObjectRecorder.bindings.cs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,30 @@
1111

1212
namespace UnityEditor.Animations
1313
{
14+
public struct CurveFilterOptions
15+
{
16+
public float positionError;
17+
public float rotationError;
18+
public float scaleError;
19+
public float floatError;
20+
public bool keyframeReduction;
21+
}
22+
1423
[NativeHeader("Editor/Src/Animation/EditorCurveBinding.bindings.h")]
1524
[NativeHeader("Editor/Src/Animation/GameObjectRecorder.h")]
1625
[NativeHeader("Modules/Animation/AnimationClip.h")]
1726
[NativeType]
1827
public class GameObjectRecorder : Object
1928
{
29+
readonly static CurveFilterOptions k_DefaultCurveFilterOptions = new CurveFilterOptions()
30+
{
31+
keyframeReduction = true,
32+
positionError = 0.5f,
33+
rotationError = 0.5f,
34+
scaleError = 0.5f,
35+
floatError = 0.5f
36+
};
37+
2038
public GameObjectRecorder(GameObject root)
2139
{
2240
Internal_Create(this, root);
@@ -76,11 +94,36 @@ public void SaveToClip(AnimationClip clip, float fps)
7694
{
7795
if (fps <= Mathf.Epsilon)
7896
throw new ArgumentException("FPS can't be 0.0 or less");
79-
SaveToClipInternal(clip, fps);
97+
98+
if (!isRecording)
99+
throw new InvalidOperationException("Cannot save to clip as there is nothing to save. The method TakeSnapshot() has not been called.");
100+
101+
SaveToClipInternal(clip, fps, k_DefaultCurveFilterOptions);
102+
103+
AnimationUtility.onCurveWasModified?.Invoke(clip, new EditorCurveBinding(), AnimationUtility.CurveModifiedType.ClipModified);
104+
}
105+
106+
public void SaveToClip(AnimationClip clip, float fps, CurveFilterOptions filterOptions)
107+
{
108+
if (fps <= Mathf.Epsilon)
109+
throw new ArgumentException("FPS can't be 0.0 or less");
110+
111+
if (filterOptions.keyframeReduction)
112+
{
113+
if (filterOptions.positionError < 0 || filterOptions.rotationError < 0 || filterOptions.scaleError < 0 || filterOptions.floatError < 0)
114+
throw new ArgumentException("Allowed errors for keyframe reduction cannot be negative.");
115+
}
116+
117+
if (!isRecording)
118+
throw new InvalidOperationException("Cannot save to clip as there is nothing to save. The method TakeSnapshot() has not been called.");
119+
120+
SaveToClipInternal(clip, fps, filterOptions);
121+
122+
AnimationUtility.onCurveWasModified?.Invoke(clip, new EditorCurveBinding(), AnimationUtility.CurveModifiedType.ClipModified);
80123
}
81124

82125
[NativeMethod("SaveToClip")]
83-
extern void SaveToClipInternal(AnimationClip clip, float fps);
126+
extern void SaveToClipInternal(AnimationClip clip, float fps, CurveFilterOptions filterOptions);
84127

85128
extern public void ResetRecording();
86129

Editor/Mono/Animation/TimeArea.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ public void TimeRuler(Rect position, float frameRate)
137137
TimeRuler(position, frameRate, true, false, 1f, TimeFormat.TimeFrame);
138138
}
139139

140-
public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntireHeight, float alpha)
141-
{
142-
TimeRuler(position, frameRate, labels, useEntireHeight, alpha, TimeFormat.TimeFrame);
143-
}
144-
145140
public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntireHeight, float alpha,
146141
TimeFormat timeFormat)
147142
{

Editor/Mono/Annotation/AnnotationUtility.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (c) Unity Technologies. For terms of use, see
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

5+
using System;
56
using System.Runtime.InteropServices;
67
using UnityEngine.Bindings;
78

@@ -53,6 +54,8 @@ internal sealed partial class AnnotationUtility
5354
internal extern static bool use3dGizmos { get; set; }
5455

5556
[StaticAccessor("GetAnnotationManager()", StaticAccessorType.Dot)]
57+
// Thomas Tu: 2019-06-20. Will be marked as Obsolete.
58+
// We need to deal with code dependency in packages first.
5659
internal extern static bool showGrid { get; set; }
5760

5861
[StaticAccessor("GetAnnotationManager()", StaticAccessorType.Dot)]

Editor/Mono/Annotation/AnnotationWindow.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ private enum EnabledState
8080
GUIContent iconSelectContent = EditorGUIUtility.TrTextContent("", "Select Icon");
8181

8282
GUIContent icon3dGizmoContent = EditorGUIUtility.TrTextContent("3D Icons");
83-
GUIContent showGridContent = EditorGUIUtility.TrTextContent("Show Grid");
8483
GUIContent showOutlineContent = EditorGUIUtility.TrTextContent("Selection Outline");
8584
GUIContent showWireframeContent = EditorGUIUtility.TrTextContent("Selection Wire");
8685
private bool m_IsGameView;
@@ -144,7 +143,7 @@ static public void IconChanged()
144143

145144
float GetTopSectionHeight()
146145
{
147-
const int numberOfControls = 4;
146+
const int numberOfControls = 3;
148147
return EditorGUI.kSingleLineHeight * numberOfControls + EditorGUI.kControlVerticalSpacing * numberOfControls;
149148
}
150149

@@ -365,9 +364,6 @@ void DrawTopSection(float topSectionHeight)
365364
using (new EditorGUI.DisabledScope(m_IsGameView))
366365
{
367366
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
368-
AnnotationUtility.showGrid = GUI.Toggle(toggleRect, AnnotationUtility.showGrid, showGridContent);
369-
370-
toggleRect.y += rowHeight;
371367
AnnotationUtility.showSelectionOutline = GUI.Toggle(toggleRect, AnnotationUtility.showSelectionOutline, showOutlineContent);
372368

373369
toggleRect.y += rowHeight;
@@ -714,11 +710,6 @@ public AInfo(bool gizmoEnabled, bool iconEnabled, int flags, int classID, string
714710
public string m_DisplayText;
715711
public int m_Flags;
716712

717-
bool IsBitSet(byte b, int pos)
718-
{
719-
return (b & (1 << pos)) != 0;
720-
}
721-
722713
public bool HasGizmo()
723714
{
724715
return (m_Flags & (int)Flags.kHasGizmo) > 0;

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
[assembly: InternalsVisibleTo("Unity.IntegrationTests.UnityAnalytics")]
2828
[assembly: InternalsVisibleTo("Unity.Timeline.Editor")]
2929
[assembly: InternalsVisibleTo("Unity.PackageManagerUI.Develop.Editor")]
30+
[assembly: InternalsVisibleTo("Unity.DeviceSimulator.Editor")]
3031

3132
[assembly: InternalsVisibleTo("Unity.Timeline.EditorTests")]
3233
[assembly: InternalsVisibleTo("UnityEditor.Graphs")]

0 commit comments

Comments
 (0)