I have an enum RemoteCommand that I am trying to pass the values of into my Unity iOS game. Abridged Swift code:

enum RemoteCommand:String {
    case none
    case open = "Open"
    case closed = "Closed"

func showAndSendCommand (_ command:RemoteCommand) {
    DispatchQueue.main.async {
        if command == .open {
        } else if command == .closed {

I am looking for best practices on how to pass this command value that's being printed into my Unity iOS build. The above code lives in the ViewController.swift file, and calculations that are performed on the native iOS side concurrently with the Unity game running should determine that command value. I've looked into embedding the Unity game in my XCode project, but one of the drawbacks I've read is that "embedding Unity can cause problems withing the game, especially graphics ones."

Essentially, I just want to pass a simple string into my Unity game. This string is determined by calculations that need to run in Swift while the game is ongoing. The game will fetch this string value every frame.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.