Skip to content

Commit a1977c9

Browse files
author
Unity Technologies
committed
Unity 2018.3.0a5 C# reference source code
1 parent 0f8d03f commit a1977c9

387 files changed

Lines changed: 19664 additions & 6901 deletions

File tree

Some content is hidden

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

Editor/Mono/2D/SpriteAtlas/SpriteAtlasInspector.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ public override void OnInspectorGUI()
264264
{
265265
s_Styles = s_Styles ?? new Styles();
266266

267+
// Ensure changes done through script are reflected immediately in Inspector by Syncing m_TempPlatformSettings with Actual Settings.
268+
SyncPlatformSettings();
269+
267270
serializedObject.Update();
268271

269272
HandleCommonSettingUI();

Editor/Mono/Animation/AnimationMode.bindings.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,25 +138,31 @@ internal static void StartAnimationRecording()
138138
extern public static void EndSampling();
139139

140140
[NativeThrows]
141-
extern public static void SampleAnimationClip(GameObject gameObject, AnimationClip clip, float time);
141+
extern public static void SampleAnimationClip([NotNull] GameObject gameObject, [NotNull] AnimationClip clip, float time);
142142

143143
[NativeThrows]
144-
extern internal static void SampleCandidateClip(GameObject gameObject, AnimationClip clip, float time);
144+
extern internal static void SampleCandidateClip([NotNull] GameObject gameObject, [NotNull] AnimationClip clip, float time);
145145

146146
[NativeThrows]
147147
extern public static void AddPropertyModification(EditorCurveBinding binding, PropertyModification modification, bool keepPrefabOverride);
148148

149149
[NativeThrows]
150-
extern internal static void InitializePropertyModificationForGameObject(GameObject gameObject, AnimationClip clip);
150+
extern internal static void AddTransformTR([NotNull] GameObject root, string path);
151151

152152
[NativeThrows]
153-
extern internal static void InitializePropertyModificationForObject(Object target, AnimationClip clip);
153+
extern internal static void AddTransformTRS([NotNull] GameObject root, string path);
154154

155155
[NativeThrows]
156-
extern internal static void RevertPropertyModificationsForGameObject(GameObject gameObject);
156+
extern internal static void InitializePropertyModificationForGameObject([NotNull] GameObject gameObject, [NotNull] AnimationClip clip);
157157

158158
[NativeThrows]
159-
extern internal static void RevertPropertyModificationsForObject(Object target);
159+
extern internal static void InitializePropertyModificationForObject([NotNull] Object target, [NotNull] AnimationClip clip);
160+
161+
[NativeThrows]
162+
extern internal static void RevertPropertyModificationsForGameObject([NotNull] GameObject gameObject);
163+
164+
[NativeThrows]
165+
extern internal static void RevertPropertyModificationsForObject([NotNull] Object target);
160166

161167
extern private static bool Internal_InAnimationMode(Object driver);
162168

Editor/Mono/Animation/AnimationUtility.bindings.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static AnimationClip[] GetAnimationClips(GameObject gameObject)
115115
var allClips = new List<AnimationClip>(clips);
116116
for (int i = 0; i < clipSources.Length; ++i)
117117
{
118-
var extraClips = new List<AnimationClip>(clips);
118+
var extraClips = new List<AnimationClip>();
119119
clipSources[i].GetAnimationClips(extraClips);
120120

121121
allClips.AddRange(extraClips);
@@ -354,11 +354,27 @@ public static AnimationCurve GetEditorCurve(AnimationClip clip, string relativeP
354354

355355
extern internal static AnimationClipStats GetAnimationClipStats(AnimationClip clip);
356356

357-
extern public static bool GetGenerateMotionCurves(AnimationClip clip);
358-
extern public static void SetGenerateMotionCurves(AnimationClip clip, bool value);
357+
[Obsolete("This is not used anymore. Root motion curves are automatically generated if applyRootMotion is enabled on Animator component.")]
358+
public static bool GetGenerateMotionCurves(AnimationClip clip)
359+
{
360+
return true;
361+
}
362+
363+
[Obsolete("This is not used anymore. Root motion curves are automatically generated if applyRootMotion is enabled on Animator component.")]
364+
public static void SetGenerateMotionCurves(AnimationClip clip, bool value)
365+
{
366+
}
367+
368+
[Obsolete("Use AnimationClip.hasGenericRootTransform instead.")]
359369
extern internal static bool HasGenericRootTransform(AnimationClip clip);
370+
371+
[Obsolete("Use AnimationClip.hasMotionFloatCurves instead.")]
360372
extern internal static bool HasMotionFloatCurves(AnimationClip clip);
373+
374+
[Obsolete("Use AnimationClip.hasMotionCurves instead.")]
361375
extern internal static bool HasMotionCurves(AnimationClip clip);
376+
377+
[Obsolete("Use AnimationClip.hasRootCurves instead.")]
362378
extern internal static bool HasRootCurves(AnimationClip clip);
363379

364380
extern internal static bool AmbiguousBinding(string path, int classID, Transform root);

Editor/Mono/Animation/AnimationWindow/AddCurvesPopup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal class AddCurvesPopup : EditorWindow
2929
void Init(Rect buttonRect)
3030
{
3131
buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
32-
ShowAsDropDown(buttonRect, windowSize, new[] { PopupLocationHelper.PopupLocation.Right });
32+
ShowAsDropDown(buttonRect, windowSize, new[] { PopupLocation.Right });
3333
}
3434

3535
void OnEnable()

Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -353,25 +353,35 @@ static private void CollectVector3Modifications(IAnimationRecordingState state,
353353
}
354354
}
355355

356-
static private void ProcessVector3Modification(IAnimationRecordingState state, EditorCurveBinding baseBinding, UndoPropertyModification modification, Transform target, string axis)
356+
static private void ProcessVector3Modification(IAnimationRecordingState state, EditorCurveBinding baseBinding, UndoPropertyModification modification, Transform target, string axis, float scale = 1.0f)
357357
{
358358
var binding = baseBinding;
359-
var property = modification.previousValue;
360-
361359
binding.propertyName = binding.propertyName.Remove(binding.propertyName.Length - 1, 1) + axis;
362360

363-
if (property == null)
361+
object currentValue = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, binding);
362+
363+
var previousModification = modification.previousValue;
364+
if (previousModification == null)
364365
{
365366
// create dummy
366-
property = new PropertyModification();
367-
property.target = target;
368-
property.propertyPath = binding.propertyName;
369-
object currentValue = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, binding);
370-
property.value = ((float)currentValue).ToString();
367+
previousModification = new PropertyModification();
368+
previousModification.target = target;
369+
previousModification.propertyPath = binding.propertyName;
370+
previousModification.value = ((float)currentValue).ToString();
371371
}
372372

373-
state.AddPropertyModification(binding, property, modification.keepPrefabOverride);
374-
AddKey(state, binding, typeof(float), property);
373+
object previousValue = currentValue;
374+
ValueFromPropertyModification(previousModification, binding, out previousValue);
375+
376+
state.AddPropertyModification(binding, previousModification, modification.keepPrefabOverride);
377+
378+
if (scale != 1.0f)
379+
{
380+
previousValue = (object)((float)previousValue / scale);
381+
currentValue = (object)((float)currentValue / scale);
382+
}
383+
384+
AddKey(state, binding, typeof(float), previousValue, currentValue);
375385
}
376386

377387
static public void ProcessVector3Modifications(IAnimationRecordingState state, ref Dictionary<object, Vector3Modification> vector3Modifications)
@@ -412,8 +422,14 @@ static public void ProcessModifications(IAnimationRecordingState state, UndoProp
412422
Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(prop, root, out binding);
413423
if (type != null)
414424
{
425+
object currentValue = CurveBindingUtility.GetCurrentValue(root, binding);
426+
427+
object previousValue = null;
428+
if (!ValueFromPropertyModification(prop, binding, out previousValue))
429+
previousValue = currentValue;
430+
415431
state.AddPropertyModification(binding, prop, modifications[i].keepPrefabOverride);
416-
AddKey(state, binding, type, prop);
432+
AddKey(state, binding, type, previousValue, currentValue);
417433
}
418434
}
419435
}
@@ -481,7 +497,7 @@ static bool ValueFromPropertyModification(PropertyModification modification, Edi
481497
}
482498
}
483499

484-
static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, PropertyModification modification)
500+
static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, object previousValue, object currentValue)
485501
{
486502
GameObject root = state.activeRootGameObject;
487503
AnimationClip clip = state.activeAnimationClip;
@@ -491,23 +507,18 @@ static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, T
491507

492508
AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, type);
493509

494-
// Add key at current frame
495-
object currentValue = CurveBindingUtility.GetCurrentValue(root, binding);
496-
510+
// Add previous value at first frame on empty curves.
497511
if (state.addZeroFrame)
498512
{
499513
// Is it a new curve?
500514
if (curve.length == 0)
501515
{
502-
object oldValue = null;
503-
if (!ValueFromPropertyModification(modification, binding, out oldValue))
504-
oldValue = currentValue;
505-
506516
if (state.currentFrame != 0)
507-
AnimationWindowUtility.AddKeyframeToCurve(curve, oldValue, type, AnimationKeyTime.Frame(0, clip.frameRate));
517+
AnimationWindowUtility.AddKeyframeToCurve(curve, previousValue, type, AnimationKeyTime.Frame(0, clip.frameRate));
508518
}
509519
}
510520

521+
// Add key at current frame.
511522
AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.currentFrame, clip.frameRate));
512523

513524
state.SaveCurve(curve);
@@ -578,17 +589,17 @@ static private void ProcessRootMotionModifications(IAnimationRecordingState stat
578589

579590
if (m.lastP.previousValue != null)
580591
{
581-
ProcessAnimatorModification(state, animator, m.px, "MotionT.x", position.x, scale.x);
582-
ProcessAnimatorModification(state, animator, m.py, "MotionT.y", position.y, scale.y);
583-
ProcessAnimatorModification(state, animator, m.pz, "MotionT.z", position.z, scale.z);
592+
ProcessRootMotionModification(state, animator, m.px, "MotionT.x", position.x, scale.x);
593+
ProcessRootMotionModification(state, animator, m.py, "MotionT.y", position.y, scale.y);
594+
ProcessRootMotionModification(state, animator, m.pz, "MotionT.z", position.z, scale.z);
584595
}
585596

586597
if (m.lastR.previousValue != null)
587598
{
588-
ProcessAnimatorModification(state, animator, m.rx, "MotionQ.x", rotation.x, 1);
589-
ProcessAnimatorModification(state, animator, m.ry, "MotionQ.y", rotation.y, 1);
590-
ProcessAnimatorModification(state, animator, m.rz, "MotionQ.z", rotation.z, 1);
591-
ProcessAnimatorModification(state, animator, m.rw, "MotionQ.w", rotation.w, 1);
599+
ProcessRootMotionModification(state, animator, m.rx, "MotionQ.x", rotation.x, 1);
600+
ProcessRootMotionModification(state, animator, m.ry, "MotionQ.y", rotation.y, 1);
601+
ProcessRootMotionModification(state, animator, m.rz, "MotionQ.z", rotation.z, 1);
602+
ProcessRootMotionModification(state, animator, m.rw, "MotionQ.w", rotation.w, 1);
592603
}
593604
}
594605
}
@@ -607,6 +618,7 @@ static private void ProcessAnimatorModifications(IAnimationRecordingState state,
607618
bool isHuman = animator != null ? animator.isHuman : false;
608619
bool hasRootMotion = animator != null ? animator.hasRootMotion : false;
609620
bool applyRootMotion = animator != null ? animator.applyRootMotion : false;
621+
bool hasRootCurves = clip.hasRootCurves;
610622

611623
// process animator positions
612624
List<object> discardListPos = new List<object>();
@@ -625,7 +637,7 @@ static private void ProcessAnimatorModifications(IAnimationRecordingState state,
625637
continue;
626638

627639
bool isRootTransform = root.transform == target;
628-
bool isRootMotion = (isHuman || hasRootMotion || applyRootMotion) && isRootTransform;
640+
bool isRootMotion = isRootTransform && applyRootMotion && hasRootCurves && (isHuman || hasRootMotion);
629641
bool isHumanBone = isHuman && !isRootTransform && animator.IsBoneTransform(target);
630642

631643
if (isHumanBone)
@@ -648,6 +660,16 @@ static private void ProcessAnimatorModifications(IAnimationRecordingState state,
648660
rootMotionModification.py = m.y;
649661
rootMotionModification.pz = m.z;
650662

663+
discardListPos.Add(item.Key);
664+
}
665+
else if (applyRootMotion)
666+
{
667+
Vector3 scale = target.localScale * (isHuman ? animator.humanScale : 1);
668+
669+
ProcessVector3Modification(state, binding, m.x, target, "x", scale.x);
670+
ProcessVector3Modification(state, binding, m.y, target, "y", scale.y);
671+
ProcessVector3Modification(state, binding, m.z, target, "z", scale.z);
672+
651673
discardListPos.Add(item.Key);
652674
}
653675
}
@@ -674,7 +696,7 @@ static private void ProcessAnimatorModifications(IAnimationRecordingState state,
674696
continue;
675697

676698
bool isRootTransform = root.transform == target;
677-
bool isRootMotion = (isHuman || hasRootMotion || applyRootMotion) && isRootTransform;
699+
bool isRootMotion = isRootTransform && applyRootMotion && hasRootCurves && (isHuman || hasRootMotion);
678700
bool isHumanBone = isHuman && !isRootTransform && animator.IsBoneTransform(target);
679701

680702
if (isHumanBone)
@@ -740,7 +762,7 @@ static private void ProcessAnimatorModifications(IAnimationRecordingState state,
740762
ProcessRootMotionModifications(state, ref rootMotionModifications);
741763
}
742764

743-
static void ProcessAnimatorModification(IAnimationRecordingState state, Animator animator, UndoPropertyModification modification, string name, float value, float scale)
765+
static void ProcessRootMotionModification(IAnimationRecordingState state, Animator animator, UndoPropertyModification modification, string name, float value, float scale)
744766
{
745767
AnimationClip clip = state.activeAnimationClip;
746768

Editor/Mono/Animation/AnimationWindow/AnimationWindowControl.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,21 @@ public override bool canPreview
333333
if (!state.selection.canPreview)
334334
return false;
335335

336-
return AnimationMode.InAnimationMode(GetAnimationModeDriver()) || !AnimationMode.InAnimationMode();
336+
var driver = GetAnimationModeDriverNoAlloc();
337+
338+
return (driver != null && AnimationMode.InAnimationMode(driver)) || !AnimationMode.InAnimationMode();
337339
}
338340
}
339341

340342
public override bool previewing
341343
{
342344
get
343345
{
344-
return AnimationMode.InAnimationMode(GetAnimationModeDriver());
346+
var driver = GetAnimationModeDriverNoAlloc();
347+
if (driver == null)
348+
return false;
349+
350+
return AnimationMode.InAnimationMode(driver);
345351
}
346352
}
347353

@@ -494,6 +500,11 @@ private AnimationModeDriver GetAnimationModeDriver()
494500
return m_Driver;
495501
}
496502

503+
private AnimationModeDriver GetAnimationModeDriverNoAlloc()
504+
{
505+
return m_Driver;
506+
}
507+
497508
private AnimationModeDriver GetCandidateDriver()
498509
{
499510
if (m_CandidateDriver == null)

Editor/Mono/Animation/AnimationWindow/AnimationWindowHierarchyGUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ internal class AnimationWindowHierarchyGUI : TreeViewGUI
3535
private const float k_ValueFieldWidth = 80;
3636
private const float k_ValueFieldOffsetFromRightSide = 90;
3737
private const float k_ColorIndicatorTopMargin = 3;
38-
public const float k_DopeSheetRowHeight = EditorGUI.kSingleLineHeight;
39-
public const float k_DopeSheetRowHeightTall = k_DopeSheetRowHeight * 2f;
38+
public static readonly float k_DopeSheetRowHeight = EditorGUI.kSingleLineHeight;
39+
public static readonly float k_DopeSheetRowHeightTall = k_DopeSheetRowHeight * 2f;
4040
public const float k_AddCurveButtonNodeHeight = 40f;
4141
public const float k_RowBackgroundColorBrightness = 0.28f;
4242
private const float k_SelectedPhantomCurveColorMultiplier = 1.4f;

Editor/Mono/Annotation/AnnotationWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void Init(Rect buttonRect, bool isGameView)
182182
windowHeight = Mathf.Min(windowHeight, 900);
183183
Vector2 windowSize = new Vector2(kWindowWidth, windowHeight);
184184

185-
ShowAsDropDown(buttonRect, windowSize, null, ShowMode.PopupMenuWithKeyboardFocus);
185+
ShowAsDropDown(buttonRect, windowSize);
186186
}
187187

188188
private void IconHasChanged()

Editor/Mono/Annotation/SceneRenderModeWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private float windowHeight
190190
const float kFrameWidth = 1f;
191191
const float kHeaderHorizontalPadding = 5f;
192192
const float kHeaderVerticalPadding = 1f;
193-
const float kShowLightmapResolutionHeight = EditorGUI.kSingleLineHeight + kSeparatorHeight * 2;
193+
static readonly float kShowLightmapResolutionHeight = EditorGUI.kSingleLineHeight + kSeparatorHeight * 2;
194194
const float kTogglePadding = 7f;
195195

196196
readonly SceneView m_SceneView;

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@
3737
[assembly: InternalsVisibleTo("UnityEditor.LinuxStandalone.Extensions")]
3838
[assembly: InternalsVisibleTo("UnityEditor.WindowsStandalone.Extensions")]
3939
[assembly: InternalsVisibleTo("UnityEditor.OSXStandalone.Extensions")]
40+
[assembly: InternalsVisibleTo("UnityEditor.Lumin.Extensions")]
4041
[assembly: InternalsVisibleTo("UnityEditor.Networking")]
4142
[assembly: InternalsVisibleTo("UnityEngine.Networking")]
4243
[assembly: InternalsVisibleTo("Unity.Analytics.Editor")]
4344
[assembly: InternalsVisibleTo("UnityEditor.Analytics")]
4445
[assembly: InternalsVisibleTo("UnityEditor.Purchasing")]
4546
[assembly: InternalsVisibleTo("UnityEditor.N3DS.Extensions")]
47+
[assembly: InternalsVisibleTo("UnityEditor.Lumin")]
4648
[assembly: InternalsVisibleTo("UnityEditor.Switch.Extensions")]
4749
[assembly: InternalsVisibleTo("UnityEditor.EditorTestsRunner")]
4850
[assembly: InternalsVisibleTo("UnityEditor.TestRunner")]
@@ -92,5 +94,6 @@
9294
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.003")]
9395
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.004")]
9496
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.005")]
97+
[assembly: InternalsVisibleTo("Unity.XR.Remoting.Editor")]
9598

9699
[assembly: AssemblyIsEditorAssembly]

0 commit comments

Comments
 (0)