Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using UnityEngine;
using UnityEditor;
using UnityEngine.Bindings;
using UnityEngine.U2D;

namespace UnityEditor.Experimental.U2D
namespace UnityEditor.U2D
{
[NativeHeader("Editor/Src/2D/SpriteEditorExtension.h")]
public static class SpriteEditorExtension
Expand Down
9 changes: 9 additions & 0 deletions Editor/Mono/Animation/AnimationMode.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ internal static void StartAnimationRecording()
[NativeThrows]
extern internal static void RevertPropertyModificationsForObject([NotNull] Object target);

// Returns editor curve bindings for animation clip and animator hierarchy that need to be snapshot for animation mode.
extern internal static EditorCurveBinding[] GetAllBindings([NotNull] GameObject root, [NotNull] AnimationClip clip);

// Returns editor curve bindings for animation clip that need to be snapshot for animation mode.
extern internal static EditorCurveBinding[] GetCurveBindings([NotNull] AnimationClip clip);

// Return editor curve bindings for animator hierarhcy that need to be snapshot for animation mode.
extern internal static EditorCurveBinding[] GetAnimatorBindings([NotNull] GameObject root);

extern private static bool Internal_InAnimationMode(Object driver);

extern private static bool Internal_InAnimationModeNoDriver();
Expand Down
6 changes: 0 additions & 6 deletions Editor/Mono/Animation/AnimationUtility.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,13 @@ internal static EditorCurveBinding[] GetAnimatableBindings(ScriptableObject scri
return Internal_GetScriptableObjectAnimatableBindings(scriptableObject);
}

internal static EditorCurveBinding[] GetAdditionalAnimatorBindings(GameObject targetObject)
{
return Internal_GetAdditionalAnimatorBindings(targetObject);
}

internal static EditorCurveBinding[] GetAnimationStreamBindings(GameObject root)
{
return Internal_GetAnimationStreamBindings(root);
}

extern private static EditorCurveBinding[] Internal_GetGameObjectAnimatableBindings([NotNull] GameObject targetObject, [NotNull] GameObject root);
extern private static EditorCurveBinding[] Internal_GetScriptableObjectAnimatableBindings([NotNull] ScriptableObject scriptableObject);
extern private static EditorCurveBinding[] Internal_GetAdditionalAnimatorBindings([NotNull] GameObject targetObject);
extern private static EditorCurveBinding[] Internal_GetAnimationStreamBindings([NotNull] GameObject root);

// 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)
Expand Down
6 changes: 3 additions & 3 deletions Editor/Mono/Animation/AnimationWindow/AnimationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ static bool OnOpenAsset(int instanceID, int line)

public bool EditGameObject(GameObject gameObject)
{
if (state.linkedWithSequencer == true)
return false;

return EditGameObjectInternal(gameObject, (IAnimationWindowControl)null);
}

Expand Down Expand Up @@ -268,6 +265,9 @@ private bool ShouldUpdateGameObjectSelection(GameObjectSelectionItem selectedIte
if (m_LockTracker.isLocked)
return false;

if (state.linkedWithSequencer)
return false;

// Selected game object with no animation player.
if (selectedItem.rootGameObject == null)
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,6 @@ private string GetGameObjectName(GameObject rootGameObject, string path)
return splits[splits.Length - 1];
}

private string GetPathWithoutChildmostGameObject(string path)
{
if (string.IsNullOrEmpty(path))
return "";

int lastIndex = path.LastIndexOf('/');
return path.Substring(0, lastIndex + 1);
}

private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row)
{
bool curvesChanged = false;
Expand Down
30 changes: 0 additions & 30 deletions Editor/Mono/Animation/AnimationWindow/AnimationWindowState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -900,15 +900,6 @@ public void SelectKey(AnimationWindowKeyframe keyframe)
m_SelectionBoundsCache = null;
}

public void SelectKeysFromDopeline(DopeLine dopeline)
{
if (dopeline == null)
return;

foreach (var key in dopeline.keys)
SelectKey(key);
}

public void UnselectKey(AnimationWindowKeyframe keyframe)
{
int hash = keyframe.GetHash();
Expand All @@ -919,15 +910,6 @@ public void UnselectKey(AnimationWindowKeyframe keyframe)
m_SelectionBoundsCache = null;
}

public void UnselectKeysFromDopeline(DopeLine dopeline)
{
if (dopeline == null)
return;

foreach (var key in dopeline.keys)
UnselectKey(key);
}

public void DeleteSelectedKeys()
{
if (selectedKeys.Count == 0)
Expand Down Expand Up @@ -1546,18 +1528,6 @@ public HashSet<int> GetAffectedHierarchyIDs(List<AnimationWindowKeyframe> keyfra
return hierarchyIDs;
}

public List<DopeLine> GetAffectedDopelines(List<AnimationWindowKeyframe> keyframes)
{
List<DopeLine> affectedDopelines = new List<DopeLine>();

foreach (AnimationWindowCurve curve in GetAffectedCurves(keyframes))
foreach (DopeLine dopeline in dopelines)
if (!affectedDopelines.Contains(dopeline) && dopeline.curves.Contains(curve))
affectedDopelines.Add(dopeline);

return affectedDopelines;
}

public List<AnimationWindowCurve> GetAffectedCurves(List<AnimationWindowKeyframe> keyframes)
{
List<AnimationWindowCurve> affectedCurves = new List<AnimationWindowCurve>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class AnimationWindowStyles
public static GUIContent addKeyframeContent = EditorGUIUtility.TrIconContent("Animation.AddKeyframe", "Add keyframe.");
public static GUIContent addEventContent = EditorGUIUtility.TrIconContent("Animation.AddEvent", "Add event.");
public static GUIContent filterBySelectionContent = EditorGUIUtility.TrIconContent("Animation.FilterBySelection", "Filter by selection.");
public static GUIContent sequencerLinkContent = EditorGUIUtility.TrIconContent("Animation.SequencerLink", "Animation Window is linked to Sequence Editor. Press to Unlink.");
public static GUIContent sequencerLinkContent = EditorGUIUtility.TrIconContent("Animation.SequencerLink", "Animation Window is linked to Timeline Editor. Press to Unlink.");

public static GUIContent noAnimatableObjectSelectedText = EditorGUIUtility.TrTextContent("No animatable object selected.");
public static GUIContent formatIsMissing = EditorGUIUtility.TrTextContent("To begin animating {0}, create {1}.");
Expand Down
17 changes: 1 addition & 16 deletions Editor/Mono/Animation/AnimationWindow/CurveEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,21 +1326,6 @@ void DragTangents()
}
}

struct KeyFrameCopy
{
public float time, value, inTangent, outTangent;
public int idx, selectionIdx;
public KeyFrameCopy(int idx, int selectionIdx, Keyframe source)
{
this.idx = idx;
this.selectionIdx = selectionIdx;
time = source.time;
value = source.value;
inTangent = source.inTangent;
outTangent = source.outTangent;
}
}

internal void DeleteSelectedKeys()
{
string undoLabel;
Expand Down Expand Up @@ -2882,7 +2867,7 @@ public Vector2 MovePoints()
}

// Curve dragging. Moving keys has highest priority, therefore we check curve/region dragging AFTER key dragging above
if (settings.allowDraggingCurvesAndRegions && m_DraggingKey == null)
if (evt.shift && settings.allowDraggingCurvesAndRegions && m_DraggingKey == null)
{
// We use the logic as for moving keys when we drag entire curves or regions: We just
// select all keyFrames in a curve or region before dragging and ensure to hide tangents when drawing.
Expand Down
5 changes: 0 additions & 5 deletions Editor/Mono/Animation/AnimationWindow/DopeSheetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,6 @@ private void RectangleToolGUI()
m_RectangleTool.OnGUI();
}

private void DrawGrid(Rect position)
{
TimeRuler(position, state.frameRate, false, true, 0.2f);
}

public void DrawMasterDopelineBackground(Rect position)
{
if (Event.current.type != EventType.Repaint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace UnityEditor
{
internal class DopeSheetEditorRectangleTool : RectangleTool
{
const float kDefaultFrameRate = 60f;

const int kScaleLeftWidth = 17;
const int kScaleLeftMarginHorizontal = 0;
const float kScaleLeftMarginVertical = 4;
Expand Down Expand Up @@ -382,14 +377,6 @@ private void OnScaleTime(float time)
TransformKeys(transform, flipX, false);
}

private void OnScaleValue(float val)
{
Matrix4x4 transform;
bool flipY;
if (CalculateScaleValueMatrix(m_Previous.y, val, m_MouseOffset.y, m_Pivot.y, out transform, out flipY))
TransformKeys(transform, false, flipY);
}

private void OnEndScale()
{
m_State.EndLiveEdit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ public static State GetCurveState(AnimationClip clip, EditorCurveBinding[] selec
return state;
}

public static int GetCurveIndexFromName(string name)
{
return ExtractComponentCharacter(name) - 'x';
}

public static char ExtractComponentCharacter(string name)
{
return name[name.Length - 1];
Expand Down
47 changes: 45 additions & 2 deletions Editor/Mono/Animation/GameObjectRecorder.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,30 @@

namespace UnityEditor.Animations
{
public struct CurveFilterOptions
{
public float positionError;
public float rotationError;
public float scaleError;
public float floatError;
public bool keyframeReduction;
}

[NativeHeader("Editor/Src/Animation/EditorCurveBinding.bindings.h")]
[NativeHeader("Editor/Src/Animation/GameObjectRecorder.h")]
[NativeHeader("Modules/Animation/AnimationClip.h")]
[NativeType]
public class GameObjectRecorder : Object
{
readonly static CurveFilterOptions k_DefaultCurveFilterOptions = new CurveFilterOptions()
{
keyframeReduction = true,
positionError = 0.5f,
rotationError = 0.5f,
scaleError = 0.5f,
floatError = 0.5f
};

public GameObjectRecorder(GameObject root)
{
Internal_Create(this, root);
Expand Down Expand Up @@ -76,11 +94,36 @@ public void SaveToClip(AnimationClip clip, float fps)
{
if (fps <= Mathf.Epsilon)
throw new ArgumentException("FPS can't be 0.0 or less");
SaveToClipInternal(clip, fps);

if (!isRecording)
throw new InvalidOperationException("Cannot save to clip as there is nothing to save. The method TakeSnapshot() has not been called.");

SaveToClipInternal(clip, fps, k_DefaultCurveFilterOptions);

AnimationUtility.onCurveWasModified?.Invoke(clip, new EditorCurveBinding(), AnimationUtility.CurveModifiedType.ClipModified);
}

public void SaveToClip(AnimationClip clip, float fps, CurveFilterOptions filterOptions)
{
if (fps <= Mathf.Epsilon)
throw new ArgumentException("FPS can't be 0.0 or less");

if (filterOptions.keyframeReduction)
{
if (filterOptions.positionError < 0 || filterOptions.rotationError < 0 || filterOptions.scaleError < 0 || filterOptions.floatError < 0)
throw new ArgumentException("Allowed errors for keyframe reduction cannot be negative.");
}

if (!isRecording)
throw new InvalidOperationException("Cannot save to clip as there is nothing to save. The method TakeSnapshot() has not been called.");

SaveToClipInternal(clip, fps, filterOptions);

AnimationUtility.onCurveWasModified?.Invoke(clip, new EditorCurveBinding(), AnimationUtility.CurveModifiedType.ClipModified);
}

[NativeMethod("SaveToClip")]
extern void SaveToClipInternal(AnimationClip clip, float fps);
extern void SaveToClipInternal(AnimationClip clip, float fps, CurveFilterOptions filterOptions);

extern public void ResetRecording();

Expand Down
5 changes: 0 additions & 5 deletions Editor/Mono/Animation/TimeArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ public void TimeRuler(Rect position, float frameRate)
TimeRuler(position, frameRate, true, false, 1f, TimeFormat.TimeFrame);
}

public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntireHeight, float alpha)
{
TimeRuler(position, frameRate, labels, useEntireHeight, alpha, TimeFormat.TimeFrame);
}

public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntireHeight, float alpha,
TimeFormat timeFormat)
{
Expand Down
3 changes: 3 additions & 0 deletions Editor/Mono/Annotation/AnnotationUtility.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System;
using System.Runtime.InteropServices;
using UnityEngine.Bindings;

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

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

[StaticAccessor("GetAnnotationManager()", StaticAccessorType.Dot)]
Expand Down
11 changes: 1 addition & 10 deletions Editor/Mono/Annotation/AnnotationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ private enum EnabledState
GUIContent iconSelectContent = EditorGUIUtility.TrTextContent("", "Select Icon");

GUIContent icon3dGizmoContent = EditorGUIUtility.TrTextContent("3D Icons");
GUIContent showGridContent = EditorGUIUtility.TrTextContent("Show Grid");
GUIContent showOutlineContent = EditorGUIUtility.TrTextContent("Selection Outline");
GUIContent showWireframeContent = EditorGUIUtility.TrTextContent("Selection Wire");
private bool m_IsGameView;
Expand Down Expand Up @@ -144,7 +143,7 @@ static public void IconChanged()

float GetTopSectionHeight()
{
const int numberOfControls = 4;
const int numberOfControls = 3;
return EditorGUI.kSingleLineHeight * numberOfControls + EditorGUI.kControlVerticalSpacing * numberOfControls;
}

Expand Down Expand Up @@ -365,9 +364,6 @@ void DrawTopSection(float topSectionHeight)
using (new EditorGUI.DisabledScope(m_IsGameView))
{
toggleRect = new Rect(margin, curY, labelWidth, rowHeight);
AnnotationUtility.showGrid = GUI.Toggle(toggleRect, AnnotationUtility.showGrid, showGridContent);

toggleRect.y += rowHeight;
AnnotationUtility.showSelectionOutline = GUI.Toggle(toggleRect, AnnotationUtility.showSelectionOutline, showOutlineContent);

toggleRect.y += rowHeight;
Expand Down Expand Up @@ -714,11 +710,6 @@ public AInfo(bool gizmoEnabled, bool iconEnabled, int flags, int classID, string
public string m_DisplayText;
public int m_Flags;

bool IsBitSet(byte b, int pos)
{
return (b & (1 << pos)) != 0;
}

public bool HasGizmo()
{
return (m_Flags & (int)Flags.kHasGizmo) > 0;
Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/AssemblyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static public string ExtractInternalAssemblyName(string path)
}
catch
{
return ""; // Possible on just deleted FacebookSDK
return "";
}
}

Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/AssemblyInfo/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
[assembly: InternalsVisibleTo("Unity.IntegrationTests.UnityAnalytics")]
[assembly: InternalsVisibleTo("Unity.Timeline.Editor")]
[assembly: InternalsVisibleTo("Unity.PackageManagerUI.Develop.Editor")]
[assembly: InternalsVisibleTo("Unity.DeviceSimulator.Editor")]

[assembly: InternalsVisibleTo("Unity.Timeline.EditorTests")]
[assembly: InternalsVisibleTo("UnityEditor.Graphs")]
Expand Down Expand Up @@ -58,7 +59,6 @@
[assembly: InternalsVisibleTo("UnityEditor.VR")]
[assembly: InternalsVisibleTo("Unity.RuntimeTests")]
[assembly: InternalsVisibleTo("Unity.RuntimeTests.Framework")]
[assembly: InternalsVisibleTo("UnityEditor.Facebook.Extensions")]
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor-firstpass-testable")]
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor-testable")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
Expand Down
Loading