Skip to content

Commit 7331a93

Browse files
author
Unity Technologies
committed
Unity 2018.2.0a7 C# reference source code
1 parent 623fbfa commit 7331a93

95 files changed

Lines changed: 3512 additions & 618 deletions

File tree

Some content is hidden

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

Editor/Mono/Animation/AnimationUtility.bindings.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,28 @@ internal static System.Type GetEditorCurveValueType(ScriptableObject scriptableO
136136
extern private static System.Type Internal_GetScriptableObjectEditorCurveValueType([NotNull] ScriptableObject scriptableObject, EditorCurveBinding binding);
137137

138138
extern public static bool GetFloatValue([NotNull] GameObject root, EditorCurveBinding binding, out float data);
139-
//extern public static bool GetObjectReferenceValue([NotNull]GameObject root, [NotNull]EditorCurveBinding binding, out Object data);
139+
public static bool GetObjectReferenceValue(GameObject root, EditorCurveBinding binding, out Object data)
140+
{
141+
data = Internal_GetObjectReferenceValue(root, binding);
142+
return data != null;
143+
}
144+
145+
extern private static Object Internal_GetObjectReferenceValue([NotNull] GameObject root, EditorCurveBinding binding);
140146

141147
extern public static Object GetAnimatedObject([NotNull] GameObject root, EditorCurveBinding binding);
142148

143-
//extern public static Type PropertyModificationToEditorCurveBinding(PropertyModification modification, [NotNull]GameObject gameObject, out EditorCurveBinding binding);
149+
public static Type PropertyModificationToEditorCurveBinding(PropertyModification modification, GameObject gameObject, out EditorCurveBinding binding)
150+
{
151+
binding = new EditorCurveBinding();
152+
binding.type = typeof(Object); // dummy type to avoid errors while marshalling.
153+
154+
if (modification == null)
155+
return null;
156+
157+
return Internal_PropertyModificationToEditorCurveBinding(modification, gameObject, out binding);
158+
}
159+
160+
extern private static Type Internal_PropertyModificationToEditorCurveBinding(PropertyModification modification, [NotNull] GameObject gameObject, out EditorCurveBinding binding);
144161
extern internal static PropertyModification EditorCurveBindingToPropertyModification(EditorCurveBinding binding, [NotNull] GameObject gameObject);
145162

146163
extern public static EditorCurveBinding[] GetCurveBindings([NotNull] AnimationClip clip);

Editor/Mono/AssetPipeline/AssetImporter.bindings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public extern string assetBundleVariant
9191
[NativeName("SetAssetBundleName")]
9292
extern public void SetAssetBundleNameAndVariant(string assetBundleName, string assetBundleVariant);
9393

94-
[FreeFunction("FindAssetImporterInstanceAtAssetPath")]
94+
[FreeFunction("FindAssetImporterAtAssetPath")]
9595
extern public static AssetImporter GetAtPath(string path);
9696

9797
public void SaveAndReimport()

Editor/Mono/BuildPipeline/DesktopStandaloneBuildWindowExtension.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ public override void ShowPlatformBuildOptions()
159159
}
160160

161161
ShowIl2CppErrorIfNeeded();
162-
ShowIl2CppDebuggerWarningIfNeeded();
163162
}
164163

165164
private void ShowIl2CppErrorIfNeeded()
@@ -174,15 +173,6 @@ private void ShowIl2CppErrorIfNeeded()
174173
EditorGUILayout.HelpBox(error, MessageType.Error);
175174
}
176175

177-
void ShowIl2CppDebuggerWarningIfNeeded()
178-
{
179-
if (PlayerSettings.GetScriptingBackend(BuildTargetGroup.Standalone) != ScriptingImplementation.IL2CPP)
180-
return;
181-
182-
if (EditorUserBuildSettings.allowDebugging && EditorApplication.scriptingRuntimeVersion != ScriptingRuntimeVersion.Latest)
183-
EditorGUILayout.HelpBox("Script debugging is only supported with IL2CPP on the .NET 4.x scripting runtime.", MessageType.Warning);
184-
}
185-
186176
public override bool EnabledBuildButton()
187177
{
188178
if (PlayerSettings.GetScriptingBackend(BuildTargetGroup.Standalone) == ScriptingImplementation.Mono2x)

Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,23 @@
1616

1717
internal abstract class DesktopStandalonePostProcessor : DefaultBuildPostprocessor
1818
{
19-
protected DesktopStandalonePostProcessor()
19+
readonly bool m_HasIl2CppPlayers;
20+
21+
protected DesktopStandalonePostProcessor(bool hasIl2CppPlayers)
22+
{
23+
m_HasIl2CppPlayers = hasIl2CppPlayers;
24+
}
25+
26+
public override string PrepareForBuild(BuildOptions options, BuildTarget target)
2027
{
28+
if (!m_HasIl2CppPlayers)
29+
{
30+
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(target);
31+
if (PlayerSettings.GetScriptingBackend(buildTargetGroup) == ScriptingImplementation.IL2CPP)
32+
return "Currently selected scripting backend (IL2CPP) is not installed.";
33+
}
34+
35+
return null;
2136
}
2237

2338
public override void PostProcess(BuildPostProcessArgs args)
@@ -184,9 +199,9 @@ private void CopyNativePlugins(BuildPostProcessArgs args, out List<string> cppPl
184199
}
185200
}
186201

187-
private void CopyCppPlugins(string cppOutputDir, IEnumerable<string> cppPlugins)
202+
private void CopyCppPlugins(BuildPostProcessArgs args, string cppOutputDir, IEnumerable<string> cppPlugins)
188203
{
189-
if (GetCreateSolution())
204+
if (GetCreateSolution(args))
190205
return;
191206

192207
foreach (var plugin in cppPlugins)
@@ -218,15 +233,15 @@ private void SetupStagingArea(BuildPostProcessArgs args, HashSet<string> filesTo
218233
{
219234
CopyVariationFolderIntoStagingArea(args);
220235

221-
if (GetCreateSolution())
236+
if (GetCreateSolution(args))
222237
CopyPlayerSolutionIntoStagingArea(args, filesToNotOverwrite);
223238

224239
if (UseIl2Cpp)
225240
{
226241
var il2cppPlatformProvider = GetPlatformProvider(args);
227-
IL2CPPUtils.RunIl2Cpp(args.stagingAreaData, il2cppPlatformProvider, (cppOutputDir) => CopyCppPlugins(cppOutputDir, cppPlugins), args.usedClassRegistry);
242+
IL2CPPUtils.RunIl2Cpp(args.stagingAreaData, il2cppPlatformProvider, (cppOutputDir) => CopyCppPlugins(args, cppOutputDir, cppPlugins), args.usedClassRegistry);
228243

229-
if (GetCreateSolution())
244+
if (GetCreateSolution(args))
230245
{
231246
ProcessIl2CppOutputForSolution(args, il2cppPlatformProvider, cppPlugins);
232247
}
@@ -466,7 +481,7 @@ protected static bool UseIl2Cpp
466481
}
467482
}
468483

469-
protected virtual bool GetCreateSolution() { return false; }
484+
protected virtual bool GetCreateSolution(BuildPostProcessArgs args) { return false; }
470485

471486
protected virtual string GetDestinationFolder(BuildPostProcessArgs args)
472487
{

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,22 @@ internal static bool UseIl2CppCodegenWithMonoBackend(BuildTargetGroup targetGrou
121121
EditorApplication.useLibmonoBackendForIl2cpp &&
122122
PlayerSettings.GetScriptingBackend(targetGroup) == ScriptingImplementation.IL2CPP;
123123
}
124+
125+
internal static bool EnableIL2CPPDebugger(BuildTargetGroup targetGroup)
126+
{
127+
if (!EditorUserBuildSettings.allowDebugging)
128+
return false;
129+
130+
switch (PlayerSettings.GetApiCompatibilityLevel(targetGroup))
131+
{
132+
case ApiCompatibilityLevel.NET_4_6:
133+
case ApiCompatibilityLevel.NET_Standard_2_0:
134+
return true;
135+
136+
default:
137+
return false;
138+
}
139+
}
124140
}
125141

126142
internal class IL2CPPBuilder
@@ -190,8 +206,8 @@ public void RunCompileAndLink()
190206
Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder);
191207

192208
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
193-
var useDebugBuild = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup) == Il2CppCompilerConfiguration.Debug;
194-
var arguments = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, useDebugBuild).ToList();
209+
var compilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
210+
var arguments = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration).ToList();
195211

196212
arguments.Add(string.Format("--map-file-parser=\"{0}\"", GetMapFileParserPath()));
197213
arguments.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(GetCppOutputDirectoryInStagingArea())));
@@ -292,16 +308,15 @@ private void ConvertPlayerDlltoCpp(ICollection<string> userAssemblies, string ou
292308
break;
293309
}
294310

295-
if (EditorUserBuildSettings.allowDebugging && platformSupportsManagedDebugging && EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest)
311+
if (IL2CPPUtils.EnableIL2CPPDebugger(buildTargetGroup) && platformSupportsManagedDebugging)
296312
arguments.Add("--enable-debugger");
297313

298314
var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder();
299315
if (il2CppNativeCodeBuilder != null)
300316
{
301-
var useDebugBuild = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup) == Il2CppCompilerConfiguration.Debug;
302-
317+
var compilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
303318
Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder);
304-
arguments.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, useDebugBuild));
319+
arguments.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration));
305320
}
306321

307322
arguments.Add(string.Format("--map-file-parser=\"{0}\"", GetMapFileParserPath()));

Editor/Mono/BuildPipeline/Il2Cpp/Il2CppNativeCodeBuilderUtils.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace UnityEditorInternal
1212
{
1313
public static class Il2CppNativeCodeBuilderUtils
1414
{
15-
public static IEnumerable<string> AddBuilderArguments(Il2CppNativeCodeBuilder builder, string outputRelativePath, IEnumerable<string> includeRelativePaths, IEnumerable<string> additionalLibs, bool debugBuild)
15+
public static IEnumerable<string> AddBuilderArguments(Il2CppNativeCodeBuilder builder, string outputRelativePath, IEnumerable<string> includeRelativePaths, IEnumerable<string> additionalLibs, Il2CppCompilerConfiguration compilerConfiguration)
1616
{
1717
var arguments = new List<string>();
1818

@@ -21,11 +21,7 @@ public static IEnumerable<string> AddBuilderArguments(Il2CppNativeCodeBuilder bu
2121
arguments.Add("--libil2cpp-static");
2222
arguments.Add(FormatArgument("platform", builder.CompilerPlatform));
2323
arguments.Add(FormatArgument("architecture", builder.CompilerArchitecture));
24-
25-
if (debugBuild)
26-
arguments.Add(FormatArgument("configuration", "Debug"));
27-
else
28-
arguments.Add(FormatArgument("configuration", "Release"));
24+
arguments.Add(FormatArgument("configuration", compilerConfiguration.ToString()));
2925

3026
arguments.Add(FormatArgument("outputpath", builder.ConvertOutputFileToFullPath(outputRelativePath)));
3127

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -689,18 +689,30 @@ void ShowBuildTargetSettings()
689689
GUI.enabled = developmentBuild;
690690
if (shouldDrawDebuggingToggle)
691691
{
692-
EditorUserBuildSettings.allowDebugging = EditorGUILayout.Toggle(styles.allowDebugging, EditorUserBuildSettings.allowDebugging);
692+
using (new EditorGUI.DisabledScope(buildWindowExtension.ShouldDisableManagedDebuggerCheckboxes()))
693+
{
694+
EditorUserBuildSettings.allowDebugging = EditorGUILayout.Toggle(styles.allowDebugging, EditorUserBuildSettings.allowDebugging);
695+
696+
// Not all platforms have native dialog implemented in Runtime\Misc\GiveDebuggerChanceToAttachIfRequired.cpp
697+
// Display this option only for developer builds
698+
bool shouldDrawWaitForManagedDebugger = buildWindowExtension != null ? buildWindowExtension.ShouldDrawWaitForManagedDebugger() : false;
693699

694-
// Not all platforms have native dialog implemented in Runtime\Misc\GiveDebuggerChanceToAttachIfRequired.cpp
695-
// Display this option only for developer builds
696-
bool shouldDrawWaitForManagedDebugger = buildWindowExtension != null ? buildWindowExtension.ShouldDrawWaitForManagedDebugger() : false;
700+
if (EditorUserBuildSettings.allowDebugging && shouldDrawWaitForManagedDebugger)
701+
{
702+
var buildTargetName = BuildPipeline.GetBuildTargetName(buildTarget);
703+
704+
bool value = EditorGUILayout.Toggle(styles.waitForManagedDebugger, EditorUserBuildSettings.GetPlatformSettings(buildTargetName, kSettingDebuggingWaitForManagedDebugger) == "true");
705+
EditorUserBuildSettings.SetPlatformSettings(buildTargetName, kSettingDebuggingWaitForManagedDebugger, value.ToString().ToLower());
706+
}
707+
}
697708

698-
if (EditorUserBuildSettings.allowDebugging && shouldDrawWaitForManagedDebugger)
709+
if (EditorUserBuildSettings.allowDebugging && PlayerSettings.GetScriptingBackend(buildTargetGroup) == ScriptingImplementation.IL2CPP)
699710
{
700-
var buildTargetName = BuildPipeline.GetBuildTargetName(buildTarget);
711+
var apiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup);
712+
bool isDebuggerUsable = apiCompatibilityLevel == ApiCompatibilityLevel.NET_4_6 || apiCompatibilityLevel == ApiCompatibilityLevel.NET_Standard_2_0;
701713

702-
bool value = EditorGUILayout.Toggle(styles.waitForManagedDebugger, EditorUserBuildSettings.GetPlatformSettings(buildTargetName, kSettingDebuggingWaitForManagedDebugger) == "true");
703-
EditorUserBuildSettings.SetPlatformSettings(buildTargetName, kSettingDebuggingWaitForManagedDebugger, value.ToString().ToLower());
714+
if (!isDebuggerUsable)
715+
EditorGUILayout.HelpBox("Script debugging is only supported with IL2CPP on .NET 4.x and .NET Standard 2.0 API Compatibility Levels.", MessageType.Warning);
704716
}
705717
}
706718

Editor/Mono/EditorGUIUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ private static UnityObject Load(string filename, Type type)
870870
if (bundle == null)
871871
{
872872
// If in batch mode, loading any Editor UI items shouldn't be needed
873-
if (Application.isBatchmode)
873+
if (Application.isBatchMode)
874874
return null;
875875
throw new NullReferenceException("Failure to load editor resource asset bundle.");
876876
}

Editor/Mono/ImportSettings/TextureImporterInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ void InitializeGUI()
733733
| TextureInspectorGUIElement.StreamingMipmaps
734734
, shapeCapsAll);
735735
m_TextureTypeGUIElements[(int)TextureImporterType.Sprite] = new TextureInspectorTypeGUIProperties(TextureInspectorGUIElement.Sprite,
736-
TextureInspectorGUIElement.PowerOfTwo | TextureInspectorGUIElement.Readable | TextureInspectorGUIElement.AlphaHandling | TextureInspectorGUIElement.MipMaps | TextureInspectorGUIElement.ColorSpace,
736+
TextureInspectorGUIElement.Readable | TextureInspectorGUIElement.AlphaHandling | TextureInspectorGUIElement.MipMaps | TextureInspectorGUIElement.ColorSpace,
737737
TextureImporterShape.Texture2D);
738738
m_TextureTypeGUIElements[(int)TextureImporterType.Cookie] = new TextureInspectorTypeGUIProperties(TextureInspectorGUIElement.Cookie | TextureInspectorGUIElement.AlphaHandling | TextureInspectorGUIElement.CubeMapping,
739739
TextureInspectorGUIElement.PowerOfTwo | TextureInspectorGUIElement.Readable | TextureInspectorGUIElement.MipMaps,

Editor/Mono/Inspector/GenericInspector.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out Op
6363
else
6464
m_SerializedObject.Update();
6565

66+
height = 0;
6667
SerializedProperty property = m_SerializedObject.GetIterator();
6768
while (property.NextVisible(height <= 0))
6869
{
@@ -77,8 +78,6 @@ internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out Op
7778
// Allocate height for spacing above first control
7879
if (height > 0)
7980
height += EditorGUI.kControlVerticalSpacing;
80-
else
81-
height = 0;
8281

8382
if (m_OptimizedBlock == null)
8483
m_OptimizedBlock = new OptimizedGUIBlock();
@@ -116,10 +115,10 @@ internal override bool OnOptimizedInspectorGUI(Rect contentRect)
116115
else
117116
childrenAreExpanded = property.isExpanded;
118117

119-
m_LastHeight = contentRect.yMax - contentOffset;
120118
contentRect.y += contentRect.height + EditorGUI.kControlVerticalSpacing;
121119
}
122120

121+
m_LastHeight = contentRect.y - contentOffset;
123122
GUI.enabled = wasEnabled;
124123
return m_SerializedObject.ApplyModifiedProperties();
125124
}

0 commit comments

Comments
 (0)