Skip to content

Commit f8fe858

Browse files
author
Unity Technologies
committed
Unity 2020.2.0a16 C# reference source code
1 parent 6a14d35 commit f8fe858

File tree

215 files changed

+4781
-7223
lines changed

Some content is hidden

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

215 files changed

+4781
-7223
lines changed

Editor/Mono/Animation/AnimationWindow/AnimationWindow.cs

Lines changed: 170 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44

55
using System;
66
using UnityEngine;
7-
using UnityEditor;
8-
using System.Collections;
97
using System.Collections.Generic;
108
using UnityEditorInternal;
119
using Object = UnityEngine.Object;
1210

1311
namespace UnityEditor
1412
{
1513
[EditorWindowTitle(title = "Animation", useTypeNameAsIconName = true)]
16-
internal class AnimationWindow : EditorWindow, IHasCustomMenu
14+
public sealed class AnimationWindow : EditorWindow, IHasCustomMenu
1715
{
1816
// Active Animation windows
1917
private static List<AnimationWindow> s_AnimationWindows = new List<AnimationWindow>();
20-
public static List<AnimationWindow> GetAllAnimationWindows() { return s_AnimationWindows; }
18+
internal static List<AnimationWindow> GetAllAnimationWindows() { return s_AnimationWindows; }
2119

2220
private AnimEditor m_AnimEditor;
2321

@@ -50,15 +48,167 @@ internal AnimationWindowState state
5048
}
5149
}
5250

53-
public void ForceRefresh()
51+
public AnimationClip animationClip
52+
{
53+
get
54+
{
55+
if (m_AnimEditor != null)
56+
{
57+
return m_AnimEditor.state.activeAnimationClip;
58+
}
59+
return null;
60+
}
61+
set
62+
{
63+
if (m_AnimEditor != null)
64+
{
65+
m_AnimEditor.state.activeAnimationClip = value;
66+
}
67+
}
68+
}
69+
70+
public bool previewing
71+
{
72+
get
73+
{
74+
if (m_AnimEditor != null)
75+
{
76+
return m_AnimEditor.state.previewing;
77+
}
78+
return false;
79+
}
80+
set
81+
{
82+
if (m_AnimEditor != null)
83+
{
84+
if (value)
85+
m_AnimEditor.state.StartPreview();
86+
else
87+
m_AnimEditor.state.StopPreview();
88+
}
89+
}
90+
}
91+
92+
public bool canPreview
93+
{
94+
get
95+
{
96+
if (m_AnimEditor != null)
97+
{
98+
return m_AnimEditor.state.canPreview;
99+
}
100+
101+
return false;
102+
}
103+
}
104+
105+
public bool recording
106+
{
107+
get
108+
{
109+
if (m_AnimEditor != null)
110+
{
111+
return m_AnimEditor.state.recording;
112+
}
113+
return false;
114+
}
115+
set
116+
{
117+
if (m_AnimEditor != null)
118+
{
119+
if (value)
120+
m_AnimEditor.state.StartRecording();
121+
else
122+
m_AnimEditor.state.StopRecording();
123+
}
124+
}
125+
}
126+
127+
public bool canRecord
128+
{
129+
get
130+
{
131+
if (m_AnimEditor != null)
132+
{
133+
return m_AnimEditor.state.canRecord;
134+
}
135+
136+
return false;
137+
}
138+
}
139+
140+
public bool playing
141+
{
142+
get
143+
{
144+
if (m_AnimEditor != null)
145+
{
146+
return m_AnimEditor.state.playing;
147+
}
148+
return false;
149+
}
150+
set
151+
{
152+
if (m_AnimEditor != null)
153+
{
154+
if (value)
155+
m_AnimEditor.state.StartPlayback();
156+
else
157+
m_AnimEditor.state.StopPlayback();
158+
}
159+
}
160+
}
161+
162+
public float time
163+
{
164+
get
165+
{
166+
if (m_AnimEditor != null)
167+
{
168+
return m_AnimEditor.state.currentTime;
169+
}
170+
return 0.0f;
171+
}
172+
set
173+
{
174+
if (m_AnimEditor != null)
175+
{
176+
m_AnimEditor.state.currentTime = value;
177+
}
178+
}
179+
}
180+
181+
public int frame
182+
{
183+
get
184+
{
185+
if (m_AnimEditor != null)
186+
{
187+
return m_AnimEditor.state.currentFrame;
188+
}
189+
return 0;
190+
}
191+
set
192+
{
193+
if (m_AnimEditor != null)
194+
{
195+
m_AnimEditor.state.currentFrame = value;
196+
}
197+
}
198+
}
199+
200+
private AnimationWindow()
201+
{}
202+
203+
internal void ForceRefresh()
54204
{
55205
if (m_AnimEditor != null)
56206
{
57207
m_AnimEditor.state.ForceRefresh();
58208
}
59209
}
60210

61-
public void OnEnable()
211+
void OnEnable()
62212
{
63213
if (m_AnimEditor == null)
64214
{
@@ -77,28 +227,28 @@ public void OnEnable()
77227
Undo.undoRedoPerformed += UndoRedoPerformed;
78228
}
79229

80-
public void OnDisable()
230+
void OnDisable()
81231
{
82232
s_AnimationWindows.Remove(this);
83233
m_AnimEditor.OnDisable();
84234

85235
Undo.undoRedoPerformed -= UndoRedoPerformed;
86236
}
87237

88-
public void OnDestroy()
238+
void OnDestroy()
89239
{
90240
DestroyImmediate(m_AnimEditor);
91241
}
92242

93-
public void Update()
243+
void Update()
94244
{
95245
if (m_AnimEditor == null)
96246
return;
97247

98248
m_AnimEditor.Update();
99249
}
100250

101-
public void OnGUI()
251+
void OnGUI()
102252
{
103253
if (m_AnimEditor == null)
104254
return;
@@ -107,7 +257,7 @@ public void OnGUI()
107257
m_AnimEditor.OnAnimEditorGUI(this, position);
108258
}
109259

110-
public void OnSelectionChange()
260+
internal void OnSelectionChange()
111261
{
112262
if (m_AnimEditor == null)
113263
return;
@@ -148,18 +298,18 @@ public void OnSelectionChange()
148298
}
149299
}
150300

151-
public void OnFocus()
301+
void OnFocus()
152302
{
153303
OnSelectionChange();
154304
}
155305

156-
public void OnControllerChange()
306+
internal void OnControllerChange()
157307
{
158308
// Refresh selectedItem to update selected clips.
159309
OnSelectionChange();
160310
}
161311

162-
public void OnLostFocus()
312+
void OnLostFocus()
163313
{
164314
if (m_AnimEditor != null)
165315
m_AnimEditor.OnLostFocus();
@@ -177,12 +327,12 @@ static bool OnOpenAsset(int instanceID, int line)
177327
return false;
178328
}
179329

180-
public bool EditGameObject(GameObject gameObject)
330+
internal bool EditGameObject(GameObject gameObject)
181331
{
182332
return EditGameObjectInternal(gameObject, (IAnimationWindowControl)null);
183333
}
184334

185-
public bool EditAnimationClip(AnimationClip animationClip)
335+
internal bool EditAnimationClip(AnimationClip animationClip)
186336
{
187337
if (state.linkedWithSequencer == true)
188338
return false;
@@ -191,14 +341,14 @@ public bool EditAnimationClip(AnimationClip animationClip)
191341
return true;
192342
}
193343

194-
public bool EditSequencerClip(AnimationClip animationClip, Object sourceObject, IAnimationWindowControl controlInterface)
344+
internal bool EditSequencerClip(AnimationClip animationClip, Object sourceObject, IAnimationWindowControl controlInterface)
195345
{
196346
EditAnimationClipInternal(animationClip, sourceObject, controlInterface);
197347
state.linkedWithSequencer = true;
198348
return true;
199349
}
200350

201-
public void UnlinkSequencer()
351+
internal void UnlinkSequencer()
202352
{
203353
if (state.linkedWithSequencer)
204354
{
@@ -246,7 +396,7 @@ private void EditAnimationClipInternal(AnimationClip animationClip, Object sourc
246396
m_AnimEditor.OnSelectionUpdated();
247397
}
248398

249-
protected virtual void ShowButton(Rect r)
399+
void ShowButton(Rect r)
250400
{
251401
if (m_LockButtonStyle == null)
252402
m_LockButtonStyle = "IN LockButton";
@@ -307,7 +457,7 @@ private void UndoRedoPerformed()
307457
Repaint();
308458
}
309459

310-
public virtual void AddItemsToMenu(GenericMenu menu)
460+
public void AddItemsToMenu(GenericMenu menu)
311461
{
312462
m_LockTracker.AddItemsToMenu(menu, m_AnimEditor.stateDisabled);
313463
}

0 commit comments

Comments
 (0)