Beispiel #1
0
    private static void StripAssembliesToLeaveOnlyMetadata(BuildTarget target, string stagingAreaDataManaged)
    {
        AssemblyReferenceChecker assemblyReferenceChecker = new AssemblyReferenceChecker();

        assemblyReferenceChecker.CollectReferences(stagingAreaDataManaged, true, 0f, false);
        EditorUtility.DisplayProgressBar("Removing bytecode from assemblies", "Stripping assemblies so that only metadata remains", 0.95f);
        MonoAssemblyStripping.MonoCilStrip(target, stagingAreaDataManaged, assemblyReferenceChecker.GetAssemblyFileNames());
    }
        public void PostProcess(BuildPostProcessArgs args)
        {
            base.m_PostProcessArgs = args;
            AssemblyReferenceChecker checker = new AssemblyReferenceChecker();

            checker.CollectReferences(args.stagingAreaDataManaged, false, 0f, true);
            bool flag = !string.IsNullOrEmpty(checker.WhoReferencesClass("UnityEngine.SocialPlatforms.GameCenter.GameCenterPlatform", true));

            this.SaveEditorOnlyPlayerSettingsToPlist();
            base.PostProcess();
            if (flag)
            {
                if (Application.platform != RuntimePlatform.OSXEditor)
                {
                    UnityEngine.Debug.LogWarning("OS X Standalone players with GameCenter support need to be built on an OS X machine in order to pass Mac App Store validation.");
                }
                else
                {
                    Console.WriteLine("Adding GameKit linkage to OS X binary.");
                    ProcessStartInfo info2 = new ProcessStartInfo {
                        FileName = Path.Combine(BuildPipeline.GetPlaybackEngineDirectory(args.target, args.options), "optool")
                    };
                    string[] textArray1 = new string[] { "install -c weak -p /System/Library/Frameworks/GameKit.framework/Versions/A/GameKit -t \"", this.m_PostProcessArgs.installPath, "/Contents/MacOS/", this.InstallNameWithoutExtension, "\"" };
                    info2.Arguments      = string.Concat(textArray1);
                    info2.CreateNoWindow = true;
                    ProcessStartInfo si      = info2;
                    Program          program = new Program(si);
                    program.Start();
                    while (!program.WaitForExit(100))
                    {
                    }
                    if (program.ExitCode != 0)
                    {
                        UnityEngine.Debug.LogError("Running optool to link GameKit failed\n" + si.FileName + " " + si.Arguments + "\n" + program.GetAllOutput());
                    }
                    program.Dispose();
                }
            }
        }
Beispiel #3
0
        private string PatchManifest(PostProcessorContext context, string manifest)
        {
            BuildTarget platform = context.Get <BuildTarget>("BuildTarget");

            string[]        components  = new string[] { this._stagingArea, "assets", "bin" };
            string          str         = Paths.Combine(components);
            AndroidManifest manifestXML = new AndroidManifest(manifest);
            string          location    = this.PreferredInstallLocationAsString();

            manifestXML.SetInstallLocation(location);
            manifestXML.SetDebuggable(this._developmentPlayer || Unsupported.IsDeveloperBuild());
            int    minSdkVersion = (int)PlayerSettings.Android.minSdkVersion;
            string glEsVersion   = "0x00020000";

            GraphicsDeviceType[] graphicsAPIs = PlayerSettings.GetGraphicsAPIs(platform);
            if (graphicsAPIs.Contains <GraphicsDeviceType>(GraphicsDeviceType.OpenGLES3) && (minSdkVersion >= 0x12))
            {
                glEsVersion = "0x00030000";
            }
            if (graphicsAPIs.Contains <GraphicsDeviceType>(GraphicsDeviceType.OpenGLES2))
            {
                glEsVersion = "0x00020000";
            }
            if ((glEsVersion == "0x00030000") && (PlayerSettings.openGLRequireES31 || PlayerSettings.openGLRequireES31AEP))
            {
                glEsVersion = "0x00030001";
            }
            manifestXML.AddGLESVersion(glEsVersion);
            if ((glEsVersion == "0x00030001") && PlayerSettings.openGLRequireES31AEP)
            {
                manifestXML.AddUsesFeature("android.hardware.opengles.aep", true);
            }
            if (EditorUserBuildSettings.androidBuildSubtarget != MobileTextureSubtarget.Generic)
            {
                this.CreateSupportsTextureElem(manifestXML, EditorUserBuildSettings.androidBuildSubtarget);
            }
            HashSet <string> set = new HashSet <string>(this.GetActivitiesWithMetadata(manifestXML, "unityplayer.UnityActivity", "true"));

            string[] other = new string[] { "com.unity3d.player.UnityPlayerNativeActivity", "com.unity3d.player.UnityPlayerActivity", "com.unity3d.player.UnityPlayerProxyActivity" };
            set.UnionWith(other);
            string orientationAttr = this.GetOrientationAttr();
            bool   flag            = false;

            foreach (string str5 in set)
            {
                flag = manifestXML.SetOrientation(str5, orientationAttr) || flag;
                flag = manifestXML.SetLaunchMode(str5, "singleTask") || flag;
                flag = manifestXML.SetConfigChanges(str5, AndroidManifest.AndroidConfigChanges) || flag;
            }
            if (!flag)
            {
                Debug.LogWarning($"Unable to find unity activity in manifest. You need to make sure orientation attribute is set to {orientationAttr} manually.");
            }
            manifestXML.SetApplicationFlag("isGame", PlayerSettings.Android.androidIsGame);
            if (PlayerSettings.Android.androidBannerEnabled)
            {
                manifestXML.SetApplicationBanner("@drawable/app_banner");
            }
            if ((PlayerSettings.Android.androidTVCompatibility && !manifestXML.HasLeanbackLauncherActivity()) && !manifestXML.AddLeanbackLauncherActivity())
            {
                Debug.LogWarning("No activity with LEANBACK_LAUNCHER or LAUNCHER categories found.\nThe build may not be compatible with Android TV. Specify an activity with LEANBACK_LAUNCHER or LAUNCHER category in the manifest, or disable Android TV compatibility in Player Settings.");
            }
            switch (PlayerSettings.Android.androidGamepadSupportLevel)
            {
            case AndroidGamepadSupportLevel.SupportsGamepad:
                manifestXML.AddUsesFeature("android.hardware.gamepad", false);
                break;

            case AndroidGamepadSupportLevel.RequiresGamepad:
                manifestXML.AddUsesFeature("android.hardware.gamepad", true);
                break;
            }
            if (PlayerSettings.virtualRealitySupported)
            {
                manifestXML.OverrideTheme("@android:style/Theme.Black.NoTitleBar.Fullscreen");
                int num2 = context.Get <int>("GearVRMinSdkVersion");
                if (PlayerSettings.Android.minSdkVersion < num2)
                {
                    Debug.LogWarning("GearVR requires Minimum API Level of 19");
                }
            }
            AssemblyReferenceChecker checker = new AssemblyReferenceChecker();
            bool collectMethods   = true;
            bool ignoreSystemDlls = true;

            string[] textArray3 = new string[] { str, "Data", "Managed" };
            string   path       = Paths.Combine(textArray3);

            checker.CollectReferences(path, collectMethods, 0f, ignoreSystemDlls);
            this.SetPermissionAttributes(context, manifestXML, checker);
            manifestXML.StripUnityLibEntryForNativeActitivy();
            manifestXML.SaveAs(manifest);
            return(manifestXML.packageName);
        }
Beispiel #4
0
        internal static void PostProcess(BuildTarget target, string stagingAreaDataUpperCase, string stagingArea, string stagingAreaDataManaged, string playerPackage, string installPath, string companyName, string productName, BuildOptions options)
        {
            bool  flag = (options & BuildOptions.AutoRunPlayer) != BuildOptions.CompressTextures;
            bool  developmentPlayer = (options & BuildOptions.Development) != BuildOptions.CompressTextures;
            float numSteps          = !flag ? ((float)2) : ((float)5);

            progress.Reset(numSteps);
            if (PlayerSettings.Tizen.deploymentTargetType == 2)
            {
                flag = false;
            }
            Regex  regex = new Regex("[^a-zA-Z_-]");
            string normalizedProductName = regex.Replace(productName, "").ToLower();
            string str2 = Path.Combine(playerPackage, "assets");

            if (!IsValidTizenBundleIdentifier(PlayerSettings.bundleIdentifier))
            {
                string message = "Please set the Bundle Identifier in the Player Settings.";
                message = (message + " The value must follow the convention 'com.YourCompanyName.YourProductName'") + " and can contain alphanumeric characters and underscore." + "\nEach segment must not start with a numeric character or underscore.";
                Selection.activeObject = Unsupported.GetSerializedAssetInterfaceSingleton("PlayerSettings");
                TizenUtilities.ShowErrDlgAndThrow("Bundle Identifier has not been set up correctly", message);
            }
            if (TizenUtilities.ThisIsAUnityTestProject())
            {
                PlayerSettings.Tizen.deploymentTargetType = 0;
            }
            if (PlayerSettings.Tizen.deploymentTargetType < 0)
            {
                string str4 = "Please select a Tizen deployment target.";
                str4 = str4 + " Press the Discover button in the Publishing section of Player Settings." + " Then select a type of target to get a list of available targets to select.";
                Selection.activeObject = Unsupported.GetSerializedAssetInterfaceSingleton("PlayerSettings");
                TizenUtilities.ShowErrDlgAndThrow("Tizen Deployment Target has not been selected.", str4);
            }
            TizenUtilities.PrepareToolPaths();
            TizenUtilities.ValidateSigningProfile(stagingArea);
            if (flag)
            {
                TizenUtilities.AssertAnyDeviceReady(new Command.WaitingForProcessToExit(new Progress("Tizen Device Detection", "Detecting attached devices", progress.Get()).Show));
            }
            Directory.CreateDirectory(Path.Combine(stagingArea, "lib"));
            Directory.CreateDirectory(Path.Combine(stagingArea, "res"));
            Directory.CreateDirectory(Path.Combine(stagingArea, "setting"));
            string path = Path.Combine(stagingArea, "shared");

            Directory.CreateDirectory(path);
            string str9 = Path.Combine(path, "res");

            Directory.CreateDirectory(str9);
            string destDirName = Path.Combine(str9, "data");
            string dst         = Path.Combine(str9, "app_icon.png");

            FileUtil.MoveFileIfExists(Path.Combine(stagingArea, "app_icon.png"), dst);
            if (!PlayerSettings.SplashScreen.show)
            {
                string str12 = Path.Combine(str9, "app_splash.png");
                FileUtil.MoveFileIfExists(Path.Combine(stagingArea, "app_splash.png"), str12);
                if (!File.Exists(str12))
                {
                    FileUtil.CopyFileOrDirectory(playerPackage + "/assets/splash.png", str12);
                }
            }
            Directory.CreateDirectory(Path.Combine(path, "trusted"));
            Directory.Move(stagingAreaDataUpperCase, destDirName + "2");
            Directory.Move(destDirName + "2", destDirName);
            if (!File.Exists(dst))
            {
                FileUtil.CopyFileOrDirectory(str2 + "/icon.png", dst);
            }
            Directory.CreateDirectory(Path.Combine(destDirName, "Managed/mono/2.0"));
            FileUtil.CopyFileOrDirectory(playerPackage + "/Data/Resources/unity default resources", destDirName + "/unity default resources");
            Directory.CreateDirectory(Path.Combine(stagingArea, "data"));
            string str15 = Path.Combine(stagingArea, "lib");

            Directory.CreateDirectory(str15);
            foreach (PluginImporter importer in PluginImporter.GetImporters(target))
            {
                string fileName = Path.GetFileName(importer.assetPath);
                FileUtil.UnityFileCopy(importer.assetPath, Path.Combine(str15, fileName));
            }
            if (Directory.Exists("Assets/StreamingAssets"))
            {
                FileUtil.CopyDirectoryRecursive("Assets/StreamingAssets", Path.Combine(destDirName, "Raw"), true, true);
            }
            AssemblyReferenceChecker checker = new AssemblyReferenceChecker();
            bool collectMethods   = true;
            bool ignoreSystemDlls = true;

            string[] components = new string[] { destDirName, "Managed" };
            string   str17      = Paths.Combine(components);

            checker.CollectReferences(str17, collectMethods, 0f, ignoreSystemDlls);
            string bundleIdentifier = PlayerSettings.bundleIdentifier;

            CreateManifest(Path.Combine(stagingArea, "tizen-manifest.xml"), companyName, productName, normalizedProductName, bundleIdentifier, checker);
            CreateProject(stagingArea);
            PackageTargets(PlayerSettings.Tizen.deploymentTargetType, installPath, playerPackage, stagingArea, developmentPlayer, normalizedProductName);
            if (flag)
            {
                progress.Step("Installing", EditorGUIUtility.TextContent("Installing application on " + TizenUtilities.SelectedDeploymentTarget() + "...").text);
                if (TizenUtilities.InstallTpkPackage(installPath))
                {
                    if (developmentPlayer)
                    {
                        progress.Step("Port Forwarding", EditorGUIUtility.TextContent("Setting up profiler tunnel...").text);
                        TizenUtilities.ForwardPort(ProfilerDriver.directConnectionPort, "55000");
                    }
                    progress.Step("Launching", EditorGUIUtility.TextContent("Launching application on " + TizenUtilities.SelectedDeploymentTarget() + "...").text);
                    TizenUtilities.LaunchTpkPackage(bundleIdentifier, stagingArea);
                }
            }
        }