Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How catch exitCode from unity app in other application?

Discussion in 'Scripting' started by Sly88, Dec 30, 2020.

  1. Sly88

    Sly88

    Joined:
    Feb 22, 2016
    Posts:
    73
    hello,
    I have some question I would like to close the unity app via Application.Quit(special id) and catch it or check the exit code in another app it is possible?

    best
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    This is dependent on the OS (and possibly shell) you are using, but generally it's the same on a given OS for ALL programs running under it. Look at the docs for however you are spawning the Unity process as a child, and see how to get exit codes back when that process terminates.
     
  3. Sly88

    Sly88

    Joined:
    Feb 22, 2016
    Posts:
    73
    I would like to use it on desktop app Win and Mac
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    That's the first place to start looking then. As I said above, 100% of the answer depends on how the other program spawns your process. You need to understand that first.
     
  5. Sly88

    Sly88

    Joined:
    Feb 22, 2016
    Posts:
    73
    [ workspace launchApplicationAtURL:url options:0 configuration:[NSDictionary dictionaryWithObject:arguments forKey:NSWorkspaceLaunchConfigurationArguments] error:&error];

    I use it for mac but I think I can't handle error code from this maybe I should use NSTask to run unity app
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    I don't know the details of all the NS-prefixed library crud, but basic C interprocess stuff can get you return codes, stuff that is contained in stdio like popen() and exec() and whatnot. Look at the latest docs to see what is safe to use these days because anytime you spawn an external process you probably want to understand the security issues of it.