Application quit unity не работает

Application.Quit

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Submission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Declaration

Parameters

exitCode An optional exit code to return when the player application terminates on Windows, Mac and Linux. Defaults to 0.

Description

Quits the player application.

Shut down the running application. The Application.Quit call is ignored in the Editor.

If you want to use Application.Quit when running Unity inside another application, see the UnityasaLibrary-Android Unity as a Library Manual page for more information.

Note: In most cases termination of application under iOS should be left at the user’s discretion. Calling this method in iOS player might appear to the user that the application has crashed. For more information, see Apple Technical Page qa1561.

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.

Copyright ©2021 Unity Technologies. Publication Date: 2021-10-08.

Источник

MonoBehaviour.OnApplicationQuit()

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Submission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Description

Sent to all GameObjects before the application quits.

In the Editor, Unity calls this message when playmode is stopped.

Note: iOS applications are usually suspended and do not quit. For iOS builds, enable the » Exit on Suspend » property in Player Settings to make the application quit and not suspend, otherwise you might not see this call. If you do not enable the » Exit on Suspend » property then you will see calls to OnApplicationPause instead.

On Windows Store Apps and Windows Phone 8.1 there is no application quit event. Use the OnApplicationFocus event when focusStatus equals false .
On WebGL it is not possible to implement OnApplicationQuit because of the way browser tabs close. For a workaround, see the Unity User Manual documentation on Interacting with browser scripting in WebGL.

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.

Copyright ©2021 Unity Technologies. Publication Date: 2021-10-08.

Источник

Реализация кнопки Back на Android в Unity3d?

Доброго времени суток!)
В связи со своей не опытностью в геймдеве столкнулся с проблемой что в приложение сделанном на юнити по дефолту аппаратные кнопки андроида не работают -_-
Саму кнопку как отслеживать сделал.

Гугл посоветовал использовать именно Application.Quit(); для выхода из приложения. но у меня ноль эффекта -_- На всякий случай проверил ловится ли нажатие на кнопку, вставив на выполнение загрузку сцены. Кнопка ловит, все в порядке.

Вопрос
Как реализовать выход на сцену назад с последующим выходом из приложения по двойному нажатию на «Назад» с высвечиванием системного сообщения «для выхода из приложения нажмите два раза «назад» «?

  • Вопрос задан более трёх лет назад
  • 10822 просмотра
Читайте также:  Lancer 9 не работает звуковой сигнал

ну с знаете, многовато вы требуете из простого вопроса как сделать кнопку -> как реализовать кучу всего.

Кстати двойной тап на кнопку назад — вызывает сворачивание(выгрузку из памяти) приложений в том же циагене андроидовском.
поэтому если и реализовывать выход, то просто по одиночному нажатию, когда некуда уже назад «отматывать».
и обязательно не забудьте про окошко подтверждения, а то как практика показывает без него — много жалуются.

А по делу — вы уже знаете как отследить одно нажатие.
Вперед , дерзайте.
после первого нажатия отслеживайте второе (таймер там добавить, чтоб два нажатия быстрее чем за N секунд — считается двойным тапом)

не может не срабатывать, ну или вы запускаете в эдиторе или веб билде не почитав документацию, почему-то.

лишь чуток добавлю что #if UNITY_ANDROID и подобное зовется директивами. и это не совсем проверка.
не знаю важно или нет или уже прочитали, но это по сути «знак» компилятору — компилировать этот кусок кода или нет).

«if (Application.platform == RuntimePlatform.Android)
в которой явно прописано что данный код работает только если запускается на андроид.»

ну а про эту строчку просто забыл) простите) очевидным казалось что неё надо если нужно чтоб везде работало))

и про выход в прошлую сцену.
юнити к сожалению никаких готовых решений не дает, если вы говорите про «запомнить прошлый экран, на который надо вернуться»(по крайней мере ни разу не встречал таких).

только свои список . складываем/удаляем элементы при загрузках/переходах.

Источник

Application.quitting

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Submission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Description

Unity raises this event when the player application is qutting.

Add an event handler to this event to recieve a notification that the application is quitting.

Note: This will not fire if the player is forced to quit or if there is a crash. This event is raised when the quitting process cannot be cancelled.

Note: iOS applications are usually suspended and do not quit. You should tick «Exit on Suspend» in Player settings for iOS builds to cause the game to quit and not suspend, otherwise you may not see this call. If «Exit on Suspend» is not ticked then you will see calls to OnApplicationPause instead.

Note: On Windows Store Apps and Windows Phone 8.1 there’s no application quit event, consider using OnApplicationFocus event when focusStatus equals false.

To prevent the player application from quitting look at the Application.wantsToQuit event.

Did you find this page useful? Please give it a rating:

Thanks for rating this page!

What kind of problem would you like to report?

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at

Thanks for letting us know! This page has been marked for review based on your feedback.

If you have time, you can provide more information to help us fix the problem faster.

You’ve told us this page needs code samples. If you’d like to help us further, you could provide a code sample, or tell us about what kind of code sample you’d like to see:

You’ve told us there are code samples on this page which don’t work. If you know how to fix it, or have something better we could use instead, please let us know:

Читайте также:  Event trigger unity не работает

You’ve told us there is information missing from this page. Please tell us more about what’s missing:

You’ve told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

You’ve told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

You’ve told us there is a spelling or grammar error on this page. Please tell us what’s wrong:

You’ve told us this page has a problem. Please tell us more about what’s wrong:

Thanks for helping to make the Unity documentation better!

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.

Copyright © 2018 Unity Technologies. Publication: 2018.1-002N. Built: 2018-12-04.

Источник

Application

class in UnityEngine

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Submission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Description

Access to application run-time data.

This class contains static methods for looking up information about and controlling the run-time data.

Static Properties

absoluteURL The URL of the document. For WebGL, this a web URL. For Android, iOS, or Universal Windows Platform (UWP) this is a deep link URL. (Read Only)
backgroundLoadingPriority Priority of background loading thread.
buildGUID Returns a GUID for this build (Read Only).
cloudProjectId A unique cloud project identifier. It is unique for every project (Read Only).
companyName Return application company name (Read Only).
consoleLogPath Returns the path to the console log file, or an empty string if the current platform does not support log files.
dataPath Contains the path to the game data folder on the target device (Read Only).
genuine Returns false if application is altered in any way after it was built.
genuineCheckAvailable Returns true if application integrity can be confirmed.
identifier Returns application identifier at runtime. On Apple platforms this is the ‘bundleIdentifier’ saved in the info.plist file, on Android it’s the ‘package’ from the AndroidManifest.xml.
installerName Returns the name of the store or package that installed the application (Read Only).
installMode Returns application install mode (Read Only).
internetReachability Returns the type of Internet reachability currently possible on the device.
isBatchMode Returns true when Unity is launched with the -batchmode flag from the command line (Read Only).
isConsolePlatform Is the current Runtime platform a known console platform.
isEditor Are we running inside the Unity editor? (Read Only)
isFocused Whether the player currently has focus. Read-only.
isMobilePlatform Is the current Runtime platform a known mobile platform.
isPlaying Returns true when called in any kind of built Player, or when called in the Editor in Play Mode (Read Only).
persistentDataPath (Read Only) Contains the path to a persistent data directory.
platform Returns the platform the game is running on (Read Only).
productName Returns application product name (Read Only).
runInBackground Should the player be running when the application is in the background?
sandboxType Returns application running in sandbox (Read Only).
streamingAssetsPath The path to the StreamingAssets folder (Read Only).
systemLanguage The language the user’s operating system is running in.
targetFrameRate Instructs the game to try to render at a specified frame rate.
temporaryCachePath Contains the path to a temporary data / cache directory (Read Only).
unityVersion The version of the Unity runtime used to play the content.
version Returns application version number (Read Only).
Читайте также:  Не работает микрофон iphone айсаппорт

Static Methods

CanStreamedLevelBeLoaded Can the streamed level be loaded?
GetBuildTags Returns an array of feature tags in use for this build.
GetStackTraceLogType Get stack trace logging options. The default value is StackTraceLogType.ScriptOnly.
HasProLicense Is Unity activated with the Pro license?
HasUserAuthorization Check if the user has authorized use of the webcam or microphone in the Web Player.
IsPlaying Returns true if the given object is part of the playing world either in any kind of built Player or in Play Mode.
OpenURL Opens the URL specified, subject to the permissions and limitations of your app’s current platform and environment. This is handled in different ways depending on the nature of the URL, and with different security restrictions, depending on the runtime platform.
Quit Quits the player application.
RequestAdvertisingIdentifierAsync Request advertising ID for iOS and Windows Store.
RequestUserAuthorization Request authorization to use the webcam or microphone on iOS.
SetBuildTags Set an array of feature tags for this build.
SetStackTraceLogType Set stack trace logging options. The default value is StackTraceLogType.ScriptOnly.
Unload Unloads the Unity Player.

Events

deepLinkActivated This event is raised when an application running on Android, iOS, or the Universal Windows Platform (UWP) is activated using a deep link URL.
focusChanged Defines the delegate to use to register for events in which the focus gained or lost.
logMessageReceived Event that is fired if a log message is received.
logMessageReceivedThreaded Event that is fired if a log message is received.
lowMemory This event occurs when your app receives a low-memory notification from the device it is running on. This only occurs when your app is running in the foreground. You can release non-critical assets from memory (such as, textures or audio clips) in response to this in order to avoid the app being terminated. You can also load smaller versions of such assets. Furthermore, you should serialize any transient data to permanent storage to avoid data loss if the app is terminated.This event is supported on iOS, Android, and Universal Windows Platform (UWP).This event corresponds to the following callbacks on the different platforms:iOS: [UIApplicationDelegate applicationDidReceiveMemoryWarning]Android: onLowMemory() and onTrimMemory(level == TRIM_MEMORY_RUNNING_CRITICAL)UWP: MemoryManager.AppMemoryUsageIncreased (AppMemoryUsageLevel == OverLimit)Note: For UWP, this event will not occur on Desktop and only works on memory constrained devices, such as HoloLens and Xbox One. The OverLimit threshold specified by the OS in this case is so high it is not reasonably possible to reach it and trigger the event.Here is an example of handling the callback:
onBeforeRender Delegate method used to register for «Just Before Render» input updates for VR devices.
quitting Unity raises this event when the player application is qutting.
unloading Unity raises this event when Player is unloading.
wantsToQuit Unity raises this event when the player application wants to quit.

Delegates

AdvertisingIdentifierCallback Delegate method for fetching advertising ID.
LogCallback Use this delegate type with Application.logMessageReceived or Application.logMessageReceivedThreaded to monitor what gets logged.
LowMemoryCallback This is the delegate function when a mobile device notifies of low memory.

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.

Copyright ©2021 Unity Technologies. Publication Date: 2021-10-08.

Источник

Оцените статью