Пример #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
                );
        }
Пример #2
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
                );
        }