Skip to content

Commit d9c9752

Browse files
author
Unity Technologies
committed
Unity 2018.1.0a3 C# reference source code
1 parent 24b451c commit d9c9752

File tree

318 files changed

+12595
-10160
lines changed

Some content is hidden

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

318 files changed

+12595
-10160
lines changed

Editor/Mono/2D/Common/TexturePlatformSettingsFormatHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public void AcquireTextureFormatValuesAndStrings(BuildTarget buildTarget, out in
3636
formatValues = TextureImportPlatformSettings.kTextureFormatsValueWiiU;
3737
formatStrings = TextureImporterInspector.s_TextureFormatStringsWiiU;
3838
}
39+
else if (buildTarget == BuildTarget.PSP2)
40+
{
41+
formatValues = TextureImportPlatformSettings.kTextureFormatsValuePSP2;
42+
formatStrings = TextureImporterInspector.s_TextureFormatStringsPSP2;
43+
}
3944
else if (buildTarget == BuildTarget.Switch)
4045
{
4146
formatValues = TextureImportPlatformSettings.kTextureFormatsValueSwitch;

Editor/Mono/Animation/AnimationWindow/AddCurvesPopup.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ internal class AddCurvesPopup : EditorWindow
1515
const float k_WindowPadding = 3;
1616

1717
internal static AnimationWindowState s_State;
18-
internal static AnimationWindowSelection selection { get; set; }
1918

2019
private static AddCurvesPopup s_AddCurvesPopup;
2120
private static long s_LastClosedTime;
@@ -48,7 +47,7 @@ void OnDisable()
4847

4948
internal static void AddNewCurve(AddCurvesPopupPropertyNode node)
5049
{
51-
AnimationWindowUtility.CreateDefaultCurves(s_State, node.selectionItem, node.curveBindings);
50+
AnimationWindowUtility.CreateDefaultCurves(s_State, node.curveBindings);
5251
if (NewCurveAddedCallback != null)
5352
NewCurveAddedCallback(node);
5453
}

Editor/Mono/Animation/AnimationWindow/AddCurvesPopupHierarchyDataSource.cs

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,36 @@ private void SetupRootNodeSettings()
3131

3232
public override void FetchData()
3333
{
34-
if (AddCurvesPopup.selection == null)
35-
return;
36-
37-
AnimationWindowSelectionItem[] selectionItems = AddCurvesPopup.selection.ToArray();
38-
if (selectionItems.Length > 1)
39-
{
40-
m_RootItem = new AddCurvesPopupObjectNode(null, "", "");
41-
}
42-
43-
foreach (AnimationWindowSelectionItem item in selectionItems)
34+
if (AddCurvesPopup.s_State.selection.canAddCurves)
4435
{
45-
if (!item.canAddCurves)
46-
continue;
36+
GameObject rootGameObject = AddCurvesPopup.s_State.activeRootGameObject;
37+
ScriptableObject scriptableObject = AddCurvesPopup.s_State.activeScriptableObject;
4738

48-
if (item.rootGameObject != null)
39+
if (rootGameObject != null)
4940
{
50-
AddGameObjectToHierarchy(item.rootGameObject, item, m_RootItem);
41+
AddGameObjectToHierarchy(rootGameObject, rootGameObject, AddCurvesPopup.s_State.activeAnimationClip, m_RootItem);
5142
}
52-
else if (item.scriptableObject != null)
43+
else if (scriptableObject != null)
5344
{
54-
AddScriptableObjectToHierarchy(item.scriptableObject, item, m_RootItem);
45+
AddScriptableObjectToHierarchy(scriptableObject, AddCurvesPopup.s_State.activeAnimationClip, m_RootItem);
5546
}
5647
}
5748

5849
SetupRootNodeSettings();
5950
m_NeedRefreshRows = true;
6051
}
6152

62-
private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWindowSelectionItem selectionItem, TreeViewItem parent)
53+
private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, GameObject rootGameObject, AnimationClip animationClip, TreeViewItem parent)
6354
{
64-
string path = AnimationUtility.CalculateTransformPath(gameObject.transform, selectionItem.rootGameObject.transform);
55+
string path = AnimationUtility.CalculateTransformPath(gameObject.transform, rootGameObject.transform);
6556
TreeViewItem node = new AddCurvesPopupGameObjectNode(gameObject, parent, gameObject.name);
6657
List<TreeViewItem> childNodes = new List<TreeViewItem>();
6758

6859
if (m_RootItem == null)
6960
m_RootItem = node;
7061

7162
// Iterate over all animatable objects
72-
EditorCurveBinding[] allCurveBindings = AnimationUtility.GetAnimatableBindings(gameObject, selectionItem.rootGameObject);
63+
EditorCurveBinding[] allCurveBindings = AnimationUtility.GetAnimatableBindings(gameObject, rootGameObject);
7364
List<EditorCurveBinding> singleObjectBindings = new List<EditorCurveBinding>();
7465
for (int i = 0; i < allCurveBindings.Length; i++)
7566
{
@@ -83,7 +74,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
8374
// Don't show for the root go
8475
if (curveBinding.path != "")
8576
{
86-
TreeViewItem newNode = CreateNode(selectionItem, singleObjectBindings.ToArray(), node);
77+
TreeViewItem newNode = CreateNode(singleObjectBindings.ToArray(), node);
8778
if (newNode != null)
8879
childNodes.Add(newNode);
8980
singleObjectBindings.Clear();
@@ -104,7 +95,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
10495
isLastItemOnThisGroup = (allCurveBindings[i + 1].type != curveBinding.type);
10596

10697
// Let's not add those that already have a existing curve.
107-
if (AnimationWindowUtility.IsCurveCreated(selectionItem.animationClip, curveBinding))
98+
if (AnimationWindowUtility.IsCurveCreated(animationClip, curveBinding))
10899
singleObjectBindings.Remove(curveBinding);
109100

110101
// Remove animator enabled property which shouldn't be animated.
@@ -113,7 +104,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
113104

114105
if ((isLastItemOverall || isLastItemOnThisGroup) && singleObjectBindings.Count > 0)
115106
{
116-
childNodes.Add(AddAnimatableObjectToHierarchy(selectionItem, singleObjectBindings.ToArray(), node, path));
107+
childNodes.Add(AddAnimatableObjectToHierarchy(singleObjectBindings.ToArray(), node, path));
117108
singleObjectBindings.Clear();
118109
}
119110
}
@@ -125,7 +116,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
125116
for (int i = 0; i < gameObject.transform.childCount; i++)
126117
{
127118
Transform childTransform = gameObject.transform.GetChild(i);
128-
TreeViewItem childNode = AddGameObjectToHierarchy(childTransform.gameObject, selectionItem, node);
119+
TreeViewItem childNode = AddGameObjectToHierarchy(childTransform.gameObject, rootGameObject, animationClip, node);
129120
if (childNode != null)
130121
childNodes.Add(childNode);
131122
}
@@ -135,14 +126,14 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
135126
return node;
136127
}
137128

138-
private TreeViewItem AddScriptableObjectToHierarchy(ScriptableObject scriptableObject, AnimationWindowSelectionItem selectionItem, TreeViewItem parent)
129+
private TreeViewItem AddScriptableObjectToHierarchy(ScriptableObject scriptableObject, AnimationClip clip, TreeViewItem parent)
139130
{
140131
EditorCurveBinding[] allCurveBindings = AnimationUtility.GetScriptableObjectAnimatableBindings(scriptableObject);
141-
EditorCurveBinding[] availableBindings = allCurveBindings.Where(c => !AnimationWindowUtility.IsCurveCreated(selectionItem.animationClip, c)).ToArray();
132+
EditorCurveBinding[] availableBindings = allCurveBindings.Where(c => !AnimationWindowUtility.IsCurveCreated(clip, c)).ToArray();
142133

143134
TreeViewItem node = null;
144135
if (availableBindings.Length > 0)
145-
node = AddAnimatableObjectToHierarchy(selectionItem, availableBindings, parent, "");
136+
node = AddAnimatableObjectToHierarchy(availableBindings, parent, "");
146137
else
147138
node = new AddCurvesPopupObjectNode(parent, "", scriptableObject.name);
148139

@@ -152,36 +143,36 @@ private TreeViewItem AddScriptableObjectToHierarchy(ScriptableObject scriptableO
152143
return node;
153144
}
154145

155-
static string GetClassName(AnimationWindowSelectionItem selectionItem, EditorCurveBinding binding)
146+
static string GetClassName(EditorCurveBinding binding)
156147
{
157-
if (selectionItem.rootGameObject != null)
148+
if (AddCurvesPopup.s_State.activeRootGameObject != null)
158149
{
159-
Object target = AnimationUtility.GetAnimatedObject(selectionItem.rootGameObject, binding);
150+
Object target = AnimationUtility.GetAnimatedObject(AddCurvesPopup.s_State.activeRootGameObject, binding);
160151
if (target)
161152
return ObjectNames.GetInspectorTitle(target);
162153
}
163154

164155
return binding.type.Name;
165156
}
166157

167-
static Texture2D GetIcon(AnimationWindowSelectionItem selectionItem, EditorCurveBinding binding)
158+
static Texture2D GetIcon(EditorCurveBinding binding)
168159
{
169-
if (selectionItem.rootGameObject != null)
160+
if (AddCurvesPopup.s_State.activeRootGameObject != null)
170161
{
171-
return AssetPreview.GetMiniThumbnail(AnimationUtility.GetAnimatedObject(selectionItem.rootGameObject, binding));
162+
return AssetPreview.GetMiniThumbnail(AnimationUtility.GetAnimatedObject(AddCurvesPopup.s_State.activeRootGameObject, binding));
172163
}
173-
else if (selectionItem.scriptableObject != null)
164+
else if (AddCurvesPopup.s_State.activeScriptableObject != null)
174165
{
175-
return AssetPreview.GetMiniThumbnail(selectionItem.scriptableObject);
166+
return AssetPreview.GetMiniThumbnail(AddCurvesPopup.s_State.activeScriptableObject);
176167
}
177168

178169
return null;
179170
}
180171

181-
private TreeViewItem AddAnimatableObjectToHierarchy(AnimationWindowSelectionItem selectionItem, EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
172+
private TreeViewItem AddAnimatableObjectToHierarchy(EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
182173
{
183-
TreeViewItem node = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(selectionItem, curveBindings[0]));
184-
node.icon = GetIcon(selectionItem, curveBindings[0]);
174+
TreeViewItem node = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(curveBindings[0]));
175+
node.icon = GetIcon(curveBindings[0]);
185176

186177
List<TreeViewItem> childNodes = new List<TreeViewItem>();
187178
List<EditorCurveBinding> singlePropertyBindings = new List<EditorCurveBinding>();
@@ -195,7 +186,7 @@ private TreeViewItem AddAnimatableObjectToHierarchy(AnimationWindowSelectionItem
195186
// We expect curveBindings to come sorted by propertyname
196187
if (i == curveBindings.Length - 1 || AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(curveBinding.propertyName))
197188
{
198-
TreeViewItem newNode = CreateNode(selectionItem, singlePropertyBindings.ToArray(), node);
189+
TreeViewItem newNode = CreateNode(singlePropertyBindings.ToArray(), node);
199190
if (newNode != null)
200191
childNodes.Add(newNode);
201192
singlePropertyBindings.Clear();
@@ -208,9 +199,9 @@ private TreeViewItem AddAnimatableObjectToHierarchy(AnimationWindowSelectionItem
208199
return node;
209200
}
210201

211-
private TreeViewItem CreateNode(AnimationWindowSelectionItem selectionItem, EditorCurveBinding[] curveBindings, TreeViewItem parentNode)
202+
private TreeViewItem CreateNode(EditorCurveBinding[] curveBindings, TreeViewItem parentNode)
212203
{
213-
var node = new AddCurvesPopupPropertyNode(parentNode, selectionItem, curveBindings);
204+
var node = new AddCurvesPopupPropertyNode(parentNode, curveBindings);
214205

215206
// For RectTransform.position we only want .z
216207
if (AnimationWindowUtility.IsRectTransformPosition(node.curveBindings[0]))
@@ -244,13 +235,11 @@ public AddCurvesPopupObjectNode(TreeViewItem parent, string path, string classNa
244235

245236
internal class AddCurvesPopupPropertyNode : TreeViewItem
246237
{
247-
public AnimationWindowSelectionItem selectionItem;
248238
public EditorCurveBinding[] curveBindings;
249239

250-
public AddCurvesPopupPropertyNode(TreeViewItem parent, AnimationWindowSelectionItem selectionItem, EditorCurveBinding[] curveBindings)
240+
public AddCurvesPopupPropertyNode(TreeViewItem parent, EditorCurveBinding[] curveBindings)
251241
: base(curveBindings[0].GetHashCode(), parent.depth + 1, parent, AnimationWindowUtility.NicifyPropertyGroupName(curveBindings[0].type, AnimationWindowUtility.GetPropertyGroupName(curveBindings[0].propertyName)))
252242
{
253-
this.selectionItem = selectionItem;
254243
this.curveBindings = curveBindings;
255244
}
256245

Editor/Mono/Animation/AnimationWindow/AnimEditor.cs

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,16 @@ static private Color inRangeColor
102102

103103
public AnimationWindowState state { get { return m_State; } }
104104

105-
public AnimationWindowSelection selection
105+
public AnimationWindowSelectionItem selection
106106
{
107107
get
108108
{
109109
return m_State.selection;
110110
}
111-
}
112-
113-
public AnimationWindowSelectionItem selectedItem
114-
{
115-
get
116-
{
117-
return m_State.selectedItem;
118-
}
119111

120112
set
121113
{
122-
m_State.selectedItem = value;
114+
m_State.selection = value;
123115
}
124116
}
125117

@@ -387,7 +379,6 @@ public void OnDestroy()
387379

388380
public void OnSelectionChanged()
389381
{
390-
m_State.OnSelectionChanged();
391382
triggerFraming = true; // Framing of clip can only be done after Layout. Here we just order it to happen later on.
392383
Repaint();
393384
}
@@ -458,7 +449,7 @@ private void SetupWizardOnGUI(Rect position)
458449
if (AnimationWindowUtility.InitializeGameobjectForAnimation(m_State.activeGameObject))
459450
{
460451
Component animationPlayer = AnimationWindowUtility.GetClosestAnimationPlayerComponentInParents(m_State.activeGameObject.transform);
461-
m_State.selection.UpdateClip(m_State.selectedItem, AnimationUtility.GetAnimationClips(animationPlayer.gameObject)[0]);
452+
m_State.activeAnimationClip = AnimationUtility.GetAnimationClips(animationPlayer.gameObject)[0];
462453

463454
// Selection has changed, bail out now.
464455
EditorGUIUtility.ExitGUI();
@@ -483,7 +474,7 @@ private void EventLineOnGUI(Rect eventsRect)
483474
eventsRect.width -= kSliderThickness;
484475
GUI.Label(eventsRect, GUIContent.none, AnimationWindowStyles.eventBackground);
485476

486-
using (new EditorGUI.DisabledScope(m_State.selectedItem == null || !m_State.selectedItem.animationIsEditable))
477+
using (new EditorGUI.DisabledScope(!selection.animationIsEditable))
487478
{
488479
m_Events.EventLineGUI(eventsRect, m_State);
489480
}
@@ -521,9 +512,7 @@ private void HierarchyOnGUI()
521512

522513
private void FrameRateInputFieldOnGUI()
523514
{
524-
var selectedItem = m_State.selectedItem;
525-
526-
using (new EditorGUI.DisabledScope(selectedItem == null || !selectedItem.animationIsEditable))
515+
using (new EditorGUI.DisabledScope(!selection.animationIsEditable))
527516
{
528517
GUILayout.Label(AnimationWindowStyles.samples, AnimationWindowStyles.toolbarLabel);
529518

@@ -637,22 +626,16 @@ private void TimeRulerOnGUI(Rect timeRulerRect)
637626

638627
private void AddEventButtonOnGUI()
639628
{
640-
var selectedItem = m_State.selectedItem;
641-
if (selectedItem != null)
629+
using (new EditorGUI.DisabledScope(!selection.animationIsEditable))
642630
{
643-
using (new EditorGUI.DisabledScope(!selectedItem.animationIsEditable))
644-
{
645-
if (GUILayout.Button(AnimationWindowStyles.addEventContent, EditorStyles.toolbarButton))
646-
m_Events.AddEvent(m_State.currentTime - selectedItem.timeOffset, selectedItem.rootGameObject, selectedItem.animationClip);
647-
}
631+
if (GUILayout.Button(AnimationWindowStyles.addEventContent, EditorStyles.toolbarButton))
632+
m_Events.AddEvent(m_State.currentTime, selection.rootGameObject, selection.animationClip);
648633
}
649634
}
650635

651636
private void AddKeyframeButtonOnGUI()
652637
{
653-
bool animationIsEditable = m_State.selection.Find(selectedItem => selectedItem.animationIsEditable);
654-
655-
using (new EditorGUI.DisabledScope(!animationIsEditable))
638+
using (new EditorGUI.DisabledScope(!selection.animationIsEditable))
656639
{
657640
if (GUILayout.Button(AnimationWindowStyles.addKeyframeContent, EditorStyles.toolbarButton))
658641
{
@@ -733,7 +716,7 @@ private void LinkOptionsOnGUI()
733716
if (GUILayout.Toggle(true, AnimationWindowStyles.sequencerLinkContent, EditorStyles.toolbarButton) == false)
734717
{
735718
m_State.linkedWithSequencer = false;
736-
m_State.selection.Clear();
719+
m_State.selection = null;
737720

738721
// Layout has changed, bail out now.
739722
EditorGUIUtility.ExitGUI();
@@ -995,9 +978,9 @@ private void SynchronizeLayout()
995978
m_HorizontalSplitter.realSizes[1] = (int)Mathf.Min(m_Position.width - m_HorizontalSplitter.realSizes[0], m_HorizontalSplitter.realSizes[1]);
996979

997980
// Synchronize frame rate
998-
if ((selectedItem != null) && (selectedItem.animationClip != null))
981+
if (selection.animationClip != null)
999982
{
1000-
m_State.frameRate = selectedItem.animationClip.frameRate;
983+
m_State.frameRate = selection.animationClip.frameRate;
1001984
}
1002985
else
1003986
{
@@ -1262,8 +1245,6 @@ private void InitializeNonserializedValues()
12621245

12631246
m_State.onStartLiveEdit += OnStartLiveEdit;
12641247
m_State.onEndLiveEdit += OnEndLiveEdit;
1265-
1266-
m_State.selection.onSelectionChanged += OnSelectionChanged;
12671248
}
12681249
}
12691250
}

Editor/Mono/Animation/AnimationWindow/AnimationClipSelectionItem.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ internal class AnimationClipSelectionItem : AnimationWindowSelectionItem
1515
public static AnimationClipSelectionItem Create(AnimationClip animationClip, Object sourceObject)
1616
{
1717
AnimationClipSelectionItem selectionItem = CreateInstance(typeof(AnimationClipSelectionItem)) as AnimationClipSelectionItem;
18-
selectionItem.hideFlags = HideFlags.HideAndDontSave;
1918

2019
selectionItem.gameObject = sourceObject as GameObject;
2120
selectionItem.scriptableObject = sourceObject as ScriptableObject;
2221
selectionItem.animationClip = animationClip;
23-
selectionItem.timeOffset = 0.0f;
2422
selectionItem.id = 0; // no need for id since there's only one item in selection.
2523

2624
return selectionItem;

0 commit comments

Comments
 (0)