Skip to content

Commit 02d565c

Browse files
author
Unity Technologies
committed
Unity 2020.1.0a3 C# reference source code
1 parent 0cf7cda commit 02d565c

File tree

532 files changed

+10153
-6549
lines changed

Some content is hidden

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

532 files changed

+10153
-6549
lines changed

Editor/Mono/Animation/AnimationWindow/AddCurvesPopupHierarchyDataSource.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override void FetchData()
5454
private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, GameObject rootGameObject, AnimationClip animationClip, TreeViewItem parent)
5555
{
5656
string path = AnimationUtility.CalculateTransformPath(gameObject.transform, rootGameObject.transform);
57-
TreeViewItem node = new AddCurvesPopupGameObjectNode(gameObject, parent, gameObject.name);
57+
AddCurvesPopupGameObjectNode node = new AddCurvesPopupGameObjectNode(gameObject, parent, gameObject.name);
5858
List<TreeViewItem> childNodes = new List<TreeViewItem>();
5959

6060
if (m_RootItem == null)
@@ -111,6 +111,20 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, GameObject
111111
}
112112
}
113113

114+
var animator = rootGameObject.GetComponent<Animator>();
115+
if (animator != null)
116+
{
117+
//If the Animator has a human avatar, we need to check if the avatar's hierarchy matches that of the current GameObject. If they do not match, disable the node.
118+
if (animator.avatarRoot != null && animator.isHuman)
119+
{
120+
if (animator.avatarRoot.Find(path) == null)
121+
{
122+
node.propertyPathMismatchWithHumanAvatar = true;
123+
}
124+
}
125+
}
126+
127+
114128
if (showEntireHierarchy)
115129
{
116130
// Iterate over all child GOs
@@ -220,6 +234,7 @@ public void UpdateData()
220234

221235
internal class AddCurvesPopupGameObjectNode : TreeViewItem
222236
{
237+
internal bool propertyPathMismatchWithHumanAvatar = false;
223238
public AddCurvesPopupGameObjectNode(GameObject gameObject, TreeViewItem parent, string displayName)
224239
: base(gameObject.GetInstanceID(), parent != null ? parent.depth + 1 : -1, parent, displayName)
225240
{

Editor/Mono/Animation/AnimationWindow/AddCurvesPopupHierarchyGUI.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using UnityEditor.IMGUI.Controls;
77
using UnityEngine;
88
using System.Collections.Generic;
9+
using UnityEditor.ShortcutManagement;
910

1011
namespace UnityEditorInternal
1112
{
@@ -18,17 +19,38 @@ internal class AddCurvesPopupHierarchyGUI : TreeViewGUI
1819
private GUIContent addPropertiesContent = EditorGUIUtility.TrTextContent("Add Properties");
1920
private const float plusButtonWidth = 17;
2021

22+
static Texture2D warningIcon = (Texture2D)EditorGUIUtility.LoadRequired("Icons/ShortcutManager/alertDialog.png");
23+
public static GUIStyle warningIconStyle;
24+
2125
public AddCurvesPopupHierarchyGUI(TreeViewController treeView, EditorWindow owner)
2226
: base(treeView, true)
2327
{
2428
this.owner = owner;
29+
warningIconStyle = new GUIStyle();
30+
warningIconStyle.margin = new RectOffset(15, 15, 15, 15);
2531
}
2632

2733
public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
2834
{
29-
base.OnRowGUI(rowRect, node, row, selected, focused);
30-
DoAddCurveButton(rowRect, node);
31-
HandleContextMenu(rowRect, node);
35+
bool propertyPathMismatchWithHumanAvatar = false;
36+
AddCurvesPopupGameObjectNode addCurvesPopupNode = node as AddCurvesPopupGameObjectNode;
37+
if (addCurvesPopupNode != null)
38+
{
39+
propertyPathMismatchWithHumanAvatar = addCurvesPopupNode.propertyPathMismatchWithHumanAvatar;
40+
}
41+
42+
using (new EditorGUI.DisabledScope(propertyPathMismatchWithHumanAvatar))
43+
{
44+
base.OnRowGUI(rowRect, node, row, selected, focused);
45+
DoAddCurveButton(rowRect, node);
46+
HandleContextMenu(rowRect, node);
47+
}
48+
49+
if (propertyPathMismatchWithHumanAvatar)
50+
{
51+
Rect iconRect = new Rect(rowRect.width - plusButtonWidth, rowRect.yMin, plusButtonWidth, plusButtonStyle.fixedHeight);
52+
GUI.Label(iconRect, new GUIContent(warningIcon, "The Avatar definition does not match the property path. Please author using a hierarchy the Avatar was built with."), warningIconStyle);
53+
}
3254
}
3355

3456
private void DoAddCurveButton(Rect rowRect, TreeViewItem node)

Editor/Mono/Animation/AnimationWindow/AnimEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public FrameRateMenuEntry(GUIContent content, float value)
115115

116116
public GUIContent content;
117117
public float value;
118-
};
118+
}
119119

120120
internal static FrameRateMenuEntry[] kAvailableFrameRates = new FrameRateMenuEntry[]
121121
{

Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ static bool HasAnyRecordableModifications(GameObject root, UndoPropertyModificat
3131

3232
static private UndoPropertyModification[] FilterModifications(IAnimationRecordingState state, ref UndoPropertyModification[] modifications)
3333
{
34-
AnimationClip clip = state.activeAnimationClip;
3534
GameObject rootGameObject = state.activeRootGameObject;
3635

3736
List<UndoPropertyModification> discardedModifications = new List<UndoPropertyModification>();
@@ -163,7 +162,6 @@ static private void DiscardRotationModification(RotationModification rotationMod
163162

164163
static private UndoPropertyModification[] FilterRotationModifications(IAnimationRecordingState state, ref Dictionary<object, RotationModification> rotationModifications)
165164
{
166-
AnimationClip clip = state.activeAnimationClip;
167165
GameObject rootGameObject = state.activeRootGameObject;
168166

169167
List<object> itemsToRemove = new List<object>();
@@ -213,9 +211,6 @@ static private void AddRotationPropertyModification(IAnimationRecordingState sta
213211

214212
static private void ProcessRotationModifications(IAnimationRecordingState state, ref Dictionary<object, RotationModification> rotationModifications)
215213
{
216-
AnimationClip clip = state.activeAnimationClip;
217-
GameObject root = state.activeRootGameObject;
218-
219214
foreach (KeyValuePair<object, RotationModification> item in rotationModifications)
220215
{
221216
RotationModification m = item.Value;
@@ -387,9 +382,6 @@ static private void ProcessVector3Modification(IAnimationRecordingState state, E
387382

388383
static public void ProcessVector3Modifications(IAnimationRecordingState state, ref Dictionary<object, Vector3Modification> vector3Modifications)
389384
{
390-
AnimationClip clip = state.activeAnimationClip;
391-
GameObject root = state.activeRootGameObject;
392-
393385
foreach (KeyValuePair<object, Vector3Modification> item in vector3Modifications)
394386
{
395387
Vector3Modification m = item.Value;
@@ -411,7 +403,6 @@ static public void ProcessVector3Modifications(IAnimationRecordingState state, r
411403

412404
static public void ProcessModifications(IAnimationRecordingState state, UndoPropertyModification[] modifications)
413405
{
414-
AnimationClip clip = state.activeAnimationClip;
415406
GameObject root = state.activeRootGameObject;
416407

417408
// Record modified properties
@@ -500,7 +491,6 @@ static bool ValueFromPropertyModification(PropertyModification modification, Edi
500491

501492
static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, object previousValue, object currentValue)
502493
{
503-
GameObject root = state.activeRootGameObject;
504494
AnimationClip clip = state.activeAnimationClip;
505495

506496
if ((clip.hideFlags & HideFlags.NotEditable) != 0)
@@ -573,7 +563,6 @@ internal class RootMotionModification
573563
static private void ProcessRootMotionModifications(IAnimationRecordingState state,
574564
ref Dictionary<object, RootMotionModification> rootMotionModifications)
575565
{
576-
AnimationClip clip = state.activeAnimationClip;
577566
GameObject root = state.activeRootGameObject;
578567
Animator animator = root.GetComponent<Animator>();
579568

Editor/Mono/Animation/AnimationWindow/AnimationWindowControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ enum RecordingStateMode
5858
{
5959
ManualKey,
6060
AutoKey
61-
};
61+
}
6262

6363
class RecordingState : IAnimationRecordingState
6464
{
@@ -105,7 +105,7 @@ enum ResampleFlags
105105
FlushUndos = 1 << 2,
106106

107107
Default = RefreshViews | FlushUndos
108-
};
108+
}
109109

110110
private static bool HasFlag(ResampleFlags flags, ResampleFlags flag)
111111
{

Editor/Mono/Animation/AnimationWindow/AnimationWindowEventInspector.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,7 @@ private static int EnumPopup(string label, Type enumType, int selected)
379379

380380
private static bool IsSupportedMethodName(string name)
381381
{
382-
if (name == "Main" || name == "Start" || name == "Awake" || name == "Update")
383-
return false;
384-
385-
return true;
382+
return name != "Main" && name != "Start" && name != "Awake" && name != "Update";
386383
}
387384

388385
private static string FormatEventArguments(IEnumerable<Type> paramTypes, AnimationEvent evt)

Editor/Mono/Animation/AnimationWindow/AnimationWindowHierarchyDataSource.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ public override bool IsRenamingItemAllowed(TreeViewItem item)
6767
if (item is AnimationWindowHierarchyAddButtonNode || item is AnimationWindowHierarchyMasterNode || item is AnimationWindowHierarchyClipNode)
6868
return false;
6969

70-
if ((item as AnimationWindowHierarchyNode).path.Length == 0)
71-
return false;
72-
73-
return true;
70+
return (item as AnimationWindowHierarchyNode).path.Length != 0;
7471
}
7572

7673
public List<AnimationWindowHierarchyNode> CreateTreeFromCurves()

Editor/Mono/Animation/AnimationWindow/AnimationWindowHierarchyGUI.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -822,14 +822,6 @@ override public bool BeginRename(TreeViewItem item, float delay)
822822
{
823823
m_RenamedNode = item as AnimationWindowHierarchyNode;
824824

825-
GameObject rootGameObject = null;
826-
if (m_RenamedNode.curves.Length > 0)
827-
{
828-
AnimationWindowSelectionItem selectionBinding = m_RenamedNode.curves[0].selectionBinding;
829-
if (selectionBinding != null)
830-
rootGameObject = selectionBinding.rootGameObject;
831-
}
832-
833825
return GetRenameOverlay().BeginRename(m_RenamedNode.path, item.id, delay);
834826
}
835827

Editor/Mono/Animation/AnimationWindow/AnimationWindowManipulator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public enum Alignment
124124
Center,
125125
Left,
126126
Right
127-
};
127+
}
128128

129129
public Alignment alignment;
130130
public Color headColor;

Editor/Mono/Animation/AnimationWindow/AnimationWindowState.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public enum RefreshType
2323
None = 0,
2424
CurvesOnly = 1,
2525
Everything = 2
26-
};
26+
}
2727

2828
public enum SnapMode
2929
{
3030
Disabled = 0,
3131
SnapToFrame = 1,
3232
SnapToClipFrame = 2
33-
};
33+
}
3434

3535
[SerializeField] public AnimationWindowHierarchyState hierarchyState; // Persistent state of treeview on the left side of window
3636
[SerializeField] public AnimEditor animEditor; // Reference to owner of this state. Used to trigger repaints.
@@ -1204,7 +1204,7 @@ public void PasteKeys()
12041204
clipboardCurves.Add(keyframe.curve);
12051205

12061206
// If we have equal number of target and source curves, then match by index. If not, then try to match with AnimationWindowUtility.BestMatchForPaste.
1207-
bool matchCurveByIndex = clipboardCurves.Count() == activeCurves.Count();
1207+
bool matchCurveByIndex = clipboardCurves.Count == activeCurves.Count;
12081208
int targetIndex = 0;
12091209

12101210
foreach (AnimationWindowKeyframe keyframe in s_KeyframeClipboard)
@@ -1737,7 +1737,7 @@ public Vector2 timeRange
17371737

17381738
public string FormatFrame(int frame, int frameDigits)
17391739
{
1740-
return (frame / (int)frameRate).ToString() + ":" + (frame % frameRate).ToString().PadLeft(frameDigits, '0');
1740+
return (frame / (int)frameRate) + ":" + (frame % frameRate).ToString().PadLeft(frameDigits, '0');
17411741
}
17421742

17431743
//@TODO: Remove. Replace with animationkeytime

0 commit comments

Comments
 (0)