Esempio n. 1
0
    public void BuildAll()
    {
        List <string> buildTargetNamesByTargetGroup = (from buildTarget in GetComponentsInChildren <EzBuildTarget>()
                                                       orderby buildTarget.buildTarget
                                                       select buildTarget.name).ToList();

        // the scenes are reloaded between each build, so have to refind the targets
        foreach (string childName in buildTargetNamesByTargetGroup)
        {
            EzBuild ezBuild = FindObjectOfType <EzBuild>();

            EzBuildTarget ezbt = (from bt in ezBuild.GetComponentsInChildren <EzBuildTarget>()
                                  where bt.name == childName
                                  select bt).First();

            if (ezBuild.overrideChildSettings)
            {
                ezbt.Build(ezBuild.settings);
            }
            else
            {
                ezbt.Build(ezbt.settings);
            }
        }
    }
Esempio n. 2
0
    public override void OnInspectorGUI()
    {
        ezBuild = target as EzBuild;

        if (GUILayout.Button("Choose build location"))
        {
            Undo.RegisterFullObjectHierarchyUndo(ezBuild.gameObject, "Choose location");
            ezBuild.buildLocation = EditorUtility.OpenFolderPanel("Choose a build location", "", "");
        }

        if (GUILayout.Button("Build All"))
        {
            if (EditorUtility.DisplayDialog("Are you sure you want to build all?", "This could take a while.", "Yes", "No"))
            {
                ezBuild.BuildAll();
            }
        }

        base.OnInspectorGUI();
    }
Esempio n. 3
0
    public void Build(EzBuildTargetSettings curSettings)
    {
        currentSettings = curSettings;

        ezb = GetComponentInParent <EzBuild>();
        ezb.PrepBuild();

        string buildLocation       = ezb.buildLocation;
        string prefix              = GetBuildPrefix(buildTarget);
        string gameNameWithDetails = $"{ezb.gameName}-{prefix}-{Application.version}";

        // move old versions of the game into the /old/ directory
        // first check: is there already an object with that name in this location?
        // if so, move them all to old
        foreach (string directoryPath in Directory.GetDirectories(buildLocation))
        {
            string directoryName = Path.GetFileName(directoryPath);

            // does the cur folder already contain a build w this name? if so move it
            if (directoryPath.Contains(prefix))
            {
                string moveLocation = Path.Combine(buildLocation, "old", $"{directoryName}");
                int    number       = 0;
                // also the old dir might contain this build too
                while (Directory.Exists(moveLocation))
                {
                    number++;

                    moveLocation = Path.Combine(buildLocation, "old", $"{directoryName}-{number}");
                }

                Directory.Move(directoryPath, moveLocation);
            }
        }

        // similar to the above, are there zip files with the given names in here? move them too
        foreach (string zipFilePath in Directory.GetFiles(buildLocation).ToList())
        {
            string fileName = Path.GetFileName(zipFilePath);

            Debug.Log(fileName);

            // does the cur folder already contain a build w this name? if so move it?
            if (fileName.Contains(prefix))
            {
                string moveLocation = Path.Combine(buildLocation, "old", $"{fileName}.zip");

                int number = 0;

                // also the old dir might contain this build too
                while (File.Exists(moveLocation))
                {
                    number++;

                    moveLocation = Path.Combine(buildLocation, "old", $"{fileName}-{number}.zip");
                }

                Debug.Log(zipFilePath + " " + moveLocation);

                File.Move(zipFilePath, moveLocation);
            }
        }

        string gamePath, gameFolderPath;

        // does the target need a subfolder made for it? or will unity handle it?
        if (OSXBuild())
        {
            gamePath = Path.Combine(buildLocation, $"{gameNameWithDetails}/{ezb.gameName}.app");

            gameFolderPath = $"{gamePath}";

            Directory.CreateDirectory(gameFolderPath);
        }
        else
        {
            gameFolderPath = Path.Combine(buildLocation, gameNameWithDetails);

            Directory.CreateDirectory(gameFolderPath);

            if (WindowsBuild())
            {
                gamePath = Path.Combine(gameFolderPath, $"{ezb.gameName}.exe");
            }
            else if (WebGLBuild())
            {
                gamePath = gameFolderPath;
            }
            else
            {
                gamePath = Path.Combine(gameFolderPath, ezb.gameName);
            }
        }

        //once that's done, build into the location
        DoBuild(gamePath);

        if (currentSettings.zip)
        {
            System.IO.Compression.ZipFile.CreateFromDirectory(gameFolderPath, $"{gameFolderPath}.zip", System.IO.Compression.CompressionLevel.Fastest, OSXBuild());
        }

        Debug.Log($"Succesfully built for {prefix}");
    }