Exemplo n.º 1
0
        private void OnBuildSettingsChanged()
        {
            // Only set this if supporting SDK that needs Android (and is installed!).
#if UNITY_ANDROID
#if UNITY_EDITOR_WIN
            string adbExe = "adb.exe";
#else
            string adbExe = "adb";
#endif
            // If we're on Android cache the path to adb as it used during building. Need to do it pre-work so on main thread.
            m_adbPath = BuildTiltBrush.GuiSelectedBuildTarget == BuildTarget.Android
        ? Path.Combine(UnityEditor.Android.AndroidExternalToolsSettings.sdkRootPath, "platform-tools", adbExe)
        : null;
#endif

            m_currentBuildPath = BuildTiltBrush.GetAppPathForGuiBuild();
            if (File.Exists(m_currentBuildPath))
            {
                m_currentBuildTime = File.GetLastWriteTime(m_currentBuildPath);
            }
            else
            {
                m_currentBuildTime = null;
            }

            string exeName  = Path.GetFileName(m_currentBuildPath);
            string exeTitle = Path.GetFileNameWithoutExtension(exeName);

            if (m_upload != null)
            {
                m_upload.Cancel();
            }

            m_upload = new AndroidOperation(
                string.Format("Upload {0} to {1}", exeName, m_selectedAndroid),
                (results) => results.Any(x => x.StartsWith("Success")),
                "-s", m_selectedAndroid,
                "install", "-r", "-g", m_currentBuildPath
                );

            if (m_launch != null)
            {
                m_launch.Cancel();
            }
            m_launch = new AndroidOperation(
                string.Format("Launch {0}", exeName),
                (results) => results.Any(x => x.Contains("Starting: Intent")),
                "-s", m_selectedAndroid,
                "shell", "am", "start",
                string.Format("{0}/com.unity3d.player.UnityPlayerActivity", exeTitle)
                );

            if (m_turnOnAdbDebugging != null)
            {
                m_turnOnAdbDebugging.Cancel();
            }
            m_turnOnAdbDebugging = new AndroidOperation(
                "Turn on adb debugging/profiling",
                (results) => true,
                "-s", m_selectedAndroid,
                "forward", "tcp:34999",
                string.Format("localabstract:Unity-{0}", exeTitle)
                );

            if (m_launchWithProfile != null)
            {
                m_launchWithProfile.Cancel();
            }
            m_launchWithProfile = new AndroidOperation(
                string.Format("Launch with deep profile {0}", exeName),
                (results) => results.Any(x => x.Contains("Starting: Intent")),
                "-s", m_selectedAndroid,
                "shell", "am", "start",
                string.Format("{0}/com.unity3d.player.UnityPlayerActivity", exeTitle),
                "-e", "unity", "-deepprofiling"
                );

            if (m_terminate != null)
            {
                m_terminate.Cancel();
            }
            m_terminate = new AndroidOperation(
                string.Format("Terminate {0}", exeName),
                (results) => true,
                "-s", m_selectedAndroid,
                "shell", "am", "force-stop", exeTitle
                );
        }
Exemplo n.º 2
0
        private void BuildSetupGui()
        {
            GUILayoutOption[] options = new GUILayoutOption[]
            {
                GUILayout.ExpandHeight(true),
            };

            GUILayoutOption[] toggleOpt = new GUILayoutOption[]
            {
                GUILayout.Width(150),
            };

            using (var changeScope = new EditorGUI.ChangeCheckScope())
            {
                using (var setupBar = new GUILayout.HorizontalScope(GUILayout.Height(110)))
                {
                    // Sdk Modes
                    using (var sdkBar = new HeaderedVerticalLayout("VR SDK", options))
                    {
                        SdkMode[] sdks        = BuildTiltBrush.SupportedSdkModes();
                        SdkMode   selectedSdk = BuildTiltBrush.GuiSelectedSdk;
                        foreach (var sdk in sdks)
                        {
                            bool selected    = sdk == selectedSdk;
                            bool newSelected = GUILayout.Toggle(selected, sdk.ToString(), toggleOpt);
                            if (selected != newSelected)
                            {
                                BuildTiltBrush.GuiSelectedSdk = sdk;
                            }
                        }
                    }

                    // Platforms
                    using (var platformBar = new HeaderedVerticalLayout("Platform", options))
                    {
                        BuildTarget[] targets        = BuildTiltBrush.SupportedBuildTargets();
                        BuildTarget   selectedTarget = BuildTiltBrush.GuiSelectedBuildTarget;
                        SdkMode       selectedSdk    = BuildTiltBrush.GuiSelectedSdk;
                        foreach (var target in targets)
                        {
                            GUI.enabled = BuildTiltBrush.BuildTargetSupported(selectedSdk, target);
                            bool selected    = target == selectedTarget;
                            bool newSelected = GUILayout.Toggle(selected, target.ToString(), toggleOpt);
                            if (selected != newSelected)
                            {
                                BuildTiltBrush.GuiSelectedBuildTarget = target;
                            }
                        }
                        GUI.enabled = true;
                    }

                    // Runtime
                    using (var runtimeBar = new HeaderedVerticalLayout("Runtime", options))
                    {
                        bool isIl2cpp    = BuildTiltBrush.GuiRuntimeIl2cpp;
                        bool newIsMono   = GUILayout.Toggle(!isIl2cpp, "Mono", toggleOpt);
                        bool newIsIl2cpp = GUILayout.Toggle(isIl2cpp, "IL2CPP", toggleOpt);
                        if (isIl2cpp != newIsIl2cpp || isIl2cpp != !newIsMono)
                        {
                            BuildTiltBrush.GuiRuntimeIl2cpp = !isIl2cpp;
                        }
                    }

                    // Options
                    using (var optionsBar = new HeaderedVerticalLayout("Options", options))
                    {
                        BuildTiltBrush.GuiDevelopment =
                            GUILayout.Toggle(BuildTiltBrush.GuiDevelopment, "Development");
                        BuildTiltBrush.GuiExperimental =
                            GUILayout.Toggle(BuildTiltBrush.GuiExperimental, "Experimental");
                        BuildTiltBrush.GuiAutoProfile =
                            GUILayout.Toggle(BuildTiltBrush.GuiAutoProfile, "Auto Profile");
                    }
                }

                if (changeScope.changed)
                {
                    OnBuildSettingsChanged();
                }
            }
        }
Exemplo n.º 3
0
        private void MakeBuildsGui()
        {
            using (var buildBar = new HeaderedVerticalLayout("Build"))
            {
                using (var buttonBar = new GUILayout.HorizontalScope())
                {
                    bool build = GUILayout.Button("Build");
                    GUI.enabled = !BuildTiltBrush.DoingBackgroundBuild;
                    bool buildBackground = GUILayout.Button("Background Build");

                    GUI.enabled = BuildTiltBrush.DoingBackgroundBuild;
                    if (GUILayout.Button("Cancel"))
                    {
                        BuildTiltBrush.TerminateBackgroundBuild();
                    }
                    GUI.enabled = true;

                    if (build)
                    {
                        EditorApplication.delayCall += () =>
                        {
                            bool oldBackground = BuildTiltBrush.BackgroundBuild;
                            try
                            {
                                BuildTiltBrush.BackgroundBuild = false;
                                ResetBuildLog();
                                BuildStartTime = DateTime.Now;
                                BuildTiltBrush.MenuItem_Build();
                            }
                            finally
                            {
                                BuildTiltBrush.BackgroundBuild = oldBackground;
                            }
                        };
                    }

                    if (buildBackground)
                    {
                        ResetBuildLog();
                        BuildStartTime = DateTime.Now;
                        BuildTiltBrush.DoBackgroundBuild(BuildTiltBrush.GetGuiOptions(), false);
                    }
                }

                using (var optionsBar = new GUILayout.HorizontalScope())
                {
                    UploadAfterBuild = GUILayout.Toggle(UploadAfterBuild, "Upload after Build");
                    RunAfterUpload   = GUILayout.Toggle(RunAfterUpload, "Run after Upload");
                }

                int start = Mathf.Clamp(m_buildLog.Count - 11, 0, int.MaxValue);
                if (m_buildLogPosition.HasValue)
                {
                    start = m_buildLogPosition.Value;
                }

                if (m_buildLog.Count > 0)
                {
                    int width = (int)(position.width - 35);
                    int end   = Mathf.Clamp(start + 10, 0, m_buildLog.Count);
                    using (var horizSection = new GUILayout.HorizontalScope())
                    {
                        using (var vertSection = new GUILayout.VerticalScope(GUILayout.Width(width)))
                        {
                            for (int i = start; i < end; ++i)
                            {
                                GUILayout.Label(m_buildLog[i], GUILayout.Width(width));
                            }
                        }

                        float size     = 10f / m_buildLog.Count;
                        float newStart = GUILayout.VerticalScrollbar(start, size, 0, m_buildLog.Count, GUILayout.Height(180));
                        if (newStart >= (m_buildLog.Count - 11f))
                        {
                            m_buildLogPosition = null;
                        }
                        else
                        {
                            m_buildLogPosition = (int)newStart;
                        }
                    }
                }

                if (BuildTiltBrush.DoingBackgroundBuild)
                {
                    Rect   r            = EditorGUILayout.BeginVertical();
                    float  buildSeconds = (float)(DateTime.Now - BuildStartTime).TotalSeconds;
                    float  progress     = Mathf.Clamp01(buildSeconds / SuccessfulBuildSeconds) * 0.95f;
                    float  remaining    = SuccessfulBuildSeconds - buildSeconds;
                    string time         = "???";
                    if (remaining > 0)
                    {
                        var span = TimeSpan.FromSeconds(remaining);
                        time = string.Format("{0}:{1:00}", (int)span.TotalMinutes, span.Seconds);
                    }
                    EditorGUI.ProgressBar(r, progress, string.Format("Building - {0} remaining.", time));
                    GUILayout.Space(18);
                    EditorGUILayout.EndVertical();
                }
            }
        }
Exemplo n.º 4
0
        private void OnBuildSettingsChanged()
        {
            m_currentBuildPath = BuildTiltBrush.GetAppPathForGuiBuild();
            if (File.Exists(m_currentBuildPath))
            {
                m_currentBuildTime = File.GetLastWriteTime(m_currentBuildPath);
            }
            else
            {
                m_currentBuildTime = null;
            }

            string exeName  = Path.GetFileName(m_currentBuildPath);
            string exeTitle = Path.GetFileNameWithoutExtension(exeName);

            if (m_upload != null)
            {
                m_upload.Cancel();
            }

            m_upload = new AndroidOperation(
                string.Format("Upload {0} to {1}", exeName, m_selectedAndroid),
                (results) => results.Any(x => x.StartsWith("Success")),
                "-s", m_selectedAndroid,
                "install", "-r", "-g", m_currentBuildPath
                );

            if (m_launch != null)
            {
                m_launch.Cancel();
            }
            m_launch = new AndroidOperation(
                string.Format("Launch {0}", exeName),
                (results) => results.Any(x => x.Contains("Starting: Intent")),
                "-s", m_selectedAndroid,
                "shell", "am", "start",
                string.Format("{0}/com.unity3d.player.UnityPlayerActivity", exeTitle)
                );

            if (m_turnOnAdbDebugging != null)
            {
                m_turnOnAdbDebugging.Cancel();
            }
            m_turnOnAdbDebugging = new AndroidOperation(
                "Turn on adb debugging/profiling",
                (results) => true,
                "-s", m_selectedAndroid,
                "forward", "tcp:34999",
                string.Format("localabstract:Unity-{0}", exeTitle)
                );

            if (m_launchWithProfile != null)
            {
                m_launchWithProfile.Cancel();
            }
            m_launchWithProfile = new AndroidOperation(
                string.Format("Launch with deep profile {0}", exeName),
                (results) => results.Any(x => x.Contains("Starting: Intent")),
                "-s", m_selectedAndroid,
                "shell", "am", "start",
                string.Format("{0}/com.unity3d.player.UnityPlayerActivity", exeTitle),
                "-e", "unity", "-deepprofiling"
                );

            if (m_terminate != null)
            {
                m_terminate.Cancel();
            }
            m_terminate = new AndroidOperation(
                string.Format("Terminate {0}", exeName),
                (results) => true,
                "-s", m_selectedAndroid,
                "shell", "am", "force-stop", exeTitle
                );
        }