Skip to content

Commit 170d37a

Browse files
author
Unity Technologies
committed
Unity 2018.1.0b7 C# reference source code
1 parent f6dc11b commit 170d37a

32 files changed

+289
-127
lines changed

Editor/Mono/Animation/AnimationWindow/CurveMenuManager.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@ public void AddTangentMenuItems(GenericMenu menu, List<KeyIdentifier> keyList)
129129
menu.AddItem(EditorGUIUtility.TrTextContent("Left Tangent/Linear"), allLeftLinear, SetLeftLinear, keyList);
130130
menu.AddItem(EditorGUIUtility.TrTextContent("Left Tangent/Constant"), allLeftConstant, SetLeftConstant, keyList);
131131
menu.AddItem(EditorGUIUtility.TrTextContent("Left Tangent/Weighted"), allLeftWeighted, ToggleLeftWeighted, keyList);
132+
menu.AddItem(EditorGUIUtility.TrTextContent("Right Tangent/Free"), allRightFree, SetRightEditable, keyList);
132133
menu.AddItem(EditorGUIUtility.TrTextContent("Right Tangent/Linear"), allRightLinear, SetRightLinear, keyList);
133134
menu.AddItem(EditorGUIUtility.TrTextContent("Right Tangent/Constant"), allRightConstant, SetRightConstant, keyList);
134-
menu.AddItem(EditorGUIUtility.TrTextContent("Both Tangents/Free"), allRightFree && allLeftFree, SetBothEditable, keyList);
135135
menu.AddItem(EditorGUIUtility.TrTextContent("Right Tangent/Weighted"), allRightWeighted, ToggleRightWeighted, keyList);
136+
menu.AddItem(EditorGUIUtility.TrTextContent("Both Tangents/Free"), allRightFree && allLeftFree, SetBothEditable, keyList);
137+
menu.AddItem(EditorGUIUtility.TrTextContent("Both Tangents/Linear"), allRightLinear && allLeftLinear, SetBothLinear, keyList);
136138
menu.AddItem(EditorGUIUtility.TrTextContent("Both Tangents/Constant"), allRightConstant && allLeftConstant, SetBothConstant, keyList);
137139
menu.AddItem(EditorGUIUtility.TrTextContent("Both Tangents/Weighted"), allRightWeighted && allLeftWeighted, ToggleBothWeighted, keyList);
138140
}
@@ -147,12 +149,15 @@ public void AddTangentMenuItems(GenericMenu menu, List<KeyIdentifier> keyList)
147149
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Left Tangent/Free"));
148150
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Left Tangent/Linear"));
149151
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Left Tangent/Constant"));
152+
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Left Tangent/Weighted"));
150153
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Right Tangent/Free"));
151154
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Right Tangent/Linear"));
152155
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Right Tangent/Constant"));
156+
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Right Tangent/Weighted"));
153157
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Both Tangents/Free"));
154158
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Both Tangents/Linear"));
155159
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Both Tangents/Constant"));
160+
menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Both Tangents/Weighted"));
156161
}
157162
}
158163

Editor/Mono/Animation/MaterialAnimationUtility.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ static bool ApplyMaterialModificationToAnimationRecording(PropertyModification[]
6666
undoModifications[i].previousValue = modifications[i];
6767
}
6868

69-
UndoPropertyModification[] ret = Undo.postprocessModifications(undoModifications);
70-
return (ret.Length != modifications.Length);
69+
UndoPropertyModification[] ret = Undo.InvokePostprocessModifications(undoModifications);
70+
return ret.Length != modifications.Length;
7171
}
7272

7373
static public bool OverridePropertyColor(MaterialProperty materialProp, Renderer target, out Color color)

Editor/Mono/AssemblyHelper.cs

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace UnityEditor
1717
{
1818
internal partial class AssemblyHelper
1919
{
20+
static readonly Type[] ExtendableScriptTypes = { typeof(MonoBehaviour), typeof(ScriptableObject), typeof(Experimental.AssetImporters.ScriptedImporter) };
21+
2022
// Check if assmebly internal name doesn't match file name, and show the warning.
2123
static public void CheckForAssemblyFileNameMismatch(string assemblyPath)
2224
{
@@ -50,24 +52,6 @@ static public string[] GetNamesOfAssembliesLoadedInCurrentDomain()
5052
return locations.ToArray();
5153
}
5254

53-
public static Assembly FindLoadedAssemblyWithName(string s)
54-
{
55-
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
56-
foreach (var a in assemblies)
57-
{
58-
try
59-
{
60-
if (s == System.IO.Path.GetFileNameWithoutExtension(a.Location))
61-
return a;
62-
}
63-
catch (NotSupportedException)
64-
{
65-
//we have some "dynamic" assmeblies that do not have a filename
66-
}
67-
}
68-
return null;
69-
}
70-
7155
static public string ExtractInternalAssemblyName(string path)
7256
{
7357
try
@@ -222,55 +206,29 @@ static public bool IsUnityEngineModule(Assembly assembly)
222206
return assembly.GetCustomAttributes(typeof(UnityEngineModuleAssembly), false).Length > 0;
223207
}
224208

225-
private static bool IsTypeAUserExtendedScript(AssemblyDefinition assembly, TypeReference type)
209+
private static bool IsTypeAUserExtendedScript(TypeReference type)
226210
{
227-
if (type == null)
211+
if (type == null || type.FullName == "System.Object")
228212
return false;
229213

230-
// Early out
231-
if (type.FullName == "System.Object")
232-
return false;
233-
234-
// Look up the type in UnityEngine.dll or UnityEditor.dll
235-
Assembly builtinAssembly = null;
236-
if (type.Scope.Name == "UnityEngine" || type.Scope.Name == "UnityEngine.CoreModule")
237-
builtinAssembly = typeof(MonoBehaviour).Assembly;
238-
else if (type.Scope.Name == "UnityEditor")
239-
builtinAssembly = typeof(EditorWindow).Assembly;
240-
else if (type.Scope.Name == "UnityEngine.UI")
241-
builtinAssembly = FindLoadedAssemblyWithName("UnityEngine.UI");
242-
243-
if (builtinAssembly != null)
214+
foreach (var extendableScriptType in ExtendableScriptTypes)
244215
{
245-
// TypeReference.FullName is cached and is preferred to use, but in case of generic types it
246-
// includes generic arguments we can't use to get type from assembly.
247-
var typeName = type.IsGenericInstance ? (type.Namespace + "." + type.Name) : type.FullName;
248-
var engineType = builtinAssembly.GetType(typeName);
249-
250-
// TODO: this "list of classes" should get dynamically filled by the classes them self, thus removing dependency of this class on those classes.
251-
if (engineType != null)
252-
{
253-
if (engineType == typeof(MonoBehaviour) || engineType.IsSubclassOf(typeof(MonoBehaviour)))
254-
return true;
255-
if (engineType == typeof(ScriptableObject) || engineType.IsSubclassOf(typeof(ScriptableObject)))
256-
return true;
257-
if (engineType == typeof(Experimental.AssetImporters.ScriptedImporter) || engineType.IsSubclassOf(typeof(Experimental.AssetImporters.ScriptedImporter)))
258-
return true;
259-
}
216+
if (type.Name == extendableScriptType.Name && type.Namespace == extendableScriptType.Namespace)
217+
return true;
260218
}
261219

262-
TypeDefinition typeDefinition = null;
263220
try
264221
{
265-
typeDefinition = type.Resolve();
222+
var typeDefinition = type.Resolve();
223+
224+
if (typeDefinition != null)
225+
return IsTypeAUserExtendedScript(typeDefinition.BaseType);
266226
}
267227
catch (AssemblyResolutionException)
268228
{
269229
// just eat exception if we fail to load assembly here.
270230
// failure should be handled better in other places.
271231
}
272-
if (typeDefinition != null)
273-
return IsTypeAUserExtendedScript(assembly, typeDefinition.BaseType);
274232

275233
return false;
276234
}
@@ -308,7 +266,7 @@ public static void ExtractAllClassesThatAreUserExtendedScripts(string path, out
308266

309267
try
310268
{
311-
if (IsTypeAUserExtendedScript(assembly, baseType))
269+
if (IsTypeAUserExtendedScript(baseType))
312270
{
313271
classNames.Add(type.Name);
314272
nameSpaces.Add(type.Namespace);

Editor/Mono/BuildPipeline/MonoCrossCompile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using UnityEngine;
66
using UnityEditor;
7+
using UnityEditor.Scripting.ScriptCompilation;
78
using System.Collections;
89
using System.Collections.Generic;
910
using System.IO;
@@ -233,8 +234,7 @@ static public bool CrossCompileAOTDirectoryParallel(string crossCompilerPath, Bu
233234

234235
static bool IsDebugableAssembly(string fname)
235236
{
236-
fname = Path.GetFileName(fname);
237-
return fname.StartsWith("Assembly", StringComparison.OrdinalIgnoreCase);
237+
return EditorCompilationInterface.Instance.IsRuntimeScriptAssembly(fname);
238238
}
239239

240240
static void CrossCompileAOT(BuildTarget target, string crossCompilerAbsolutePath, string assembliesAbsoluteDirectory, CrossCompileOptions crossCompileOptions, string input, string output, string additionalOptions)

Editor/Mono/GUI/DockArea.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ protected override void OnDestroy()
9999
UnityEngine.Object.DestroyImmediate(w, true);
100100
}
101101

102+
m_Panes.Clear();
103+
102104
base.OnDestroy();
103105
}
104106

Editor/Mono/GUIDebugger/GUIViewDebuggerHelper.bindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ internal struct IMGUIInstruction
109109
public StackFrame[] stack;
110110

111111
public int typeInstructionIndex;
112+
public bool enabled;
112113
}
113114

114115
[NativeHeader("Editor/Mono/GUIDebugger/GUIViewDebuggerHelper.bindings.h")]

Editor/Mono/GUIView.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ protected virtual void OnDisable()
179179
if (imguiContainer.HasMouseCapture())
180180
MouseCaptureController.ReleaseMouseCapture();
181181
visualTree.Remove(imguiContainer);
182+
imguiContainer = null;
182183
}
183184

184185
protected virtual void OldOnGUI() {}
@@ -212,6 +213,9 @@ protected override void SetPosition(Rect newPos)
212213
protected override void OnDestroy()
213214
{
214215
Internal_Close();
216+
217+
UIElementsUtility.RemoveCachedPanel(this.GetInstanceID());
218+
215219
base.OnDestroy();
216220
}
217221

Editor/Mono/ImportSettings/AssetImporterEditor.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ public abstract class AssetImporterEditor : Editor
1414
bool m_MightHaveModified = false;
1515

1616
private Editor m_AssetEditor;
17-
internal Editor assetEditor { private get { return m_AssetEditor; } set { m_AssetEditor = value; } }
17+
// Called from ActiveEditorTracker.cpp to setup the target editor once created before Awake and OnEnable of the Editor.
18+
internal void InternalSetAssetImporterTargetEditor(Object editor)
19+
{
20+
m_AssetEditor = editor as Editor;
21+
}
1822

1923
protected internal Object[] assetTargets { get { return m_AssetEditor != null ? m_AssetEditor.targets : null; } }
2024
protected internal Object assetTarget { get { return m_AssetEditor != null ? m_AssetEditor.target : null; } }
@@ -24,7 +28,7 @@ internal override string targetTitle
2428
{
2529
get
2630
{
27-
return string.Format(L10n.Tr("{0} Import Settings"), assetEditor == null ? string.Empty : assetEditor.targetTitle);
31+
return string.Format(L10n.Tr("{0} Import Settings"), m_AssetEditor == null ? string.Empty : m_AssetEditor.targetTitle);
2832
}
2933
}
3034

@@ -34,17 +38,17 @@ internal override int referenceTargetIndex
3438
set
3539
{
3640
base.referenceTargetIndex = value;
37-
if (assetEditor != null)
38-
assetEditor.referenceTargetIndex = value;
41+
if (m_AssetEditor != null)
42+
m_AssetEditor.referenceTargetIndex = value;
3943
}
4044
}
4145

4246
internal override IPreviewable preview
4347
{
4448
get
4549
{
46-
if (useAssetDrawPreview && assetEditor != null)
47-
return assetEditor;
50+
if (useAssetDrawPreview && m_AssetEditor != null)
51+
return m_AssetEditor;
4852
// Sometimes assetEditor has gone away because of "magical" workarounds and we need to fall back to base.Preview.
4953
// See cases 597496 and 601174 for context.
5054
return base.preview;
@@ -58,8 +62,8 @@ internal override IPreviewable preview
5862
// Make the Importer use the icon of the asset
5963
internal override void OnHeaderIconGUI(Rect iconRect)
6064
{
61-
if (assetEditor != null)
62-
assetEditor.OnHeaderIconGUI(iconRect);
65+
if (m_AssetEditor != null)
66+
m_AssetEditor.OnHeaderIconGUI(iconRect);
6367
}
6468

6569
// Let asset importers decide if the imported object should be shown as a separate editor or not
@@ -241,7 +245,7 @@ protected virtual bool OnApplyRevertGUI()
241245

242246
protected void ApplyRevertGUI()
243247
{
244-
if (assetEditor == null || assetEditor.target == null)
248+
if (m_AssetEditor == null || m_AssetEditor.target == null)
245249
{
246250
// always apply changes when buttons are hidden
247251
Apply();

Editor/Mono/ImportSettings/TextureImportPlatformSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ public void Apply()
353353
(int)TextureImporterFormat.RGBAHalf,
354354
(int)TextureImporterFormat.BC4,
355355
(int)TextureImporterFormat.BC5,
356+
(int)TextureImporterFormat.BC6H,
357+
(int)TextureImporterFormat.BC7,
356358

357359
(int)TextureImporterFormat.ASTC_RGB_4x4,
358360
(int)TextureImporterFormat.ASTC_RGB_5x5,

Editor/Mono/Inspector/InspectorWindow.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ protected virtual void OnGUI()
405405
s_CurrentInspectorWindow = this;
406406
Editor[] editors = tracker.activeEditors;
407407

408-
AssignAssetEditor(editors);
409408
Profiler.BeginSample("InspectorWindow.DrawEditors()");
410409
DrawEditors(editors);
411410
Profiler.EndSample();
@@ -997,15 +996,6 @@ protected void DrawVCSShortInfoAsset(Asset asset, string tooltip, Rect rect, Tex
997996
EditorGUI.LabelField(textRect, content, styles.preToolbar2);
998997
}
999998

1000-
protected void AssignAssetEditor(Editor[] editors)
1001-
{
1002-
// Assign asset editor to importer editor
1003-
if (editors.Length > 1 && editors[0] is AssetImporterEditor)
1004-
{
1005-
(editors[0] as AssetImporterEditor).assetEditor = editors[1];
1006-
}
1007-
}
1008-
1009999
private void DrawEditors(Editor[] editors)
10101000
{
10111001
if (editors.Length == 0)

0 commit comments

Comments
 (0)