22 changes: 11 additions & 11 deletions Editor/Mono/Audio/Mixer/GUI/AudioMixerDrawUtils.cs
Expand Up @@ -70,17 +70,17 @@ public class Styles
public GUIStyle warningOverlay = GetStyle("WarningOverlay");
public Texture2D scrollShadowTexture = EditorGUIUtility.FindTexture("ScrollShadow");
public Texture2D leftToRightShadowTexture = EditorGUIUtility.FindTexture("LeftToRightShadow");
public GUIContent soloGUIContent = new GUIContent("", "Adds this group to set of soloed groups");
public GUIContent muteGUIContent = new GUIContent("", "Mutes this group");
public GUIContent bypassGUIContent = new GUIContent("", "Bypasses the effects on this group");
public GUIContent effectSlotGUIContent = new GUIContent("", "Drag horizontally to change wet mix levels or vertically to change order of effects. Note: Enable wet mixing in the context menu.");
public GUIContent attenuationSlotGUIContent = new GUIContent("", "Place the attenuation slot in the effect stack where attenuation should take effect");
public GUIContent emptySendSlotGUIContent = new GUIContent("", "Connect to a Receive in the context menu or in the inspector");
public GUIContent returnSlotGUIContent = new GUIContent("", "Connect a Send to this Receive");
public GUIContent duckVolumeSlotGUIContent = new GUIContent("", "Connect a Send to this Duck Volume");
public GUIContent duckingFaderGUIContent = new GUIContent("", "Ducking Fader");
public GUIContent attenuationFader = new GUIContent("", "Attenuation fader");
public GUIContent vuMeterGUIContent = new GUIContent("", "The VU meter shows the current level of the mix of all sounds and subgroups.");
public GUIContent soloGUIContent = EditorGUIUtility.TrTextContent("", "Adds this group to set of soloed groups");
public GUIContent muteGUIContent = EditorGUIUtility.TrTextContent("", "Mutes this group");
public GUIContent bypassGUIContent = EditorGUIUtility.TrTextContent("", "Bypasses the effects on this group");
public GUIContent effectSlotGUIContent = EditorGUIUtility.TrTextContent("", "Drag horizontally to change wet mix levels or vertically to change order of effects. Note: Enable wet mixing in the context menu.");
public GUIContent attenuationSlotGUIContent = EditorGUIUtility.TrTextContent("", "Place the attenuation slot in the effect stack where attenuation should take effect");
public GUIContent emptySendSlotGUIContent = EditorGUIUtility.TrTextContent("", "Connect to a Receive in the context menu or in the inspector");
public GUIContent returnSlotGUIContent = EditorGUIUtility.TrTextContent("", "Connect a Send to this Receive");
public GUIContent duckVolumeSlotGUIContent = EditorGUIUtility.TrTextContent("", "Connect a Send to this Duck Volume");
public GUIContent duckingFaderGUIContent = EditorGUIUtility.TrTextContent("", "Ducking Fader");
public GUIContent attenuationFader = EditorGUIUtility.TrTextContent("", "Attenuation fader");
public GUIContent vuMeterGUIContent = EditorGUIUtility.TrTextContent("", "The VU meter shows the current level of the mix of all sounds and subgroups.");
public GUIContent referencedGroups = EditorGUIUtility.TrTextContent("Referenced groups", "Mixer groups that are hidden but are referenced by the visible mixer groups are shown here for convenience");
public GUIContent sendString = new GUIContent("s");

Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/Audio/Mixer/GUI/AudioMixerEffectView.cs
Expand Up @@ -397,7 +397,7 @@ private static void ShowEffectContextMenu(AudioMixerGroupController group, Audio

if (!effect.IsAttenuation() && !effect.IsSend() && !effect.IsDuckVolume() && effect.enableWetMix)
{
menu.AddItem(new GUIContent("Copy effect settings to all snapshots, including wet level"), false, delegate()
menu.AddItem(EditorGUIUtility.TrTextContent("Copy effect settings to all snapshots, including wet level"), false, delegate()
{
Undo.RecordObject(controller, "Copy effect settings to all snapshots, including wet level");
controller.CopyEffectSettingsToAllSnapshots(group, effectIndex, controller.TargetSnapshot, true);
Expand Down
Expand Up @@ -23,7 +23,7 @@ internal static void Popup(AudioMixerController controller, GUIStyle style, para
}

// Cache to prevent constructing string on every event
static GUIContent m_ButtonContent = new GUIContent("", "Audio Mixer parameters can be exposed to scripting. Select an Audio Mixer Group, right click one of its properties in the Inspector and select 'Expose ..'.");
static GUIContent m_ButtonContent = EditorGUIUtility.TrTextContent("", "Audio Mixer parameters can be exposed to scripting. Select an Audio Mixer Group, right click one of its properties in the Inspector and select 'Expose ..'.");
static int m_LastNumExposedParams = -1;
static GUIContent GetButtonContent(AudioMixerController controller)
{
Expand Down
1 change: 1 addition & 0 deletions Editor/Mono/Audio/Mixer/GUI/AudioMixerGroupTreeView.cs
Expand Up @@ -336,6 +336,7 @@ public void ReloadTree()
if (m_Controller != null)
{
m_Controller.SanitizeGroupViews();
m_Controller.OnSubAssetChanged();
}
}

Expand Down
6 changes: 3 additions & 3 deletions Editor/Mono/Audio/Mixer/GUI/AudioMixerWindow.cs
Expand Up @@ -120,9 +120,9 @@ class GUIContents
public GUIContents()
{
rms = EditorGUIUtility.TrTextContent("RMS", "Switches between RMS (Root Mean Square) metering and peak metering. RMS is closer to the energy level and perceived loudness of the sound (hence lower than the peak meter), while peak-metering is useful for monitoring spikes in the signal that can cause clipping.");
editSnapShots = EditorGUIUtility.TrTextContent("Edit in Play Mode", "Edit in playmode and your changes are automatically saved. Note when editting is disabled then live values are shown.", EditorGUIUtility.IconContent("Animation.Record", "|Are scene and inspector changes recorded into the animation curves?").image);
editSnapShots = EditorGUIUtility.TrTextContent("Edit in Play Mode", "Edit in playmode and your changes are automatically saved. Note when editting is disabled then live values are shown.", EditorGUIUtility.TrIconContent("Animation.Record", "Are scene and inspector changes recorded into the animation curves?").image);
infoText = EditorGUIUtility.TrTextContent("Create an AudioMixer asset from the Project Browser to get started");
selectAudioMixer = new GUIContent("", "Select an Audio Mixer");
selectAudioMixer = EditorGUIUtility.TrTextContent("", "Select an Audio Mixer");
output = EditorGUIUtility.TrTextContent("Output", "Select an Audio Mixer Group from another Audio Mixer to output to. If 'None' is selected then output is routed directly to the Audio Listener.");
toolbarLabel.alignment = TextAnchor.MiddleLeft;
toolbarObjectField.normal.textColor = toolbarLabel.normal.textColor;
Expand Down Expand Up @@ -344,9 +344,9 @@ public void UndoRedoPerformed()
return;

// Undo may have deleted one of the selected groups
m_Controller.OnSubAssetChanged();
m_Controller.SanitizeGroupViews();
m_Controller.OnUnitySelectionChanged();
m_Controller.OnSubAssetChanged();

if (m_GroupTree != null)
m_GroupTree.OnUndoRedoPerformed();
Expand Down
7 changes: 6 additions & 1 deletion Editor/Mono/Audio/WaveformPreview.cs
Expand Up @@ -124,7 +124,12 @@ public void Dispose()
InternalDispose();

if (m_Texture != null)
UnityEngine.Object.Destroy(m_Texture);
{
if (Application.isPlaying)
UnityEngine.Object.Destroy(m_Texture);
else
UnityEngine.Object.DestroyImmediate(m_Texture);
}

m_Texture = null;
}
Expand Down
557 changes: 557 additions & 0 deletions Editor/Mono/BuildPipeline.bindings.cs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Editor/Mono/BuildPipeline/AssemblyStripper.cs
Expand Up @@ -83,6 +83,10 @@ private static bool StripAssembliesTo(string[] assemblies, string[] searchDirs,
args.AddRange(searchDirs.Select(d => "-d \"" + d + "\""));
args.AddRange(assemblies.Select(assembly => "-a \"" + Path.GetFullPath(assembly) + "\""));

var additionalArgs = System.Environment.GetEnvironmentVariable("UNITYLINKER_ADDITIONAL_ARGS");
if (!string.IsNullOrEmpty(additionalArgs))
args.Add(additionalArgs);

return RunAssemblyLinker(args, out output, out error, linkerPath, workingDirectory);
}

Expand Down
3 changes: 2 additions & 1 deletion Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs
Expand Up @@ -103,9 +103,10 @@ internal static void InitializeBuildCallbacks(BuildCallbacks findFlags)
{
if (findFlags == previousFlags)
return;
previousFlags = findFlags;

CleanupBuildCallbacks();
previousFlags = findFlags;

bool findBuildProcessors = (findFlags & BuildCallbacks.BuildProcessors) == BuildCallbacks.BuildProcessors;
bool findSceneProcessors = (findFlags & BuildCallbacks.SceneProcessors) == BuildCallbacks.SceneProcessors;
bool findTargetProcessors = (findFlags & BuildCallbacks.BuildTargetProcessors) == BuildCallbacks.BuildTargetProcessors;
Expand Down
3 changes: 0 additions & 3 deletions Editor/Mono/BuildPipeline/BuildPlatform.cs
Expand Up @@ -59,8 +59,6 @@ public BuildTarget defaultTarget
return BuildTarget.N3DS;
case BuildTargetGroup.Switch:
return BuildTarget.Switch;
case BuildTargetGroup.Tizen:
return BuildTarget.Tizen;
case BuildTargetGroup.WebGL:
return BuildTarget.WebGL;
case BuildTargetGroup.WSA:
Expand Down Expand Up @@ -98,7 +96,6 @@ internal BuildPlatforms()
// TVOS TODO change the icon when it's ready
buildPlatformsList.Add(new BuildPlatform("tvOS", "BuildSettings.tvOS", BuildTargetGroup.tvOS, true));
buildPlatformsList.Add(new BuildPlatform("Android", "BuildSettings.Android", BuildTargetGroup.Android, true));
buildPlatformsList.Add(new BuildPlatform("Tizen", "BuildSettings.Tizen", BuildTargetGroup.Tizen, false));
buildPlatformsList.Add(new BuildPlatform("Xbox One", "BuildSettings.XboxOne", BuildTargetGroup.XboxOne, true));
buildPlatformsList.Add(new BuildPlatform("PS Vita", "BuildSettings.PSP2", BuildTargetGroup.PSP2, true));
buildPlatformsList.Add(new BuildPlatform("PS4", "BuildSettings.PS4", BuildTargetGroup.PS4, true));
Expand Down
36 changes: 22 additions & 14 deletions Editor/Mono/BuildPipeline/CodeStrippingUtils.cs
Expand Up @@ -75,7 +75,8 @@ public static UnityType[] BlackListNativeClasses

static readonly Dictionary<string, string> s_blackListNativeClassesDependencyNames = new Dictionary<string, string>
{
{"ParticleSystemRenderer", "ParticleSystem"}
{"ParticleSystemRenderer", "ParticleSystem"},
{"ParticleSystem", "ParticleSystemRenderer"}
};

static Dictionary<UnityType, UnityType> s_blackListNativeClassesDependency;
Expand Down Expand Up @@ -270,14 +271,17 @@ public static void ApplyManualStrippingOverrides(HashSet<UnityType> nativeClasse
if (includeSetting == ModuleIncludeSetting.ForceInclude)
{
nativeModules.Add(module);
var moduleClasses = ModuleMetadata.GetModuleTypes(module);
foreach (var klass in moduleClasses)
if (nativeClasses != null)
{
nativeClasses.Add(klass);
if (strippingInfo != null)
var moduleClasses = ModuleMetadata.GetModuleTypes(module);
foreach (var klass in moduleClasses)
{
strippingInfo.RegisterDependency(klass.name, "Force included module");
strippingInfo.RegisterDependency(StrippingInfo.ModuleName(module), klass.name);
nativeClasses.Add(klass);
if (strippingInfo != null)
{
strippingInfo.RegisterDependency(klass.name, "Force included module");
strippingInfo.RegisterDependency(StrippingInfo.ModuleName(module), klass.name);
}
}
}

Expand All @@ -289,12 +293,16 @@ public static void ApplyManualStrippingOverrides(HashSet<UnityType> nativeClasse
if (nativeModules.Contains(module))
{
nativeModules.Remove(module);
var moduleClasses = ModuleMetadata.GetModuleTypes(module);
foreach (var klass in moduleClasses)

if (nativeClasses != null)
{
if (nativeClasses.Contains(klass))
var moduleClasses = ModuleMetadata.GetModuleTypes(module);
foreach (var klass in moduleClasses)
{
nativeClasses.Remove(klass);
if (nativeClasses.Contains(klass))
{
nativeClasses.Remove(klass);
}
}
}

Expand Down Expand Up @@ -590,7 +598,7 @@ private static void WriteModuleAndClassRegistrationFile(string file, HashSet<str
{
using (TextWriter w = new StreamWriter(file))
{
w.WriteLine("template <typename T> void RegisterClass(const char*);");
w.WriteLine("template <typename T> void RegisterUnityClass(const char*);");
w.WriteLine("template <typename T> void RegisterStrippedType(int, const char*, const char*);");

w.WriteLine();
Expand All @@ -611,7 +619,7 @@ private static void WriteModuleAndClassRegistrationFile(string file, HashSet<str
w.Write("class {0}; ", type.name);

if (nativeClasses.Contains(type))
w.WriteLine("template <> void RegisterClass<{0}>(const char*);", type.qualifiedName);
w.WriteLine("template <> void RegisterUnityClass<{0}>(const char*);", type.qualifiedName);
else
w.WriteLine();
}
Expand Down Expand Up @@ -640,7 +648,7 @@ private static void WriteModuleAndClassRegistrationFile(string file, HashSet<str
if (classesToSkip.Contains(klass))
w.WriteLine("\t//Skipping {0}", klass.qualifiedName);
else
w.WriteLine("\tRegisterClass<{0}>(\"{1}\");", klass.qualifiedName, klass.module);
w.WriteLine("\tRegisterUnityClass<{0}>(\"{1}\");", klass.qualifiedName, klass.module);
++index;
}
w.WriteLine();
Expand Down
Expand Up @@ -199,4 +199,9 @@ public override bool EnabledBuildAndRunButton()
{
return true;
}

public override bool ShouldDrawWaitForManagedDebugger()
{
return true;
}
}
36 changes: 23 additions & 13 deletions Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs
Expand Up @@ -3,7 +3,9 @@
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEditor.Modules;
Expand Down Expand Up @@ -40,7 +42,7 @@ public override void UpdateBootConfig(BuildTarget target, BootConfigData config,
config.Set("mono-codegen", "il2cpp");
}

private void CopyNativePlugins(BuildPostProcessArgs args)
private void CopyNativePlugins(BuildPostProcessArgs args, out List<string> cppPlugins)
{
string buildTargetName = BuildPipeline.GetBuildTargetName(args.target);
IPluginImporterExtension pluginImpExtension = new DesktopPluginImporterExtension();
Expand All @@ -52,11 +54,19 @@ private void CopyNativePlugins(BuildPostProcessArgs args)
bool haveCreatedPluginsFolder = false;
bool haveCreatedSubDir32Bit = false;
bool haveCreatedSubDir64Bit = false;
cppPlugins = new List<string>();

foreach (PluginImporter imp in PluginImporter.GetImporters(args.target))
{
BuildTarget t = args.target;

// Skip .cpp files. They get copied to il2cpp output folder just before code compilation
if (DesktopPluginImporterExtension.IsCppPluginFile(imp.assetPath))
{
cppPlugins.Add(imp.assetPath);
continue;
}

// Skip managed DLLs.
if (!imp.isNativePlugin)
continue;
Expand Down Expand Up @@ -151,6 +161,14 @@ private void CopyNativePlugins(BuildPostProcessArgs args)
}
}

private void CopyCppPlugins(string cppOutputDir, IEnumerable<string> cppPlugins)
{
foreach (var plugin in cppPlugins)
{
FileUtil.CopyFileOrDirectory(plugin, Path.Combine(cppOutputDir, Path.GetFileName(plugin)));
}
}

private void SetupStagingArea(BuildPostProcessArgs args)
{
if (UseIl2Cpp && GetCreateSolution())
Expand All @@ -160,7 +178,8 @@ private void SetupStagingArea(BuildPostProcessArgs args)

Directory.CreateDirectory(args.stagingAreaData);

CopyNativePlugins(args);
List<string> cppPlugins;
CopyNativePlugins(args, out cppPlugins);

if (args.target == BuildTarget.StandaloneWindows ||
args.target == BuildTarget.StandaloneWindows64)
Expand All @@ -173,7 +192,7 @@ private void SetupStagingArea(BuildPostProcessArgs args)
if (UseIl2Cpp)
{
CopyVariationFolderIntoStagingArea(args);
IL2CPPUtils.RunIl2Cpp(args.stagingAreaData, GetPlatformProvider(args), null, args.usedClassRegistry);
IL2CPPUtils.RunIl2Cpp(args.stagingAreaData, GetPlatformProvider(args), (cppOutputDir) => CopyCppPlugins(cppOutputDir, cppPlugins), args.usedClassRegistry);

// Move GameAssembly next to game executable
var il2cppOutputNativeDirectory = Path.Combine(args.stagingAreaData, "Native");
Expand Down Expand Up @@ -427,16 +446,7 @@ protected virtual bool PlaceIL2CPPSymbolMapNextToExecutable()
return true;
}

internal class ScriptingImplementations : IScriptingImplementations
internal class ScriptingImplementations : DefaultScriptingImplementations
{
public ScriptingImplementation[] Supported()
{
return new[] { ScriptingImplementation.Mono2x, ScriptingImplementation.IL2CPP };
}

public ScriptingImplementation[] Enabled()
{
return new[] { ScriptingImplementation.Mono2x, ScriptingImplementation.IL2CPP };
}
}
}
47 changes: 19 additions & 28 deletions Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs
Expand Up @@ -104,7 +104,7 @@ internal static string ApiCompatibilityLevelToDotNetProfileArgument(ApiCompatibi
return "net20";

case ApiCompatibilityLevel.NET_4_6:
return "net45";
return "unityjit";

case ApiCompatibilityLevel.NET_Standard_2_0:
return "unityaot";
Expand Down Expand Up @@ -195,7 +195,7 @@ public void RunCompileAndLink()
arguments.Add(string.Format("--map-file-parser=\"{0}\"", GetMapFileParserPath()));
arguments.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(GetCppOutputDirectoryInStagingArea())));
if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_4_6)
arguments.Add("--dotnetprofile=\"net45\"");
arguments.Add("--dotnetprofile=\"unityjit\"");
if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_Standard_2_0)
arguments.Add("--dotnetprofile=\"unityaot\"");
Action<ProcessStartInfo> setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo;
Expand Down Expand Up @@ -275,28 +275,30 @@ private void ConvertPlayerDlltoCpp(ICollection<string> userAssemblies, string ou
if (m_PlatformProvider.enableDivideByZeroCheck)
arguments.Add("--enable-divide-by-zero-check");

if (m_PlatformProvider.developmentMode)
arguments.Add("--development-mode");

if (m_BuildForMonoRuntime)
arguments.Add("--mono-runtime");

//Currently In Development, Not yet ready to enable
//if (m_PlatformProvider.enableDebugger)
// arguments.Add("--enable-debugger");

var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_4_6)
arguments.Add("--dotnetprofile=\"net45\"");
var useDebugBuild = EditorUserBuildSettings.allowDebugging;

switch (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup))
{
case ApiCompatibilityLevel.NET_4_6:
arguments.Add("--dotnetprofile=\"unityjit\"");
break;

if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_Standard_2_0)
arguments.Add("--dotnetprofile=\"unityaot\"");
case ApiCompatibilityLevel.NET_Standard_2_0:
arguments.Add("--dotnetprofile=\"unityaot\"");
break;
}

//Currently In Development, Not yet ready to enable
//if (useDebugBuild)
// arguments.Add("--enable-debugger");

var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder();
if (il2CppNativeCodeBuilder != null)
{
var useDebugBuild = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup) == Il2CppCompilerConfiguration.Debug;

Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder);
arguments.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, useDebugBuild));
}
Expand Down Expand Up @@ -404,10 +406,8 @@ internal interface IIl2CppPlatformProvider
bool enableDivideByZeroCheck { get; }
string nativeLibraryFileName { get; }
string il2CppFolder { get; }
bool developmentMode { get; }
string moduleStrippingInformationFolder { get; }
bool supportsEngineStripping { get; }
bool enableDebugger { get; }

BuildReport buildReport { get; }
string[] includePaths { get; }
Expand All @@ -430,19 +430,15 @@ public BaseIl2CppPlatformProvider(BuildTarget target, string libraryFolder)

public virtual string libraryFolder { get; private set; }

public virtual bool developmentMode
{
get { return false; }
}

public virtual bool emitNullChecks
{
get { return true; }
}

// This is an opt-in setting, as most platforms will want to use native stacktrace mechanisms enabled by MapFileParser
public virtual bool enableStackTraces
{
get { return true; }
get { return false; }
}

public virtual bool enableArrayBoundsCheck
Expand All @@ -460,11 +456,6 @@ public virtual bool supportsEngineStripping
get { return false; }
}

public virtual bool enableDebugger
{
get { return false; }
}

public virtual BuildReport buildReport
{
get { return null; }
Expand Down
4 changes: 2 additions & 2 deletions Editor/Mono/BuildPipeline/MonoCrossCompile.cs
Expand Up @@ -4,6 +4,7 @@

using UnityEngine;
using UnityEditor;
using UnityEditor.Scripting.ScriptCompilation;
using System.Collections;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -233,8 +234,7 @@ static public void DisplayAOTProgressBar(int totalFiles, int filesFinished)

static bool IsDebugableAssembly(string fname)
{
fname = Path.GetFileName(fname);
return fname.StartsWith("Assembly", StringComparison.OrdinalIgnoreCase);
return EditorCompilationInterface.Instance.IsRuntimeScriptAssembly(fname);
}

static void CrossCompileAOT(BuildTarget target, string crossCompilerAbsolutePath, string assembliesAbsoluteDirectory, CrossCompileOptions crossCompileOptions, string input, string output, string additionalOptions)
Expand Down
4 changes: 2 additions & 2 deletions Editor/Mono/BuildPipeline/MonoInternalCallGenerator.cs
Expand Up @@ -268,7 +268,7 @@ public static void GenerateRegisterModules(HashSet<UnityType> nativeClasses, Has
public static void GenerateRegisterClassesForStripping(HashSet<UnityType> nativeClassesAndBaseClasses, TextWriter output)
{
// Forward declare template function
output.WriteLine("template <typename T> void RegisterClass(const char*);");
output.WriteLine("template <typename T> void RegisterUnityClass(const char*);");
output.WriteLine("template <typename T> void RegisterStrippedType(int, const char*, const char*);");
output.WriteLine();

Expand Down Expand Up @@ -303,7 +303,7 @@ public static void GenerateRegisterClassesForStripping(HashSet<UnityType> native
continue;

output.WriteLine("\t// {0}. {1}", count++, type.qualifiedName);
output.WriteLine("\tRegisterClass<{0}>(\"{1}\");\n", type.qualifiedName, type.module);
output.WriteLine("\tRegisterUnityClass<{0}>(\"{1}\");\n", type.qualifiedName, type.module);
}

output.WriteLine();
Expand Down
6 changes: 4 additions & 2 deletions Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs
Expand Up @@ -189,7 +189,7 @@ static public void LaunchOnTargets(BuildTargetGroup targetGroup, BuildTarget bui
try
{
// Early out so as not to show/update progressbars unnecessarily
if (buildReport == null || !DeploymentTargetManager.IsExtensionSupported(targetGroup, buildReport.summary.platform))
if (buildReport == null)
throw new System.NotSupportedException();

ProgressHandler progressHandler = new ProgressHandler("Deploying Player",
Expand All @@ -210,7 +210,9 @@ static public void LaunchOnTargets(BuildTargetGroup targetGroup, BuildTarget bui
{
try
{
DeploymentTargetManager.LaunchBuildOnTarget(targetGroup, buildReport, target, taskManager.SpawnProgressHandlerFromCurrentTask());
var manager = DeploymentTargetManager.CreateInstance(targetGroup, buildReport.summary.platform);
var buildProperties = BuildProperties.GetFromBuildReport(buildReport);
manager.LaunchBuildOnTarget(buildProperties, target, taskManager.SpawnProgressHandlerFromCurrentTask());
successfulLaunches++;
}
catch (DeploymentOperationFailedException e)
Expand Down
43 changes: 16 additions & 27 deletions Editor/Mono/BuildPlayerWindow.cs
Expand Up @@ -62,23 +62,22 @@ class Styles
const string kShopURL = "https://store.unity3d.com/shop/";
const string kDownloadURL = "http://unity3d.com/unity/download/";
const string kMailURL = "http://unity3d.com/company/sales?type=sales";
const string kMultiPlatformURL = "https://unity3d.com/unity/features/multiplatform";
const string kPlatformInstallationURL = "https://unity3d.com/platform-installation";
// ADD_NEW_PLATFORM_HERE
public GUIContent[,] notLicensedMessages =
{
{ EditorGUIUtility.TextContent("Your license does not cover Standalone Publishing."), new GUIContent(""), new GUIContent(kShopURL) },
{ EditorGUIUtility.TextContent("Your license does not cover iOS Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TextContent("Your license does not cover Apple TV Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TextContent("Your license does not cover Android Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TextContent("Your license does not cover Tizen Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TextContent("Your license does not cover Xbox One Publishing. For more information please see 'Unity for Console' on the multiplatform site."), EditorGUIUtility.TrTextContent("Unity Multiplatform"), new GUIContent(kMultiPlatformURL) },
{ EditorGUIUtility.TextContent("Your license does not cover PS Vita Publishing. For more information please see 'Unity for Console' on the multiplatform site."), EditorGUIUtility.TrTextContent("Unity Multiplatform"), new GUIContent(kMultiPlatformURL) },
{ EditorGUIUtility.TextContent("Your license does not cover PS4 Publishing. For more information please see 'Unity for Console' on the multiplatform site."), EditorGUIUtility.TrTextContent("Unity Multiplatform"), new GUIContent(kMultiPlatformURL) },
{ EditorGUIUtility.TextContent("Your license does not cover Universal Windows Platform Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TextContent("Your license does not cover Windows Phone 8 Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TextContent("Your license does not cover Nintendo 3DS Publishing"), EditorGUIUtility.TrTextContent("Contact sales"), new GUIContent(kMailURL) },
{ EditorGUIUtility.TextContent("Your license does not cover Facebook Publishing"), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TextContent("Your license does not cover Nintendo Switch Publishing"), EditorGUIUtility.TrTextContent("Contact sales"), new GUIContent(kMailURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover iOS Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover Apple TV Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover Android Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover Xbox One Publishing. Please see the Xbox One section of the Platform Module Installation documentation for more details."), EditorGUIUtility.TrTextContent("Platform Module Installation"), new GUIContent(kPlatformInstallationURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover PS Vita Publishing. Please see the PS Vita section of the Platform Module Installation documentation for more details."), EditorGUIUtility.TrTextContent("Platform Module Installation"), new GUIContent(kPlatformInstallationURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover PS4 Publishing. Please see the PS4 section of the Platform Module Installation documentation for more details."), EditorGUIUtility.TrTextContent("Platform Module Installation"), new GUIContent(kPlatformInstallationURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover Universal Windows Platform Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover Windows Phone 8 Publishing."), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover Nintendo 3DS Publishing"), EditorGUIUtility.TrTextContent("Contact sales"), new GUIContent(kMailURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover Facebook Publishing"), EditorGUIUtility.TrTextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
{ EditorGUIUtility.TrTextContent("Your license does not cover Nintendo Switch Publishing"), EditorGUIUtility.TrTextContent("Contact sales"), new GUIContent(kMailURL) },
};

// ADD_NEW_PLATFORM_HERE
Expand All @@ -88,7 +87,6 @@ class Styles
{ EditorGUIUtility.TrTextContent("iOS Player is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
{ EditorGUIUtility.TrTextContent("Apple TV Player is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
{ EditorGUIUtility.TrTextContent("Android Player is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
{ EditorGUIUtility.TrTextContent("Tizen is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
{ EditorGUIUtility.TrTextContent("Xbox One Player is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
{ EditorGUIUtility.TrTextContent("PS Vita Player is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
{ EditorGUIUtility.TrTextContent("PS4 Player is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
Expand All @@ -112,9 +110,9 @@ public GUIContent GetDownloadErrorForTarget(BuildTarget target)
// string and matching enum values for standalone subtarget dropdowm
public GUIContent debugBuild = EditorGUIUtility.TrTextContent("Development Build");
public GUIContent profileBuild = EditorGUIUtility.TrTextContent("Autoconnect Profiler");
public GUIContent vrRemoteStremaing = EditorGUIUtility.TrTextContent("VR Remote Streaming");
public GUIContent allowDebugging = EditorGUIUtility.TrTextContent("Script Debugging");
public GUIContent waitForManagedDebugger = EditorGUIUtility.TrTextContent("Wait For Managed Debugger", "Show a dialog where you can attach a managed debugger before any script execution.");
public GUIContent symlinkiOSLibraries = EditorGUIUtility.TrTextContent("Symlink Unity libraries");
public GUIContent explicitNullChecks = EditorGUIUtility.TrTextContent("Explicit Null Checks");
public GUIContent explicitDivideByZeroChecks = EditorGUIUtility.TrTextContent("Divide By Zero Checks");
public GUIContent explicitArrayBoundsChecks = EditorGUIUtility.TrTextContent("Array Bounds Checks");
Expand Down Expand Up @@ -647,17 +645,6 @@ void ShowBuildTargetSettings()
buildWindowExtension.ShowPlatformBuildOptions();

GUI.changed = false;
switch (platform.targetGroup)
{
case BuildTargetGroup.iOS:
case BuildTargetGroup.tvOS:
{
if (Application.platform == RuntimePlatform.OSXEditor)
EditorUserBuildSettings.symlinkLibraries = EditorGUILayout.Toggle(styles.symlinkiOSLibraries, EditorUserBuildSettings.symlinkLibraries);
}
break;
}

GUI.enabled = true;

bool enableBuildButton = buildWindowExtension != null ? buildWindowExtension.EnabledBuildButton() : true;
Expand Down Expand Up @@ -705,7 +692,9 @@ void ShowBuildTargetSettings()

// Not all platforms have native dialog implemented in Runtime\Misc\GiveDebuggerChanceToAttachIfRequired.cpp
// Display this option only for developer builds
if (EditorUserBuildSettings.allowDebugging && Unsupported.IsSourceBuild())
bool shouldDrawWaitForManagedDebugger = buildWindowExtension != null ? buildWindowExtension.ShouldDrawWaitForManagedDebugger() : false;

if (EditorUserBuildSettings.allowDebugging && shouldDrawWaitForManagedDebugger)
{
var buildTargetName = BuildPipeline.GetBuildTargetName(buildTarget);

Expand Down
52 changes: 52 additions & 0 deletions Editor/Mono/BuildPlayerWindowBuildMethods.cs
Expand Up @@ -312,9 +312,32 @@ static bool PickBuildLocation(BuildTargetGroup targetGroup, BuildTarget target,
// Invalidate default name, if extension mismatches the default file (for ex., when switching between folder type export to file type export, see Android)
if (extension != Path.GetExtension(defaultName).Replace(".", ""))
defaultName = string.Empty;

// Hack: For Windows Standalone, we want the BuildPanel to choose a folder,
// but we don't want BuildPlayer to take a folder path because historically it took an .exe path
// and we would be breaking tons of projects!
bool isWindowsStandalone = target == BuildTarget.StandaloneWindows || target == BuildTarget.StandaloneWindows64;
string realExtension = extension;
if (isWindowsStandalone)
{
extension = string.Empty;
// Remove the filename.exe part from the path
if (!string.IsNullOrEmpty(defaultName))
defaultName = Path.GetDirectoryName(defaultName);
}

string title = "Build " + BuildPlatforms.instance.GetBuildTargetDisplayName(targetGroup, target);
string path = EditorUtility.SaveBuildPanel(target, title, defaultFolder, defaultName, extension, out updateExistingBuild);

if (isWindowsStandalone)
{
extension = realExtension;
path = Path.Combine(path, Path.GetFileName(path) + '.' + extension);
}

if (!IsBuildPathValid(path))
return false;

if (path == string.Empty)
return false;

Expand Down Expand Up @@ -347,6 +370,35 @@ static bool PickBuildLocation(BuildTargetGroup targetGroup, BuildTarget target,
return true;
}

private static string NormalizePath(string path)
{
var fullPath = Path.GetFullPath(path);
if (fullPath.EndsWith("/") || fullPath.EndsWith("\\"))
fullPath = fullPath.Remove(fullPath.Length - 1);
fullPath = fullPath.ToLower();
if (Path.DirectorySeparatorChar == '/')
return fullPath;
return fullPath.Replace(Path.DirectorySeparatorChar, '/');
}

internal static bool IsBuildPathValid(string path)
{
var cleanedPath = NormalizePath(path);
var basePath = NormalizePath(Application.dataPath + "/../");

var assetsPath = NormalizePath(basePath + "/Assets");
var settingsPath = NormalizePath(basePath + "/ProjectSettings");
var tempPath = NormalizePath(basePath + "/Temp");
var libraryPath = NormalizePath(basePath + "/Library");
if (basePath.Contains(cleanedPath) || cleanedPath == assetsPath || cleanedPath == settingsPath || cleanedPath == tempPath || cleanedPath == libraryPath)
{
Debug.LogError("Invalid build path: " + cleanedPath);
return false;
}

return true;
}

static bool FolderIsEmpty(string path)
{
if (!Directory.Exists(path))
Expand Down
243 changes: 131 additions & 112 deletions Editor/Mono/BuildPlayerWindowPublish.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Editor/Mono/BuildTarget.cs
Expand Up @@ -79,7 +79,7 @@ public enum BuildTarget
[System.Obsolete("BlackBerry has been removed in 5.4")]
BlackBerry = 28,

// *undocumented*
[System.Obsolete("Tizen has been removed in 2017.3")]
Tizen = 29,

/// Build a Vita Standalone
Expand All @@ -92,7 +92,7 @@ public enum BuildTarget

/// Build a Unity PlayStation Mobile (PSM) application
/// SA: BuildPipeline.BuildPlayer.
[System.Obsolete("warning PSM has been removed in >= 5.3")]
[System.Obsolete("PSM has been removed in >= 5.3")]
PSM = 32,

/// Build an Xbox One Standalone
Expand Down
3 changes: 2 additions & 1 deletion Editor/Mono/BuildTargetGroup.cs
Expand Up @@ -59,6 +59,7 @@ public enum BuildTargetGroup
[Obsolete("BlackBerry has been removed as of 5.4")]
BlackBerry = 16,

[System.Obsolete("Tizen has been removed in 2017.3")]
Tizen = 17,

/// Sony Playstation Vita target.
Expand All @@ -68,7 +69,7 @@ public enum BuildTargetGroup
PS4 = 19,

/// Unity Playstation Mobile target.
[Obsolete("warning PSM has been removed in >= 5.3")]
[Obsolete("PSM has been removed in >= 5.3")]
PSM = 20,

/// Xbox One target.
Expand Down
26 changes: 26 additions & 0 deletions Editor/Mono/Burst/BurstCompilerService.bindings.cs
@@ -0,0 +1,26 @@
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.IO;
using UnityEngine.Bindings;
using System.Reflection;

namespace Unity.Burst.LowLevel
{
[NativeHeader("Runtime/Burst/Burst.h")]
[StaticAccessor("BurstCompilerService::Get()", StaticAccessorType.Arrow)]
internal static partial class BurstCompilerService
{
[NativeMethod("Initialize")]
static extern string InitializeInternal(string path, ExtractCompilerFlags extractCompilerFlags);

public static extern string GetDisassembly(MethodInfo m, string compilerOptions);

public static extern bool IsInitialized { get; }
}
}
35 changes: 35 additions & 0 deletions Editor/Mono/Burst/BurstCompilerService.cs
@@ -0,0 +1,35 @@
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.IO;
using UnityEngine.Bindings;

namespace Unity.Burst.LowLevel
{
internal static partial class BurstCompilerService
{
public delegate bool ExtractCompilerFlags(Type jobType, out string flags);

public static void Initialize(string folderRuntime, ExtractCompilerFlags extractCompilerFlags)
{
if (folderRuntime == null) throw new ArgumentNullException(nameof(folderRuntime));
if (extractCompilerFlags == null) throw new ArgumentNullException(nameof(extractCompilerFlags));

if (!Directory.Exists(folderRuntime))
{
Debug.LogError($"Unable to initialize the burst JIT compiler. The folder `{folderRuntime}` does not exist");
return;
}

var message = InitializeInternal(folderRuntime, extractCompilerFlags);

if (message != null)
Debug.LogError($"Unexpected error while trying to initialize the burst JIT compiler: {message}");
}
}
}
2 changes: 1 addition & 1 deletion Editor/Mono/Collab/AssetAccess.cs
Expand Up @@ -73,7 +73,7 @@ private static bool TryGetPrefabGUID(UnityEngine.Object gameObject, out string a

if (prefabType == PrefabType.PrefabInstance)
{
prefabObject = PrefabUtility.GetPrefabParent(gameObject);
prefabObject = PrefabUtility.GetCorrespondingObjectFromSource(gameObject);
}
else if (prefabType == PrefabType.Prefab)
{
Expand Down
26 changes: 8 additions & 18 deletions Editor/Mono/Collab/Collab.bindings.cs
Expand Up @@ -2,31 +2,21 @@
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System;
using UnityEngine;
using UnityEngine.Bindings;
using UnityEngine.Scripting;

namespace UnityEditor.Collaboration
{
[NativeHeader("Editor/Src/Collab/CollabBindings.h")]
[NativeHeader("Editor/Src/Collab/Collab.h")]
partial class Collab
{
[NativeThrows]
[FreeFunction("GetRevisions")]
private static extern Revision[] InternalGetRevisions(
bool withChanges = false, int startIndex = 0, int numRevisions = -1);

public Revision[] GetRevisions(bool withChanges = false, int startIndex = 0, int numRevisions = -1)
{
return InternalGetRevisions(withChanges, startIndex, numRevisions);
}

[NativeThrows]
[FreeFunction("GetRevisionsData")]
private static extern RevisionsData InternalGetRevisionsData(
[StaticAccessor("Collab::Get()", StaticAccessorType.Arrow)]
public static extern int GetRevisionsData(
bool withChanges, int startIndex, int numRevisions);

public RevisionsData GetRevisionsData(bool withChanges, int startIndex, int numRevisions)
{
return InternalGetRevisionsData(withChanges, startIndex, numRevisions);
}
[StaticAccessor("Collab::Get()", StaticAccessorType.Arrow)]
public static extern RevisionsData PopulateRevisionsData(IntPtr nativeData);
}
}
38 changes: 20 additions & 18 deletions Editor/Mono/Collab/Collab.cs
Expand Up @@ -17,6 +17,7 @@
namespace UnityEditor.Collaboration
{
internal delegate void StateChangedDelegate(CollabInfo info);
internal delegate void ErrorDelegate();

[Flags]
internal enum CollabOperation : ulong
Expand Down Expand Up @@ -51,6 +52,8 @@ internal partial class Collab
public event StateChangedDelegate StateChanged;
public event StateChangedDelegate RevisionUpdated;
public event StateChangedDelegate JobsCompleted;
public event ErrorDelegate ErrorOccurred;
public event ErrorDelegate ErrorCleared;

private static Collab s_Instance;
private static bool s_IsFirstStateChange = true;
Expand Down Expand Up @@ -117,24 +120,6 @@ public static string GetProjectClientType()
return string.IsNullOrEmpty(cvalue) ? clientType[0] : cvalue;
}

[MenuItem("Window/Collab/Get Revisions", false, 1000, true)]
public static void TestGetRevisions()
{
Revision[] revisions = instance.GetRevisions();
if (revisions.Length == 0)
{
Debug.Log("No revisions");
return;
}

int num = revisions.Length;
foreach (Revision revision in revisions)
{
Debug.Log("Revision #" + num + ": " + revision.revisionID);
num--;
}
}

public static Collab instance
{
get
Expand Down Expand Up @@ -269,6 +254,7 @@ private static void OnStateChanged()
}
}

[RequiredByNativeCode]
private static void OnRevisionUpdated()
{
var handler = instance.RevisionUpdated;
Expand All @@ -278,6 +264,22 @@ private static void OnRevisionUpdated()
}
}

[RequiredByNativeCode]
private static void SetCollabError()
{
var handler = instance.ErrorOccurred;
if (handler != null)
handler();
}

[RequiredByNativeCode]
private static void ClearCollabError()
{
var handler = instance.ErrorCleared;
if (handler != null)
handler();
}

private static void OnJobsCompleted()
{
var handler = instance.JobsCompleted;
Expand Down
70 changes: 33 additions & 37 deletions Editor/Mono/Collab/CollabHistoryWindow.cs
Expand Up @@ -39,7 +39,6 @@ public static bool ValidateShowHistoryWindow()
VisualElement m_Container;
PagedListView m_Pager;
int m_ItemsPerPage = 5;
string m_ErrMessage;
string m_InProgressRev;
bool m_RevisionActionsEnabled;

Expand Down Expand Up @@ -138,7 +137,7 @@ public void SetupGUI()

var waitingView = new StatusView()
{
message = "Connecting...",
message = "Updating...",
};

var historyView = new ScrollView() { name = "HistoryContainer", showHorizontal = false};
Expand Down Expand Up @@ -183,38 +182,41 @@ public void UpdateRevisions(IEnumerable<RevisionData> datas, string tip, int tot
var isFullDateObtained = false; // Has everything from this date been obtained?
m_HistoryItems.Clear();

DateTime currentDate = DateTime.MinValue;
foreach (var data in datas)
if (datas != null)
{
if (data.timeStamp.Date != currentDate.Date)
DateTime currentDate = DateTime.MinValue;
foreach (var data in datas)
{
elements.Add(new CollabHistoryRevisionLine(data.timeStamp, isFullDateObtained));
currentDate = data.timeStamp;
if (data.timeStamp.Date != currentDate.Date)
{
elements.Add(new CollabHistoryRevisionLine(data.timeStamp, isFullDateObtained));
currentDate = data.timeStamp;
}

var item = new CollabHistoryItem(data);
m_HistoryItems.Add(item);

var container = new VisualContainer();
container.style.flexDirection = FlexDirection.Row;
if (data.current)
{
isFullDateObtained = true;
container.AddToClassList("currentRevision");
container.AddToClassList("obtainedRevision");
}
else if (data.obtained)
{
container.AddToClassList("obtainedRevision");
}
else
{
container.AddToClassList("absentRevision");
}
// If we use the index as-is, the latest commit will become #1, but we want it to be last
container.Add(new CollabHistoryRevisionLine(data.index));
container.Add(item);
elements.Add(container);
}

var item = new CollabHistoryItem(data);
m_HistoryItems.Add(item);

var container = new VisualContainer();
container.style.flexDirection = FlexDirection.Row;
if (data.current)
{
isFullDateObtained = true;
container.AddToClassList("currentRevision");
container.AddToClassList("obtainedRevision");
}
else if (data.obtained)
{
container.AddToClassList("obtainedRevision");
}
else
{
container.AddToClassList("absentRevision");
}
// If we use the index as-is, the latest commit will become #1, but we want it to be last
container.Add(new CollabHistoryRevisionLine(data.index));
container.Add(item);
elements.Add(container);
}

m_Pager.totalItems = totalRevisions;
Expand Down Expand Up @@ -244,12 +246,6 @@ public int itemsPerPage
}
}

public string errMessage
{
private get { return m_ErrMessage; }
set { m_ErrMessage = value; }
}

public PageChangeAction OnPageChangeAction
{
set { m_Pager.OnPageChange = value; }
Expand Down
53 changes: 42 additions & 11 deletions Editor/Mono/Collab/Presenters/CollabHistoryPresenter.cs
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System.Collections.Generic;
using UnityEditor.Connect;
using UnityEditor.Web;

Expand All @@ -15,8 +16,11 @@ internal class CollabHistoryPresenter
IRevisionsService m_Service;
ConnectInfo m_ConnectState;
CollabInfo m_CollabState;
bool m_IsCollabError;
int m_TotalRevisions;
int m_CurrentPage;
bool m_FetchInProgress;

BuildAccess m_BuildAccess;
string m_ProgressRevision;
public bool BuildServiceEnabled {get; set; }
Expand All @@ -36,13 +40,17 @@ public void OnWindowEnabled()
Collab.instance.StateChanged += OnCollabStateChanged;
Collab.instance.RevisionUpdated += OnCollabRevisionUpdated;
Collab.instance.JobsCompleted += OnCollabJobsCompleted;
Collab.instance.ErrorOccurred += OnCollabError;
Collab.instance.ErrorCleared += OnCollabErrorCleared;
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
m_Service.FetchRevisionsCallback += OnFetchRevisions;

if (Collab.instance.IsConnected())
{
m_ConnectState = UnityConnect.instance.GetConnectInfo();
m_CollabState = Collab.instance.GetCollabInfo();
}
// Copy the initialized fields of the collab info, even if the instance hasn't connected yet.
m_CollabState = Collab.instance.GetCollabInfo();

m_Window.revisionActionsEnabled = !EditorApplication.isPlayingOrWillChangePlaymode;

Expand Down Expand Up @@ -133,6 +141,18 @@ private void OnCollabJobsCompleted(CollabInfo state)
m_ProgressRevision = null;
}

private void OnCollabError()
{
m_IsCollabError = true;
m_Window.UpdateState(RecalculateState(), false);
}

private void OnCollabErrorCleared()
{
m_IsCollabError = false;
m_Window.UpdateState(RecalculateState(), false);
}

private void OnPlayModeStateChanged(PlayModeStateChange stateChange)
{
// If entering play mode, disable
Expand All @@ -151,11 +171,6 @@ private void OnPlayModeStateChanged(PlayModeStateChange stateChange)

private HistoryState RecalculateState()
{
if (m_ConnectState.error)
{
m_Window.errMessage = m_ConnectState.lastErrorMsg;
return HistoryState.Error;
}
if (!m_ConnectState.online)
return HistoryState.Offline;
if (m_ConnectState.maintenance || m_CollabState.maintenance)
Expand All @@ -166,8 +181,10 @@ private HistoryState RecalculateState()
return HistoryState.NoSeat;
if (!Collab.instance.IsCollabEnabledForCurrentProject())
return HistoryState.Disabled;
if (!Collab.instance.IsConnected() || !m_CollabState.ready)
if (!Collab.instance.IsConnected() || !m_CollabState.ready || m_FetchInProgress)
return HistoryState.Waiting;
if (m_ConnectState.error || m_IsCollabError)
return HistoryState.Error;

return HistoryState.Ready;
}
Expand Down Expand Up @@ -210,10 +227,24 @@ public void ShowServicePage()

public void OnUpdatePage(int page)
{
var revs = m_Service.GetRevisions(page * k_ItemsPerPage, k_ItemsPerPage);
m_TotalRevisions = revs.RevisionsInRepo;
var items = m_Factory.GenerateElements(revs.Revisions, m_TotalRevisions, page * k_ItemsPerPage, m_Service.tipRevision, m_Window.inProgressRevision,
m_Window.revisionActionsEnabled, BuildServiceEnabled, m_Service.currentUser);
m_FetchInProgress = true;
m_Service.GetRevisions(page * k_ItemsPerPage, k_ItemsPerPage);
m_Window.UpdateState(RecalculateState(), false);
m_CurrentPage = page;
}

private void OnFetchRevisions(RevisionsResult data)
{
m_FetchInProgress = false;
IEnumerable<RevisionData> items = null;
if (data != null)
{
m_TotalRevisions = data.RevisionsInRepo;
items = m_Factory.GenerateElements(data.Revisions, m_TotalRevisions, m_CurrentPage * k_ItemsPerPage, m_Service.tipRevision, m_Window.inProgressRevision, m_Window.revisionActionsEnabled, BuildServiceEnabled, m_Service.currentUser);
}

// State must be recalculated prior to inserting items
m_Window.UpdateState(RecalculateState(), false);
m_Window.UpdateRevisions(items, m_Service.tipRevision, m_TotalRevisions);
}

Expand Down
49 changes: 33 additions & 16 deletions Editor/Mono/Collab/RevisionsService.cs
Expand Up @@ -2,12 +2,16 @@
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System;
using System.Collections.Generic;
using UnityEditor.Collaboration;
using UnityEditor.Connect;
using UnityEngine.Scripting;

namespace UnityEditor.Collaboration
{
delegate void RevisionsDelegate(RevisionsResult revisionsResult);

internal class RevisionsResult
{
public List<Revision> Revisions = new List<Revision>();
Expand All @@ -24,39 +28,52 @@ public void Clear()

internal interface IRevisionsService
{
RevisionsResult GetRevisions(int offset, int count);
event RevisionsDelegate FetchRevisionsCallback;
void GetRevisions(int offset, int count);
string tipRevision { get; }
string currentUser { get; }
}

internal class RevisionsService : IRevisionsService
{
public event RevisionsDelegate FetchRevisionsCallback;
protected Collab collab;
protected UnityConnect connect;
protected RevisionsResult history;
protected int historyOffset = 0;
private static RevisionsService instance;

public string tipRevision { get { return collab.collabInfo.tip; } }
public string currentUser { get { return connect.GetUserInfo().userName; } }

public RevisionsService(Collab collabInstance, UnityConnect connectInstance)
{
collab = collabInstance;
connect = connectInstance;
history = new RevisionsResult();
instance = this;
}

public RevisionsResult GetRevisions(int offset, int count)
public void GetRevisions(int offset, int count)
{
// For now, clear out the local cache and just load what they ask for
history.Clear();
// TODO: Handle exception if call fails
var data = collab.GetRevisionsData(true, offset, count);
history.Revisions.AddRange(data.Revisions);
history.RevisionsInRepo = data.RevisionsInRepo;
historyOffset = data.RevisionOffset;

return history;
// Only send down request for the desired data.
Collab.GetRevisionsData(true, offset, count);
}

public string tipRevision { get { return collab.collabInfo.tip; } }
public string currentUser { get { return connect.GetUserInfo().userName; } }
[RequiredByNativeCode]
private static void OnFetchRevisions(IntPtr nativeData)
{
RevisionsService service = instance;
if (service == null || service.FetchRevisionsCallback == null)
return;

RevisionsResult history = null;
if (nativeData != IntPtr.Zero)
{
RevisionsData data = Collab.PopulateRevisionsData(nativeData);
history = new RevisionsResult();
history.Revisions.AddRange(data.Revisions);
history.RevisionsInRepo = data.RevisionsInRepo;
}

service.FetchRevisionsCallback(history);
}
}
}
17 changes: 9 additions & 8 deletions Editor/Mono/Collab/Views/CollabHistoryDropDown.cs
Expand Up @@ -2,7 +2,6 @@
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System.Linq;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using System.Collections.Generic;
Expand All @@ -12,14 +11,16 @@ namespace UnityEditor.Collaboration
{
internal class CollabHistoryDropDown : VisualElement
{
private readonly VisualElement m_FilesContainer;
private readonly Label m_ToggleLabel;
private int m_ChangesTotal;
readonly VisualElement m_FilesContainer;
readonly Label m_ToggleLabel;
int m_ChangesTotal;
string m_RevisionId;

public CollabHistoryDropDown(ICollection<ChangeData> changes, int changesTotal, bool changesTruncated)
public CollabHistoryDropDown(ICollection<ChangeData> changes, int changesTotal, bool changesTruncated, string revisionId)
{
m_FilesContainer = new VisualElement();
m_ChangesTotal = changesTotal;
m_RevisionId = revisionId;

m_ToggleLabel = new Label(ToggleText(false));
m_ToggleLabel.AddManipulator(new Clickable(ToggleDropdown));
Expand Down Expand Up @@ -62,10 +63,10 @@ private string ToggleText(bool open)

private void ShowAllClick()
{
var host = UnityConnect.instance.GetConfigurationURL(CloudConfigUrl.CloudCollab);
var org = UnityConnect.instance.GetOrganizationForeignKey();
var host = UnityConnect.instance.GetConfigurationURL(CloudConfigUrl.CloudServicesDashboard);
var org = UnityConnect.instance.GetOrganizationId();
var proj = UnityConnect.instance.GetProjectGUID();
var url = string.Format("{0}/orgs/{1}/projects/{2}/assets", host, org, proj);
var url = string.Format("{0}/collab/orgs/{1}/projects/{2}/commits?commit={3}", host, org, proj, m_RevisionId);
Application.OpenURL(url);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/Collab/Views/CollabHistoryItem.cs
Expand Up @@ -69,7 +69,7 @@ public CollabHistoryItem(RevisionData data)
m_Description = new Label(m_FullDescription);
}
m_Description.name = "RevisionDescription";
var dropdown = new CollabHistoryDropDown(data.changes, data.changesTotal, data.changesTruncated);
var dropdown = new CollabHistoryDropDown(data.changes, data.changesTotal, data.changesTruncated, data.id);
if (data.current)
{
m_Button = new Button(Restore) {name = "ActionButton", text = "Restore"};
Expand Down
1 change: 0 additions & 1 deletion Editor/Mono/Collab/Views/ICollabHistoryWindow.cs
Expand Up @@ -69,7 +69,6 @@ internal interface ICollabHistoryWindow

bool revisionActionsEnabled { get; set; }
int itemsPerPage { set; }
string errMessage { set; }
string inProgressRevision { get; set; }
PageChangeAction OnPageChangeAction { set; }
RevisionAction OnGoBackAction { set; }
Expand Down
7 changes: 5 additions & 2 deletions Editor/Mono/Commands/GOCreationCommands.cs
Expand Up @@ -21,7 +21,7 @@ internal static void Place(GameObject go, GameObject parent)
if (parent != null)
{
var transform = go.transform;
transform.SetParent(parent.transform, false);
Undo.SetTransformParent(transform, parent.transform, "Reparenting");
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
transform.localScale = Vector3.one;
Expand All @@ -30,7 +30,10 @@ internal static void Place(GameObject go, GameObject parent)
if (parent.GetComponent<RectTransform>())
ObjectFactory.AddComponent<RectTransform>(go);
}
SceneView.PlaceGameObjectInFrontOfSceneView(go);
else
{
SceneView.PlaceGameObjectInFrontOfSceneView(go);
}
EditorWindow.FocusWindowIfItsOpen<SceneHierarchyWindow>();
Selection.activeGameObject = go;
}
Expand Down
105 changes: 105 additions & 0 deletions Editor/Mono/ContainerWindow.bindings.cs
@@ -0,0 +1,105 @@
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using UnityEngine;
using UnityEngine.Bindings;

namespace UnityEditor
{
// How ContainerWindows are visualized. Used with ContainerWindow.Show
internal enum ShowMode
{
// Show as a normal window with max, min & close buttons.
NormalWindow = 0,
// Used for a popup menu and tooltip. On mac this means light shadow and no titlebar.
PopupMenu = 1,
// Utility window - floats above the app. Disappears when app loses focus.
Utility = 2,
// Window has no shadow or decorations. Used internally for dragging stuff around.
NoShadow = 3,
// The Unity main window. On mac, this is the same as NormalWindow, except window doesn't have a close button.
MainWindow = 4,
// Aux windows. The ones that close the moment you move the mouse out of them.
AuxWindow = 5,
// Like PopupMenu, but allows keyboard focus (e.g. AddComponentWindow)
PopupMenuWithKeyboardFocus = 6
}

//[StaticAccessor("ContainerWindowBindings", StaticAccessorType.DoubleColon)]
[NativeHeader("Editor/Src/ContainerWindow.bindings.h")]
internal partial class ContainerWindow
{
private const string k_ScriptingPrefix = "ContainerWindowBindings::";

// Pixel-position on screen.
public extern Rect position
{
[FreeFunction(k_ScriptingPrefix + "GetPosition", HasExplicitThis = true)] get;
[FreeFunction(k_ScriptingPrefix + "SetPosition", HasExplicitThis = true)] set;
}

public extern bool maximized {[FreeFunction(k_ScriptingPrefix + "IsWindowMaximized", HasExplicitThis = true)] get; }

[FreeFunction(k_ScriptingPrefix + "SetAlpha", HasExplicitThis = true)]
public extern void SetAlpha(float alpha);

// Used by invisible "under the mouse" window of the eye dropper.
[FreeFunction(k_ScriptingPrefix + "SetInvisible", HasExplicitThis = true)]
public extern void SetInvisible();

[FreeFunction(k_ScriptingPrefix + "IsZoomed", HasExplicitThis = true)]
public extern bool IsZoomed();

[FreeFunction(k_ScriptingPrefix + "DisplayAllViews", HasExplicitThis = true)]
public extern void DisplayAllViews();

[FreeFunction(k_ScriptingPrefix + "Minimize", HasExplicitThis = true)]
public extern void Minimize();

[FreeFunction(k_ScriptingPrefix + "ToggleMaximize", HasExplicitThis = true)]
public extern void ToggleMaximize();

[FreeFunction(k_ScriptingPrefix + "MoveInFrontOf", HasExplicitThis = true)]
public extern void MoveInFrontOf(ContainerWindow other);

[FreeFunction(k_ScriptingPrefix + "MoveBehindOf", HasExplicitThis = true)]
public extern void MoveBehindOf(ContainerWindow other);

// Fit a container window to the screen.
[FreeFunction(k_ScriptingPrefix + "FitWindowRectToScreen", HasExplicitThis = true)]
public extern Rect FitWindowRectToScreen(Rect r, bool forceCompletelyVisible, bool useMouseScreen);

// Close the editor window.
[FreeFunction(k_ScriptingPrefix + "InternalClose", HasExplicitThis = true)]
public extern void InternalClose();

[FreeFunction(k_ScriptingPrefix + "Internal_SetMinMaxSizes", HasExplicitThis = true)]
private extern void Internal_SetMinMaxSizes(Vector2 minSize, Vector2 maxSize);

[FreeFunction(k_ScriptingPrefix + "Internal_Show", HasExplicitThis = true)]
private extern void Internal_Show(Rect r, int showMode, Vector2 minSize, Vector2 maxSize);

[FreeFunction(k_ScriptingPrefix + "Internal_BringLiveAfterCreation", HasExplicitThis = true)]
private extern void Internal_BringLiveAfterCreation(bool displayImmediately, bool setFocus);

[FreeFunction(k_ScriptingPrefix + "Internal_SetTitle", HasExplicitThis = true)]
private extern void Internal_SetTitle(string title);

[FreeFunction(k_ScriptingPrefix + "SetBackgroundColor", HasExplicitThis = true)]
private extern void SetBackgroundColor(Color color);

[FreeFunction(k_ScriptingPrefix + "Internal_GetTopleftScreenPosition", HasExplicitThis = true)]
private extern Vector2 Internal_GetTopleftScreenPosition();

// Disables any repaints until freeze is set to false again.
[FreeFunction(k_ScriptingPrefix + "SetFreezeDisplay")]
public static extern void SetFreezeDisplay(bool freeze);

[FreeFunction(k_ScriptingPrefix + "GetOrderedWindowList")]
internal static extern void GetOrderedWindowList();

[FreeFunction(k_ScriptingPrefix + "FitRectToScreen")]
internal static extern Rect FitRectToScreen(Rect defaultRect, bool forceCompletelyVisible, bool useMouseScreen);
}
}
46 changes: 14 additions & 32 deletions Editor/Mono/ContainerWindow.cs
Expand Up @@ -3,41 +3,22 @@
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using IntPtr = System.IntPtr;
using System;

namespace UnityEditor
{
// See ContainerWindow.bindings for bindings

[StructLayout(LayoutKind.Sequential)]
internal partial class ContainerWindow : ScriptableObject
{
[SerializeField]
MonoReloadableIntPtr m_WindowPtr;

#pragma warning disable 0414
[SerializeField]
Rect m_PixelRect;
[SerializeField]
int m_ShowMode;
[SerializeField]
string m_Title = "";
#pragma warning restore 0414

[SerializeField]
[UnityEngine.Serialization.FormerlySerializedAs("m_MainView")]
View m_RootView;
[SerializeField]
Vector2 m_MinSize = new Vector2(120, 80);
[SerializeField]
Vector2 m_MaxSize = new Vector2(4000, 4000);
[SerializeField] MonoReloadableIntPtr m_WindowPtr;
[SerializeField] Rect m_PixelRect;
[SerializeField] int m_ShowMode;
[SerializeField] string m_Title = "";

[SerializeField, UnityEngine.Serialization.FormerlySerializedAs("m_MainView")] View m_RootView;
[SerializeField] Vector2 m_MinSize = new Vector2(120, 80);
[SerializeField] Vector2 m_MaxSize = new Vector2(4000, 4000);

internal bool m_DontSaveToLayout = false;

Expand Down Expand Up @@ -102,7 +83,7 @@ static Color skinBackgroundColor
}

// Show the editor window.
public void Show(ShowMode showMode, bool loadPosition, bool displayImmediately)
public void Show(ShowMode showMode, bool loadPosition, bool displayImmediately)
{
if (showMode == ShowMode.AuxWindow)
showMode = ShowMode.Utility;
Expand Down Expand Up @@ -187,8 +168,7 @@ internal bool IsNotDocked()

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

(rootView as SplitView != null &&
rootView.children.Length == 1 &&
(rootView is SplitView &&
rootView.children.Length == 1 &&
rootView.children[0] is DockArea &&
((DockArea)rootView.children[0]).m_Panes.Count == 1)
Expand Down Expand Up @@ -290,8 +270,7 @@ internal void AddToWindowList()
// TODO: Handle title bar height and other things
public Vector2 WindowToScreenPoint(Vector2 windowPoint)
{
Vector2 hmm;
Internal_GetTopleftScreenPosition(out hmm);
Vector2 hmm = Internal_GetTopleftScreenPosition();
return windowPoint + hmm;// + new Vector2 (position.x, position.y) + hmm;
}

Expand Down Expand Up @@ -378,7 +357,10 @@ public void HandleWindowDecorationStart(Rect windowPosition)

BeginTitleBarButtons(windowPosition);
if (TitleBarButton(close))
{
Close();
GUIUtility.ExitGUI();
}
if (macEditor && TitleBarButton(min))
{
Minimize();
Expand Down
66 changes: 66 additions & 0 deletions Editor/Mono/CustomInspectorStubs.cs
@@ -0,0 +1,66 @@
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using UnityEngine;
using UnityEditorInternal;

namespace UnityEditor
{
// Exposed as internal, editor-only, because we only need it do make a custom inspector
[NativeClass(null)]
internal sealed class PhysicsManager : ProjectSettingsBase
{
private PhysicsManager() {}
}

// Exposed as internal, editor-only, because we only need it do make a custom inspector
[NativeClass(null)]
internal sealed class AudioManager : ProjectSettingsBase
{
private AudioManager() {}
}

// Exposed as internal, editor-only, because we only need it do make a custom inspector
[NativeClass(null)]
internal sealed class Physics2DSettings : ProjectSettingsBase
{
private Physics2DSettings() {}
}

// Exposed as internal, editor-only, because we only need it do make a custom inspector
[NativeClass(null)]
[ExcludeFromPreset]
internal sealed class MonoManager : ProjectSettingsBase
{
private MonoManager() {}
}

// Exposed as internal, editor-only, because we only need it do make a custom inspector
[NativeClass(null)]
internal sealed class TagManager : ProjectSettingsBase
{
private TagManager() {}
}

// Exposed as internal, editor-only, because we only need it do make a custom inspector
[NativeClass(null)]
internal sealed class InputManager : ProjectSettingsBase
{
private InputManager() {}
}

// Exposed as internal, editor-only, because we only need it do make a custom inspector
[NativeClass(null)]
internal sealed class TimeManager : ProjectSettingsBase
{
private TimeManager() {}
}

// Exposed as internal, editor-only, because we only need it do make a custom inspector
[NativeClass(null)]
internal sealed class UnityConnectSettings : ProjectSettingsBase
{
private UnityConnectSettings() {}
}
}
30 changes: 26 additions & 4 deletions Editor/Mono/DeploymentTargets/DefaultDeploymentTargetsExtension.cs
Expand Up @@ -5,9 +5,14 @@
using System;
using System.Collections.Generic;
using UnityEditor.Modules;
using UnityEditorInternal;

namespace UnityEditor.DeploymentTargets
{
internal class DefaultDeploymentTargetsMainThreadContext : IDeploymentTargetsMainThreadContext
{
}

internal class DefaultDeploymentTargetInfo : IDeploymentTargetInfo
{
public virtual FlagSet<DeploymentTargetSupportFlags> GetSupportFlags()
Expand All @@ -20,26 +25,43 @@ public virtual TargetCheckResult CheckTarget(DeploymentTargetRequirements target
return new TargetCheckResult();
}

public string GetDisplayName()
public virtual string GetDisplayName()
{
return "";
}

public virtual bool SupportsLaunchBuild(BuildProperties buildProperties)
{
return GetSupportFlags().HasFlags(DeploymentTargetSupportFlags.Launch) && CheckTarget(buildProperties.GetTargetRequirements()).Passed();
}
}

internal abstract class DefaultDeploymentTargetsExtension
: IDeploymentTargetsExtension
{
public virtual List<DeploymentTargetIdAndStatus> GetKnownTargets(ProgressHandler progressHandler = null)
public virtual IDeploymentTargetsMainThreadContext GetMainThreadContext(bool setup)
{
CheckGetMainThreadContextCalledOnMainThread();
return new DefaultDeploymentTargetsMainThreadContext();
}

protected void CheckGetMainThreadContextCalledOnMainThread()
{
if (!InternalEditorUtility.CurrentThreadIsMainThread())
throw new NotSupportedException("Deployment targets main thread context can only be retrieved from the main thread.");
}

public virtual List<DeploymentTargetIdAndStatus> GetKnownTargets(IDeploymentTargetsMainThreadContext context, ProgressHandler progressHandler = null)
{
return new List<DeploymentTargetIdAndStatus>();
}

public virtual IDeploymentTargetInfo GetTargetInfo(DeploymentTargetId targetId, ProgressHandler progressHandler = null)
public virtual IDeploymentTargetInfo GetTargetInfo(IDeploymentTargetsMainThreadContext context, DeploymentTargetId targetId, ProgressHandler progressHandler = null)
{
return new DefaultDeploymentTargetInfo();
}

public virtual void LaunchBuildOnTarget(BuildProperties buildProperties, DeploymentTargetId targetId, ProgressHandler progressHandler = null)
public virtual void LaunchBuildOnTarget(IDeploymentTargetsMainThreadContext context, BuildProperties buildProperties, DeploymentTargetId targetId, ProgressHandler progressHandler = null)
{
throw new NotSupportedException();
}
Expand Down
69 changes: 27 additions & 42 deletions Editor/Mono/DeploymentTargets/DeploymentTargetManager.cs
Expand Up @@ -4,84 +4,69 @@

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.Modules;
using UnityEditor.Build.Reporting;
using UnityEngine;

namespace UnityEditor.DeploymentTargets
{
internal class DeploymentTargetManager
class DeploymentTargetManager
{
const string kExtensionErrorMessage = "Platform does not implement DeploymentTargetsExtension";
const string k_ExtensionErrorMessage = "Platform does not implement DeploymentTargetsExtension";

private static IDeploymentTargetsExtension GetExtension(BuildTargetGroup targetGroup, BuildTarget buildTarget)
{
IDeploymentTargetsExtension extension = ModuleManager.GetDeploymentTargetsExtension(targetGroup, buildTarget);
if (extension == null)
throw new NotSupportedException(kExtensionErrorMessage);
return extension;
}

public static bool IsExtensionSupported(BuildTargetGroup targetGroup, BuildTarget buildTarget)
{
return ModuleManager.GetDeploymentTargetsExtension(targetGroup, buildTarget) != null;
}
readonly IDeploymentTargetsExtension m_Extension;
readonly IDeploymentTargetsMainThreadContext m_Context;

public static IDeploymentTargetInfo GetTargetInfo(BuildTargetGroup targetGroup, BuildTarget buildTarget, DeploymentTargetId targetId)
public static DeploymentTargetManager CreateInstance(BuildTargetGroup targetGroup, BuildTarget buildTarget, bool setup = true)
{
IDeploymentTargetsExtension extension = GetExtension(targetGroup, buildTarget);
return extension.GetTargetInfo(targetId);
var extension = GetExtension(targetGroup, buildTarget);
var context = extension.GetMainThreadContext(setup);
return context != null ? new DeploymentTargetManager(extension, context) : null;
}

public static bool SupportsLaunchBuild(IDeploymentTargetInfo info, BuildProperties buildProperties)
DeploymentTargetManager(IDeploymentTargetsExtension extension, IDeploymentTargetsMainThreadContext context)
{
return info.GetSupportFlags().HasFlags(DeploymentTargetSupportFlags.Launch) &&
info.CheckTarget(buildProperties.GetTargetRequirements()).Passed();
m_Extension = extension;
m_Context = context;
}

public static bool SupportsLaunchBuild(IDeploymentTargetInfo info, BuildReport buildReport)
static IDeploymentTargetsExtension GetExtension(BuildTargetGroup targetGroup, BuildTarget buildTarget)
{
return SupportsLaunchBuild(info, BuildProperties.GetFromBuildReport(buildReport));
var extension = ModuleManager.GetDeploymentTargetsExtension(targetGroup, buildTarget);
if (extension == null)
throw new NotSupportedException(k_ExtensionErrorMessage);
return extension;
}

public static void LaunchBuildOnTarget(BuildTargetGroup targetGroup, BuildTarget buildTarget, BuildProperties buildProperties, DeploymentTargetId targetId, ProgressHandler progressHandler = null)
public IDeploymentTargetInfo GetTargetInfo(DeploymentTargetId targetId)
{
IDeploymentTargetsExtension extension = GetExtension(targetGroup, buildTarget);
extension.LaunchBuildOnTarget(buildProperties, targetId, progressHandler);
return m_Extension.GetTargetInfo(m_Context, targetId);
}

public static void LaunchBuildOnTarget(BuildTargetGroup targetGroup, BuildReport buildReport, DeploymentTargetId targetId, ProgressHandler progressHandler = null)
public void LaunchBuildOnTarget(BuildProperties buildProperties, DeploymentTargetId targetId, ProgressHandler progressHandler = null)
{
LaunchBuildOnTarget(targetGroup, buildReport.summary.platform, BuildProperties.GetFromBuildReport(buildReport), targetId, progressHandler);
m_Extension.LaunchBuildOnTarget(m_Context, buildProperties, targetId, progressHandler);
}

public static List<DeploymentTargetIdAndStatus> GetKnownTargets(BuildTargetGroup targetGroup, BuildTarget buildTarget)
public List<DeploymentTargetIdAndStatus> GetKnownTargets()
{
IDeploymentTargetsExtension extension = GetExtension(targetGroup, buildTarget);
return extension.GetKnownTargets();
return m_Extension.GetKnownTargets(m_Context);
}

// Launch a build on any target on a platform
public static List<DeploymentTargetId> FindValidTargetsForLaunchBuild(BuildTargetGroup targetGroup, BuildTarget buildTarget, BuildProperties buildProperties)
public List<DeploymentTargetId> FindValidTargetsForLaunchBuild(BuildProperties buildProperties)
{
IDeploymentTargetsExtension extension = GetExtension(targetGroup, buildTarget);
List<DeploymentTargetId> validTargetIds = new List<DeploymentTargetId>();
List<DeploymentTargetIdAndStatus> knownTargets = extension.GetKnownTargets();
var validTargetIds = new List<DeploymentTargetId>();
var knownTargets = m_Extension.GetKnownTargets(m_Context);
foreach (var target in knownTargets)
{
if (target.status == DeploymentTargetStatus.Ready)
{
if (SupportsLaunchBuild(extension.GetTargetInfo(target.id), buildProperties))
var targetInfo = m_Extension.GetTargetInfo(m_Context, target.id);
if (targetInfo.SupportsLaunchBuild(buildProperties))
validTargetIds.Add(target.id);
}
}
return validTargetIds;
}

public static List<DeploymentTargetId> FindValidTargetsForLaunchBuild(BuildTargetGroup targetGroup, BuildReport buildReport)
{
return FindValidTargetsForLaunchBuild(targetGroup, buildReport.summary.platform, BuildProperties.GetFromBuildReport(buildReport));
}
}
}
19 changes: 16 additions & 3 deletions Editor/Mono/DeploymentTargets/IDeploymentTargetsExtension.cs
Expand Up @@ -102,6 +102,12 @@ internal interface IDeploymentTargetInfo
TargetCheckResult CheckTarget(DeploymentTargetRequirements targetRequirements);

string GetDisplayName();

bool SupportsLaunchBuild(BuildProperties buildProperties);
}

internal interface IDeploymentTargetsMainThreadContext
{
}

internal class DeploymentOperationAbortedException : Exception {}
Expand All @@ -122,20 +128,27 @@ internal class CorruptBuildException : DeploymentOperationFailedException

internal interface IDeploymentTargetsExtension
{
// Returns context object populated with data that other methods can access from any thread.
// setup - Pass true to setup platform if it hasn't been already setup (e.g. display dialog box to select SDK path). Throws exception if user cancels setup process.
// Pass false to return null if platform hasn't been already setup. This is useful when this method is called from UI draw event.
// Displaying dialog boxes at that point breaks UI. Let the user know what's going on by displaying informational label or something like that.
// Can NOT be called from a background thread
IDeploymentTargetsMainThreadContext GetMainThreadContext(bool setup = true);

// Returns a list of all known targets and their status
// Can be called from a background thread
List<DeploymentTargetIdAndStatus> GetKnownTargets(ProgressHandler progressHandler = null);
List<DeploymentTargetIdAndStatus> GetKnownTargets(IDeploymentTargetsMainThreadContext context, ProgressHandler progressHandler = null);

// Returns info for a target
// Throws DeploymentOperationFailedException (or one of its subclasses) is something goes wrong.
// Throws DeploymentOperationAbortedException if process is cancelled by the user.
// Can be called from a background thread
IDeploymentTargetInfo GetTargetInfo(DeploymentTargetId targetId, ProgressHandler progressHandler = null);
IDeploymentTargetInfo GetTargetInfo(IDeploymentTargetsMainThreadContext context, DeploymentTargetId targetId, ProgressHandler progressHandler = null);

// Launches a build on a target
// Throws DeploymentOperationFailedException (or one of its subclasses) is something goes wrong.
// Throws DeploymentOperationAbortedException if process is cancelled by the user.
// Can be called from a background thread
void LaunchBuildOnTarget(BuildProperties buildProperties, DeploymentTargetId targetId, ProgressHandler progressHandler = null);
void LaunchBuildOnTarget(IDeploymentTargetsMainThreadContext context, BuildProperties buildProperties, DeploymentTargetId targetId, ProgressHandler progressHandler = null);
}
}
119 changes: 119 additions & 0 deletions Editor/Mono/DragAndDrop.bindings.cs
@@ -0,0 +1,119 @@
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using UnityEngine;
using Object = UnityEngine.Object;
using System.Collections;
using UnityEngine.Bindings;
using UnityEngine.Scripting;

namespace UnityEditor
{
// Visual indication mode for Drag & Drop operation.
public enum DragAndDropVisualMode
{
None = 0, // No indication (drag should not be performed).
Copy = 1, // Copy dragged objects.
Link = 2, // Link dragged objects to target.
Move = 16, // Move dragged objects.
Generic = 4, // Generic drag operation.
Rejected = 32 // Rejected drag operation.
}

// Editor drag & drop operations.
[NativeHeader("Editor/Platform/Interface/DragAndDrop.h"),
StaticAccessor("GetDragAndDrop()", StaticAccessorType.Dot)]
public class DragAndDrop
{
private static Hashtable s_GenericData;

// HandleDelayedDrag can be used to start a drag and drop
internal static bool HandleDelayedDrag(Rect position, int id, Object objectToDrag)
{
Event evt = Event.current;
switch (evt.GetTypeForControl(id))
{
case EventType.MouseDown:
if (position.Contains(evt.mousePosition) && evt.clickCount == 1)
{
if (evt.button == 0 && !(Application.platform == RuntimePlatform.OSXEditor && evt.control))
{
GUIUtility.hotControl = id;
DragAndDropDelay delay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), id);
delay.mouseDownPosition = evt.mousePosition;
return true;
}
}
break;
case EventType.MouseDrag:
if (GUIUtility.hotControl == id)
{
DragAndDropDelay delay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), id);
if (delay.CanStartDrag())
{
GUIUtility.hotControl = 0;
PrepareStartDrag();
Object[] references = { objectToDrag };
objectReferences = references;
StartDrag(ObjectNames.GetDragAndDropTitle(objectToDrag));
return true;
}
}
break;
}
return false;
}

// Clears drag & drop data.
public static void PrepareStartDrag()
{
s_GenericData = null;
PrepareStartDrag_Internal();
}

// Start a drag operation.
public static void StartDrag(string title)
{
if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseDrag)
{
StartDrag_Internal(title);
}
else
{
Debug.LogError("Drags can only be started from MouseDown or MouseDrag events");
}
}

[RequiredByNativeCode]
private static bool HasGenericDragData()
{
return s_GenericData != null;
}

// Get data associated with current drag and drop operation.
public static object GetGenericData(string type)
{
if (s_GenericData != null && s_GenericData.Contains(type))
return s_GenericData[type];
return null;
}

// Set data associated with current drag and drop operation.
public static void SetGenericData(string type, object data)
{
if (s_GenericData == null)
s_GenericData = new Hashtable();
s_GenericData[type] = data;
}

public static extern Object[] objectReferences {[NativeMethod("GetPPtrs")] get; [NativeMethod("SetPPtrs")] set; }
public static extern string[] paths { get; set; }
public static extern int activeControlID { get; set; }
public static extern DragAndDropVisualMode visualMode { get; set; }

public static extern void AcceptDrag();
[NativeMethod("PrepareStartDrag")] private static extern void PrepareStartDrag_Internal();
[NativeMethod("StartDrag")] private static extern void StartDrag_Internal(string title);
}
}
59 changes: 59 additions & 0 deletions Editor/Mono/DrawGizmo.cs
@@ -0,0 +1,59 @@
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System;

namespace UnityEditor
{
// Determines how a gizmo is drawn or picked in the Unity editor.
public enum GizmoType
{
// The gizmo can be picked in the editor.
Pickable = 1,

// Draw the gizmo if it is not selected or child of the selection.
NotInSelectionHierarchy = 2,

// Draw the gizmo if it is not selected.
NonSelected = 32,

// Draw the gizmo if it is selected.
Selected = 4,

// Draw the gizmo if it is active (shown in the inspector).
Active = 8,

// Draw the gizmo if it is selected or a child of the selection.
InSelectionHierarchy = 16,

[Obsolete("Use NotInSelectionHierarchy instead (UnityUpgradable) -> NotInSelectionHierarchy")]
NotSelected = -127,

[Obsolete("Use InSelectionHierarchy instead (UnityUpgradable) -> InSelectionHierarchy")]
SelectedOrChild = -127,
}

// The DrawGizmo attribute allows you to supply a gizmo renderer for any [[Component]].
public sealed class DrawGizmo : Attribute
{
// Defines when the gizmo should be invoked for drawing.
public DrawGizmo(GizmoType gizmo)
{
drawOptions = gizmo;
}

// Same as above. /drawnGizmoType/ determines of what type the object we are drawing the gizmo of has to be.
public DrawGizmo(GizmoType gizmo, Type drawnGizmoType)
{
drawnType = drawnGizmoType;
drawOptions = gizmo;
}

//*undocumented
public Type drawnType;

//*undocumented
public GizmoType drawOptions;
}
}
18 changes: 0 additions & 18 deletions Editor/Mono/EditorGUI.bindings.cs

This file was deleted.