Skip to content

Commit 3cfc6c4

Browse files
author
Unity Technologies
committed
Unity 2018.2.0b1 C# reference source code
1 parent fcaa42c commit 3cfc6c4

File tree

86 files changed

+632
-1198
lines changed

Some content is hidden

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

86 files changed

+632
-1198
lines changed

Editor/Mono/Animation/AnimationWindow/AnimEditor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@ private void AddEventButtonOnGUI()
633633

634634
private void AddKeyframeButtonOnGUI()
635635
{
636-
using (new EditorGUI.DisabledScope(!selection.animationIsEditable))
636+
bool canAddKey = selection.animationIsEditable && m_State.allCurves.Count != 0;
637+
using (new EditorGUI.DisabledScope(!canAddKey))
637638
{
638639
if (GUILayout.Button(AnimationWindowStyles.addKeyframeContent, EditorStyles.toolbarButton))
639640
{

Editor/Mono/Animation/AnimationWindow/AnimationWindowHierarchyGUI.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ internal class AnimationWindowHierarchyGUI : TreeViewGUI
3232

3333
private const float k_RowRightOffset = 10;
3434
private const float k_ValueFieldDragWidth = 15;
35-
private const float k_ValueFieldWidth = 50;
36-
private const float k_ValueFieldOffsetFromRightSide = 75;
35+
private const float k_ValueFieldWidth = 80;
36+
private const float k_ValueFieldOffsetFromRightSide = 90;
3737
private const float k_ColorIndicatorTopMargin = 3;
3838
public const float k_DopeSheetRowHeight = EditorGUI.kSingleLineHeight;
3939
public const float k_DopeSheetRowHeightTall = k_DopeSheetRowHeight * 2f;
@@ -265,16 +265,6 @@ private void DoIconAndName(Rect rect, AnimationWindowHierarchyNode node, bool se
265265
if (node.curves.Length > 0)
266266
{
267267
AnimationWindowSelectionItem selectionBinding = node.curves[0].selectionBinding;
268-
if (selectionBinding != null)
269-
{
270-
if (selectionBinding.rootGameObject != null)
271-
{
272-
Transform transform = selectionBinding.rootGameObject.transform.Find(node.path);
273-
if (transform == null)
274-
isLeftOverCurve = true;
275-
}
276-
}
277-
278268
string gameObjectName = GetGameObjectName(selectionBinding != null ? selectionBinding.rootGameObject : null, node.path);
279269
nodePrefix = string.IsNullOrEmpty(gameObjectName) ? "" : gameObjectName + " : ";
280270
}
@@ -373,7 +363,7 @@ private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row)
373363
valueFieldDragRect,
374364
id,
375365
value,
376-
EditorGUI.kFloatFieldFormatString,
366+
"g5",
377367
m_AnimationSelectionTextField,
378368
true);
379369
if (enterInTextField)

Editor/Mono/Animation/AnimationWindow/CurveEditorWindow.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static internal Keyframe[] GetLinearKeys()
323323
Keyframe[] keys = new Keyframe[2];
324324
keys[0] = new Keyframe(0, 0, 1, 1);
325325
keys[1] = new Keyframe(1, 1, 1, 1);
326-
SetSmoothEditable(ref keys);
326+
SetSmoothEditable(ref keys, TangentMode.Auto);
327327
return keys;
328328
}
329329

@@ -332,7 +332,7 @@ static internal Keyframe[] GetLinearMirrorKeys()
332332
Keyframe[] keys = new Keyframe[2];
333333
keys[0] = new Keyframe(0, 1, -1, -1);
334334
keys[1] = new Keyframe(1, 0, -1, -1);
335-
SetSmoothEditable(ref keys);
335+
SetSmoothEditable(ref keys, TangentMode.Auto);
336336
return keys;
337337
}
338338

@@ -341,7 +341,7 @@ static internal Keyframe[] GetEaseInKeys()
341341
Keyframe[] keys = new Keyframe[2];
342342
keys[0] = new Keyframe(0, 0, 0, 0);
343343
keys[1] = new Keyframe(1, 1, 2, 2);
344-
SetSmoothEditable(ref keys);
344+
SetSmoothEditable(ref keys, TangentMode.Free);
345345
return keys;
346346
}
347347

@@ -350,7 +350,7 @@ static internal Keyframe[] GetEaseInMirrorKeys()
350350
Keyframe[] keys = new Keyframe[2];
351351
keys[0] = new Keyframe(0, 1, -2, -2);
352352
keys[1] = new Keyframe(1, 0, 0, 0);
353-
SetSmoothEditable(ref keys);
353+
SetSmoothEditable(ref keys, TangentMode.Free);
354354
return keys;
355355
}
356356

@@ -359,7 +359,7 @@ static internal Keyframe[] GetEaseOutKeys()
359359
Keyframe[] keys = new Keyframe[2];
360360
keys[0] = new Keyframe(0, 0, 2, 2);
361361
keys[1] = new Keyframe(1, 1, 0, 0);
362-
SetSmoothEditable(ref keys);
362+
SetSmoothEditable(ref keys, TangentMode.Free);
363363
return keys;
364364
}
365365

@@ -368,7 +368,7 @@ static internal Keyframe[] GetEaseOutMirrorKeys()
368368
Keyframe[] keys = new Keyframe[2];
369369
keys[0] = new Keyframe(0, 1, 0, 0);
370370
keys[1] = new Keyframe(1, 0, -2, -2);
371-
SetSmoothEditable(ref keys);
371+
SetSmoothEditable(ref keys, TangentMode.Free);
372372
return keys;
373373
}
374374

@@ -377,7 +377,7 @@ static internal Keyframe[] GetEaseInOutKeys()
377377
Keyframe[] keys = new Keyframe[2];
378378
keys[0] = new Keyframe(0, 0, 0, 0);
379379
keys[1] = new Keyframe(1, 1, 0, 0);
380-
SetSmoothEditable(ref keys);
380+
SetSmoothEditable(ref keys, TangentMode.Free);
381381
return keys;
382382
}
383383

@@ -386,7 +386,7 @@ static internal Keyframe[] GetEaseInOutMirrorKeys()
386386
Keyframe[] keys = new Keyframe[2];
387387
keys[0] = new Keyframe(0, 1, 0, 0);
388388
keys[1] = new Keyframe(1, 0, 0, 0);
389-
SetSmoothEditable(ref keys);
389+
SetSmoothEditable(ref keys, TangentMode.Free);
390390
return keys;
391391
}
392392

@@ -395,17 +395,17 @@ static internal Keyframe[] GetConstantKeys(float value)
395395
Keyframe[] keys = new Keyframe[2];
396396
keys[0] = new Keyframe(0, value, 0, 0);
397397
keys[1] = new Keyframe(1, value, 0, 0);
398-
SetSmoothEditable(ref keys);
398+
SetSmoothEditable(ref keys, TangentMode.Auto);
399399
return keys;
400400
}
401401

402-
static internal void SetSmoothEditable(ref Keyframe[] keys)
402+
static internal void SetSmoothEditable(ref Keyframe[] keys, TangentMode tangentMode)
403403
{
404404
for (int i = 0; i < keys.Length; i++)
405405
{
406406
AnimationUtility.SetKeyBroken(ref keys[i], false);
407-
AnimationUtility.SetKeyLeftTangentMode(ref keys[i], TangentMode.Free);
408-
AnimationUtility.SetKeyRightTangentMode(ref keys[i], TangentMode.Free);
407+
AnimationUtility.SetKeyLeftTangentMode(ref keys[i], tangentMode);
408+
AnimationUtility.SetKeyRightTangentMode(ref keys[i], tangentMode);
409409
}
410410
}
411411

Editor/Mono/AssetDatabase/AssetDatabase.bindings.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,16 @@ public static void ForceReserializeAssets(IEnumerable<string> assetPaths, ForceR
7272
[FreeFunction("AssetDatabase::GetGUIDAndLocalIdentifierInFile")]
7373
extern private static bool GetGUIDAndLocalIdentifierInFile(int instanceID, out GUID outGuid, out long outLocalId);
7474

75-
public static bool TryGetGUIDAndLocalFileIdentifier(UnityEngine.Object obj, out string guid, out int localId)
75+
public static bool TryGetGUIDAndLocalFileIdentifier(UnityEngine.Object obj, out string guid, out long localId)
7676
{
7777
return TryGetGUIDAndLocalFileIdentifier(obj.GetInstanceID(), out guid, out localId);
7878
}
7979

80-
public static bool TryGetGUIDAndLocalFileIdentifier(int instanceID, out string guid, out int localId)
80+
public static bool TryGetGUIDAndLocalFileIdentifier(int instanceID, out string guid, out long localId)
8181
{
8282
GUID uguid;
83-
long fileid;
84-
bool res = GetGUIDAndLocalIdentifierInFile(instanceID, out uguid, out fileid);
83+
bool res = GetGUIDAndLocalIdentifierInFile(instanceID, out uguid, out localId);
8584
guid = uguid.ToString();
86-
localId = (int)fileid;
8785
return res;
8886
}
8987

Editor/Mono/AssetStore/AssetStoreWindow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static void OpenURL(string url)
3030
}
3131

3232
// Use this for initialization
33+
[MenuItem("Window/General/Asset Store %9", false, 20)]
3334
public static AssetStoreWindow Init()
3435
{
3536
AssetStoreWindow window = EditorWindow.GetWindow<AssetStoreWindow>(typeof(SceneView));

Editor/Mono/BuildPipeline/CodeStrippingUtils.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ public static void GenerateDependencies(string strippedAssemblyDir, string icall
180180
}
181181
}
182182

183+
if (nativeClasses != null)
184+
RemoveClassesFromRemovedModules(nativeClasses, nativeModules);
185+
183186
AssemblyReferenceChecker checker = new AssemblyReferenceChecker();
184187
checker.CollectReferencesFromRoots(strippedAssemblyDir, userAssemblies, true, 0.0f, true);
185188

@@ -226,25 +229,24 @@ public static void ApplyManualStrippingOverrides(HashSet<UnityType> nativeClasse
226229
{
227230
nativeModules.Remove(module);
228231

229-
if (nativeClasses != null)
230-
{
231-
var moduleClasses = ModuleMetadata.GetModuleTypes(module);
232-
foreach (var klass in moduleClasses)
233-
{
234-
if (nativeClasses.Contains(klass))
235-
{
236-
nativeClasses.Remove(klass);
237-
}
238-
}
239-
}
240-
241232
if (strippingInfo != null)
242233
strippingInfo.modules.Remove(StrippingInfo.ModuleName(module));
243234
}
244235
}
245236
}
246237
}
247238

239+
static void RemoveClassesFromRemovedModules(HashSet<UnityType> nativeClasses, HashSet<string> nativeModules)
240+
{
241+
HashSet<UnityType> allModuleClasses = new HashSet<UnityType>();
242+
foreach (var module in nativeModules)
243+
{
244+
foreach (var klass in ModuleMetadata.GetModuleTypes(module))
245+
allModuleClasses.Add(klass);
246+
}
247+
nativeClasses.RemoveWhere(klass => !allModuleClasses.Contains(klass));
248+
}
249+
248250
public static string GetModuleWhitelist(string module, string moduleStrippingInformationFolder)
249251
{
250252
return Paths.Combine(moduleStrippingInformationFolder, module + ".xml");

Editor/Mono/BuildPlayerWindowBuildMethods.cs

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

5-
using UnityEditor;
65
using UnityEditor.Modules;
76
using UnityEditor.Build;
87
using UnityEngine;
98
using UnityEditorInternal;
109
using UnityEditor.Experimental;
10+
using UnityEditor.Scripting.ScriptCompilation;
1111
using System.Collections;
12-
using System.Collections.Generic;
1312
using System.IO;
1413
using System;
15-
using UnityEditor.Build.Reporting;
1614
using UnityEditor.Connect;
1715

1816
namespace UnityEditor
@@ -72,6 +70,12 @@ public static void RegisterBuildPlayerHandler(Action<BuildPlayerOptions> func)
7270
/// <param name="defaultBuildOptions"></param>
7371
static void CallBuildMethods(bool askForBuildLocation, BuildOptions defaultBuildOptions)
7472
{
73+
if (EditorCompilationInterface.IsCompiling())
74+
{
75+
Debug.LogWarning("Cannot build player while editor is compiling scripts.");
76+
return;
77+
}
78+
7579
// One build at a time!
7680
if (m_Building)
7781
return;

Editor/Mono/Collab/CollabHistoryWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ internal class CollabHistoryWindow : EditorWindow, ICollabHistoryWindow
2020
const string kWindowTitle = "Collab History";
2121
const string kServiceUrl = "developer.cloud.unity3d.com";
2222

23-
[MenuItem("Window/Collab History", false, 2011)]
23+
[MenuItem("Window/Asset Management/Collab History", false, 1)]
2424
public static void ShowHistoryWindow()
2525
{
2626
EditorWindow.GetWindow<CollabHistoryWindow>(kWindowTitle);
2727
}
2828

29-
[MenuItem("Window/Collab History", true)]
29+
[MenuItem("Window/Asset Management/Collab History", true)]
3030
public static bool ValidateShowHistoryWindow()
3131
{
3232
return Collab.instance.IsCollabEnabledForCurrentProject();

Editor/Mono/Collab/CollabToolbarWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public static void CloseToolbarWindowsImmediately()
5757
window.Close();
5858
}
5959

60-
[MenuItem("Window/Collab Toolbar", false /*IsValidateFunction*/, 2011, true /* IsInternalMenu */)]
60+
[MenuItem("Window/Asset Management/Collab Toolbar", false /*IsValidateFunction*/, 2, true /* IsInternalMenu */)]
6161
public static CollabToolbarWindow ShowToolbarWindow()
6262
{
6363
//Create a new window if it do not exist
6464
return GetWindow<CollabToolbarWindow>(false, kWindowName) as CollabToolbarWindow;
6565
}
6666

67-
[MenuItem("Window/Collab Toolbar", true /*IsValidateFunction*/)]
67+
[MenuItem("Window/Asset Management/Collab Toolbar", true /*IsValidateFunction*/)]
6868
public static bool ValidateShowToolbarWindow()
6969
{
7070
return true;

Editor/Mono/ContainerWindow.cs

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

5+
using System;
56
using UnityEngine;
67
using System.Collections.Generic;
78
using System.Runtime.InteropServices;
@@ -49,7 +50,7 @@ public ContainerWindow()
4950
m_PixelRect = new Rect(0, 0, 400, 300);
5051
}
5152

52-
private void __internalAwake()
53+
internal void __internalAwake()
5354
{
5455
hideFlags = HideFlags.DontSave;
5556
}
@@ -109,7 +110,7 @@ public void Show(ShowMode showMode, bool loadPosition, bool displayImmediately)
109110
Internal_BringLiveAfterCreation(displayImmediately, true);
110111

111112
// Window could be killed by now in user callbacks...
112-
if (this == null)
113+
if (!this)
113114
return;
114115

115116
// Fit window to screen - needs to be done after bringing the window live
@@ -158,13 +159,15 @@ internal void InternalCloseWindow()
158159
public void Close()
159160
{
160161
Save();
161-
InternalClose();
162-
DestroyImmediate(this, true);
162+
163+
// Guard against destroy window or window in the process of being destroyed.
164+
if (this && m_WindowPtr.m_IntPtr != IntPtr.Zero)
165+
InternalClose();
163166
}
164167

165168
internal bool IsNotDocked()
166169
{
167-
return ( // halleluja
170+
return ( // hallelujah
168171

169172
(m_ShowMode == (int)ShowMode.Utility || m_ShowMode == (int)ShowMode.AuxWindow) ||
170173

@@ -193,8 +196,8 @@ private string NotDockedWindowID()
193196
return (m_ShowMode == (int)ShowMode.Utility || m_ShowMode == (int)ShowMode.AuxWindow) ? v.actualView.GetType().ToString()
194197
: ((DockArea)rootView.children[0]).m_Panes[0].GetType().ToString();
195198
}
196-
else
197-
return null;
199+
200+
return null;
198201
}
199202

200203
public void Save()

0 commit comments

Comments
 (0)