Skip to content

Commit ff0db31

Browse files
author
Unity Technologies
committed
Unity 2017.3.0a1 C# reference source code
1 parent 69bc09e commit ff0db31

File tree

415 files changed

+11217
-9825
lines changed

Some content is hidden

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

415 files changed

+11217
-9825
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ public override void OnInspectorGUI()
312312

313313
// Packing an atlas might change platform settings in the process, reinitialize
314314
SyncPlatformSettings();
315+
316+
GUIUtility.ExitGUI();
315317
}
316318
}
317319
else

Editor/Mono/2D/SpriteEditorModule/ISpriteEditorModule.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ internal interface ISpriteEditor
4545
void DisplayProgressBar(string title, string content, float progress);
4646
void ClearProgressBar();
4747
ITexture2D GetReadableTexture2D();
48+
void ApplyOrRevertModification(bool apply);
4849
}
4950

5051
internal interface ISpriteRectCache : IUndoableObject

Editor/Mono/2D/SpriteEditorModule/SpriteOutlineModule.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ void GenerateOutlineIfNotExist()
142142
var rectCache = spriteEditorWindow.spriteRects;
143143
if (rectCache != null)
144144
{
145+
bool needApply = false;
145146
for (int i = 0; i < rectCache.Count; ++i)
146147
{
147148
var rect = rectCache.RectAt(i);
@@ -152,9 +153,14 @@ void GenerateOutlineIfNotExist()
152153
(float)(i) / rectCache.Count);
153154

154155
SetupShapeEditorOutline(rect);
156+
needApply = true;
155157
}
156158
}
157-
spriteEditorWindow.ClearProgressBar();
159+
if (needApply)
160+
{
161+
spriteEditorWindow.ClearProgressBar();
162+
spriteEditorWindow.ApplyOrRevertModification(true);
163+
}
158164
}
159165
}
160166

@@ -455,7 +461,6 @@ protected virtual void SetupShapeEditorOutline(SpriteRect spriteRect)
455461
}
456462
};
457463
}
458-
spriteEditorWindow.SetDataModified();
459464
}
460465
}
461466

Editor/Mono/Animation/AnimationWindow/AnimEditor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ internal class AnimEditor : ScriptableObject
4040

4141
[System.NonSerialized] private Rect m_Position;
4242
[System.NonSerialized] private bool m_TriggerFraming;
43-
[System.NonSerialized] private bool m_StylesInitialized;
4443
[System.NonSerialized] private bool m_Initialized;
4544

4645
private float hierarchyWidth { get { return m_HorizontalSplitter.realSizes[0]; } }

Editor/Mono/Animation/AnimationWindow/AnimationWindowControl.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public void AddPropertyModification(EditorCurveBinding binding, PropertyModifica
9595
public AnimEditor animEditor { get { return state.animEditor; } }
9696

9797
[SerializeField] private AnimationClip m_CandidateClip;
98-
[NonSerialized] private List<UndoPropertyModification> m_Candidates;
9998

10099
[SerializeField] private AnimationModeDriver m_Driver;
101100
[SerializeField] private AnimationModeDriver m_CandidateDriver;

Editor/Mono/Animation/AnimationWindow/CurveBindingUtility.cs

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

5-
using System;
6-
using System.Collections.Generic;
75
using UnityEditor;
8-
using UnityEditor.Animations;
96
using UnityEngine;
10-
using Object = UnityEngine.Object;
117

128
namespace UnityEditorInternal
139
{
1410
static internal class CurveBindingUtility
1511
{
16-
private static GameObject s_Root;
17-
1812
// Retrieve current value. If bindings are available and value is animated, use bindings to get value.
1913
// Otherwise, evaluate AnimationWindowCurve at current time.
2014
public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)

Editor/Mono/Animation/AnimationWindow/CurveEditor.cs

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,27 @@ public void FrameSelected(bool horizontally, bool vertically)
841841
return;
842842
}
843843

844-
Bounds frameBounds = selectionBounds;
844+
Bounds frameBounds = new Bounds();
845+
846+
// Add neighboring keys in bounds if only a single key is selected.
847+
if (selectedCurves.Count == 1)
848+
{
849+
CurveSelection cs = selectedCurves[0];
850+
CurveWrapper cw = GetCurveWrapperFromSelection(cs);
851+
852+
// Encapsulate key in bounds
853+
frameBounds = new Bounds(new Vector2(cw.curve[cs.key].time, cw.curve[cs.key].value), Vector2.zero);
854+
855+
// Include neighboring keys in bounds
856+
if (cs.key - 1 >= 0)
857+
frameBounds.Encapsulate(new Vector2(cw.curve[cs.key - 1].time, cw.curve[cs.key - 1].value));
858+
if (cs.key + 1 < cw.curve.length)
859+
frameBounds.Encapsulate(new Vector2(cw.curve[cs.key + 1].time, cw.curve[cs.key + 1].value));
860+
}
861+
else
862+
{
863+
frameBounds = selectionBounds;
864+
}
845865

846866
// Enforce minimum size of bounds
847867
frameBounds.size = new Vector3(Mathf.Max(frameBounds.size.x, 0.1F), Mathf.Max(frameBounds.size.y, 0.1F), 0);
@@ -2672,17 +2692,23 @@ void EditSelectedPoints()
26722692
}
26732693
}
26742694

2675-
if (evt.type == EventType.KeyDown && (evt.character == '\t' || (int)evt.character == 25))
2695+
if (evt.type == EventType.KeyDown)
26762696
{
2697+
const char tabCharacter = '\t';
2698+
const char endOfMediumCharacter = (char)25; // ASCII 25: "End Of Medium" on pressing shift tab
2699+
26772700
// Override Unity's Tab and Shift+Tab handling.
2678-
if (m_TimeWasEdited || m_ValueWasEdited)
2701+
if (evt.character == tabCharacter || evt.character == endOfMediumCharacter)
26792702
{
2680-
SetSelectedKeyPositions(m_NewTime, m_NewValue, m_TimeWasEdited, m_ValueWasEdited);
2681-
m_PointEditingFieldPosition = GetPointEditionFieldPosition();
2682-
}
2703+
if (m_TimeWasEdited || m_ValueWasEdited)
2704+
{
2705+
SetSelectedKeyPositions(m_NewTime, m_NewValue, m_TimeWasEdited, m_ValueWasEdited);
2706+
m_PointEditingFieldPosition = GetPointEditionFieldPosition();
2707+
}
26832708

2684-
m_FocusedPointField = GUI.GetNameOfFocusedControl() == kPointValueFieldName ? kPointTimeFieldName : kPointValueFieldName;
2685-
evt.Use();
2709+
m_FocusedPointField = GUI.GetNameOfFocusedControl() == kPointValueFieldName ? kPointTimeFieldName : kPointValueFieldName;
2710+
evt.Use();
2711+
}
26862712
}
26872713

26882714
// Stop editing if there's an unused click

Editor/Mono/Animation/AnimationWindow/CurveEditorWindow.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public string currentPresetLibrary
7171

7272
public static AnimationCurve curve
7373
{
74-
get { return CurveEditorWindow.instance.m_Curve; }
74+
get { return visible ? CurveEditorWindow.instance.m_Curve : null; }
7575
set
7676
{
7777
CurveEditorWindow.instance.m_Property = null;
@@ -91,7 +91,7 @@ public static SerializedProperty property
9191
{
9292
get
9393
{
94-
return CurveEditorWindow.instance.m_Property;
94+
return visible ? CurveEditorWindow.instance.m_Property : null;
9595
}
9696
set
9797
{
@@ -161,6 +161,12 @@ void Init(CurveEditorSettings settings)
161161
}
162162

163163
m_CurveEditor.FrameSelected(frameH, frameV);
164+
165+
titleContent = new GUIContent("Curve");
166+
167+
// deal with window size
168+
minSize = new Vector2(240, 240 + kPresetsHeight);
169+
maxSize = new Vector2(10000, 10000);
164170
}
165171

166172
CurveLibraryType curveLibraryType
@@ -281,13 +287,21 @@ private void RefreshShownCurves()
281287
public void Show(GUIView viewToUpdate, CurveEditorSettings settings)
282288
{
283289
delegateView = viewToUpdate;
290+
m_OnCurveChanged = null;
291+
284292
Init(settings);
285293
ShowAuxWindow();
286-
titleContent = new GUIContent("Curve");
294+
}
287295

288-
// deal with window size
289-
minSize = new Vector2(240, 240 + kPresetsHeight);
290-
maxSize = new Vector2(10000, 10000);
296+
System.Action<AnimationCurve> m_OnCurveChanged;
297+
298+
public void Show(System.Action<AnimationCurve> onCurveChanged, CurveEditorSettings settings)
299+
{
300+
m_OnCurveChanged = onCurveChanged;
301+
delegateView = null;
302+
303+
Init(settings);
304+
ShowAuxWindow();
291305
}
292306

293307
internal class Styles
@@ -436,7 +450,7 @@ void OnGUI()
436450
{
437451
bool gotMouseUp = (Event.current.type == EventType.mouseUp);
438452

439-
if (delegateView == null)
453+
if (delegateView == null && m_OnCurveChanged == null)
440454
m_Curve = null;
441455

442456
if (ms_Styles == null)
@@ -596,6 +610,11 @@ void SendEvent(string eventName, bool exitGUI)
596610
if (exitGUI)
597611
GUIUtility.ExitGUI();
598612
}
613+
614+
if (m_OnCurveChanged != null)
615+
{
616+
m_OnCurveChanged(curve);
617+
}
599618
GUI.changed = true;
600619
}
601620
}

Editor/Mono/Animation/AnimationWindow/CurveRenderer/NormalCurveRenderer.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ public static void DrawCurveWrapped(float minTime, float maxTime, float rangeSta
298298
{
299299
minRep = Mathf.FloorToInt((minTime - rangeStart) / (rangeEnd - rangeStart));
300300
maxRep = Mathf.CeilToInt((maxTime - rangeEnd) / (rangeEnd - rangeStart));
301+
302+
// Prevent too many loops from being rendered at one time.
303+
if (minRep < -kMaximumLoops)
304+
preWrap = WrapMode.Clamp;
305+
if (maxRep > kMaximumLoops)
306+
postWrap = WrapMode.Clamp;
301307
}
302308
else
303309
{
@@ -452,7 +458,7 @@ public static void DrawCurveWrapped(float minTime, float maxTime, float rangeSta
452458
minRep = Mathf.FloorToInt((minTime - rangeStart) / (rangeEnd - rangeStart));
453459
maxRep = Mathf.CeilToInt((maxTime - rangeEnd) / (rangeEnd - rangeStart));
454460

455-
// Prevent too much loops from being rendered at one time.
461+
// Prevent too many loops from being rendered at one time.
456462
if (minRep < -kMaximumLoops)
457463
preWrap = WrapMode.Clamp;
458464
if (maxRep > kMaximumLoops)

Editor/Mono/Animation/AnimationWindow/Deprecated/UtilityClasses.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ internal static class CurveUtility
1616
{
1717
private static Texture2D iconKey;
1818
private static Texture2D iconCurve;
19-
private static Texture2D iconNone;
2019

2120

2221
public static int GetPathAndTypeID(string path, Type type)

0 commit comments

Comments
 (0)